acer

32747 Reputation

29 Badges

20 years, 111 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

How does your supervisor feel about an interactive solution using Embedded Components?

acer

@Carl Love Yes, that kind of deferment (userinfo, etc) is part of the unfortunate way that Document Blocks are implemented (the pair of execution  groups, one with output suppressed and the other with input hidden...).

But the OP mentioned printf, and is I recall corectly that particular kind of i/o can usually be obtained asynchronously even in a Document Block. So that's one reason why I asked for more details.

[edit] I must correct myself. In a Document Block it seems that even printf display is deferred. dbdefer.mw

However, the OP has now clarified: this is about a Worksheet, so the above not relevant.

More details might help here. What OS? Is this in a Worksheet and an Execution Group or a Document and a paragraph (Document Block)?

How much output are we talking about? Very many short-ish lines?

Is there any natural amount of output which you actually would like to see, in a block? Or do you want every line? Or only one last line is useful?

Do you have a sample of code that demonstrates the problem, that we can work with?

Have you tried sprintf and redirecting that to a TextArea embedded component? (Just an idea... may not be suitable here, depending on the details above.)

acer

So your problem is with the final call to `solve`, when epsilon is greater than 0?

If so, then you could try using `fsolve` (repeated, with the avoid option built uo) or the `DirectSearch` (3rd party add-on from the Application Center) rather than `solve`. 

Let us know if you need all the roots, or just one real root, or all the real roots, etc.

acer

assumptions, internal remember tables... if the OP wants a clean slate then it seems sensible to restart. The premise that a restart should be avoided because package initialization is onerous seems faulty to me.

If you are loading packages using the mouse and the menubar Tools->Load Package... then I suggest that instead you make the package loading be done explicitly by code in the Document/Worksheet.

You can even paste all the package loading commands (calls to the `with` command) on the same line, so that you can execute them all in one keystroke.

You can even make the Standard GUI insert the actuall command for you, the first time you load the packages in the worksheet. See the menubar item Tools->Options->Display and the checkbox "Expose commands inserted from Load/Unload Package menus". If you check that then subsequent use of Tools->Load Package from the menubar will embed the `with` command call in the document.

acer

@MTata94 You can define the "subroutine" inside the outer procedure, but you don't have to.

One disadvantage of defining the subroutine `q` inside the body of the calling procedure `p` is that it incurs the cost of defining `q` each time `p` is called. That cost may be negligible for simple examples, though.

For example, here I define q at the top-level, alongside p. Note that `q` is no longer declared local inside p.

restart:

q:=proc(s) s^2 end proc:

p:=proc(x::numeric)
  local k,r;
  r:=x;
  for k from 1 to 5 do
    r:=q(r)
  end do;
  evalf(sin(r))
end proc:

p(2);

                                -0.4619865795

If you wish to organize things, and so manage the name-space a little nicer, you can also make use of modules. For example,

restart:

p:=module()
  local ModuleApply, q;
  ModuleApply:=proc(x::numeric)
  local k,r;
  r:=x;
  for k from 1 to 5 do
    r:=q(r)
  end do;
  evalf(sin(r))
  end proc:
  q:=proc(s) s^2 end proc:
end module:

p(2);
                                -0.4619865795

q(2); # note that now q is not assigned at the higher level.
                                    q(2)

See the Programming Manual ([1], [2]) for more details and examples.

@Markiyan Hirnyk Just to be clear, I meant as b->1 from below, while d->infinity.

@Markiyan Hirnyk Are you sure about the case of b < -1 ? Why not b/(b-1)?

And for the case of b>=-1 and b<0, why not undefined?

@dbachito Another way is to keep the Spline data (your e3) exact and differentiate the piecewise Spline before applying evalf. That works, but depending on the original function the process can become very slow as N gets large.

There are three real roots close to 0.085786 which give difficulty. Note that applying evalf to P before passing to fsolve will actually solve a different problem if Digits is not large enough to encapsulate the original exact data. And there is also the matter of the accuracy of the results.

The following is on Maple 2015.1 on a 64bit Linux system. With Digits<21 as the working precision I see at least two of those three problematic roots as being returned with nonzero and nonnegligible imaginary parts, when sending evalf(P) to fsolve. And with Digits=21 I see those particular three real roots' estimates as still having about 1e-9 absolute error. And when repeated (clean session or carefully with forget(evalf)) at even higher working precision those three roots get computed this way with about 15 fewer accurate digits than the others.

This is indeed a bug. Internally the candidate approximations to the problematic roots should be found wanting earlier (the bug is that `fsolve/refine2` is being passed candidates with Float(undefined) in them) and skipped so that `fsolve/polyill` can tackle them more robustly. I submitted a but report.

(I see also that robust RootFinding:-Isolate is never used when the complex option is passed. But it might help in such situations, perhaps making life easier on `fsolve/polyill`.)

In my 64bit Maple 18.02 and 2015.1 for Windows 7 the cited dsolve/numeric example (with the compile=true option) works ok.

I suppose that this is because dsolve/numeric in my Maple 18 and Maple 2015 is using the 3rd party "free" MSVC++ compiler and JDK components that I had installed to make Compiler:-Compile run in Maple 17 or some earlier Maple version.

In Maple 18 and Maple 2015 the Compiler:-Compile command uses the bundled LLVM compiler on 64bit Windows. But prior to those Maple releases one had to set up a 3rd party compiler to enable Compiler:-Compile. Here are the Maple 17 instructions, for example. I believe that I'd also installed the "2008" version of the "free" MSVC++/JDK components, for enabling Compiler:-Compile in Maple 15.

So my supposition is that configuring (at least one... particular?) version of the "free" MSVC++/JDK components for 64bit Windows 7 might allow your Maple 2015.1 dsolve/numeric to compile relevant examples in Windows 7. I don't know the situation on Windows 10.

It would nicer and simpler if dsolve/numeric were made to use the LLVM that is bundled with Maple.

I know how to change the settings which Compiler:-Compile uses to call a compiler. But that's not your issue, Preben, it seems. I don't know a good way to change arbitrarily the way dsolve/numeric attempts to call a compiler.

acer

@Carl Love rtable_eval(A, inplace) sets a bit on the rtable's DAG, I believe, to mark it.

There are efficiency considerations, when accessing rtable entries within a proc (of an rtable argument say). For example the situation of needing to access only a few entries of a large rtable with symbolic entries with nested assignment chains, versus needing to access all entries possibly multiple times each. Entry access involves evaluation, but it may be beneficial to not have to duplicate effort.

I'm on vacation with only a smartphone so cannot say more just now.

@Thomas Dean See also the `unapply` example above, at end.

So you can indeed get your methodology to work. But if you cannot remember why you need `unapply`, and when, then perhaps you might reconsider the whole approach and try to stick to expressions or procedures, only, as much as possible... Just a suggestion.

I note that confusion between functions and expressions is #1 on Robert Israel's Top Ten list. Worth a read.

One pattern I've observed is people creating a procedure like your original `f`, only to ever call it once as `f(x)`. If it's only ever called once, just to get an expression, then the odds seem good that there is a procedure/expression muddle of some sort.

Why not just assign the values into a Matrix or Array and then use ExcelTools:-Export?

I don't see why printing all the values would be useful or convenient for exporting, or anything but very inefficient.

acer

First 333 334 335 336 337 338 339 Last Page 335 of 600