acer

32348 Reputation

29 Badges

19 years, 330 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Adam Ledger The series command returns a special data-structure, which is not just a polynomial (a sum of terms). That special structure *prints* nicely like a polynomial and an error-term. But it's internal structure is different. And the `op` command works on the internal structure, not on what you see printed.

If you want to pick it apart as if it were a sum of products, like a polynomial, then you first need to convert. That's what gkokovidis has mentioned.

The operands of a SERIES data structure are not precisely the same as the operands of a SUM structure. The `op` command picks off operands.

If you want to use `op` without first converting to `polynom` then you need to adjust your usage to match the structure.

Try calling `op` (with no extra options to denote which operand) on both the result S from `series` as well as on convert(S,polynom). That might gain a little insight for you.

What happens if you do it with,

sprintf("%a", result)

instead of,

convert(result, string)

 

@John Fredsted Yes, it is essentially the same as `select`, for this example with procs in the list.

It's not exactly the same, because the seq indexer takes on elements of the list (rather than posint positions into the list, say). And so Tom's code needs that extra `eval` too.

A big part of why they are essentially the same is that looped list-augmentation is O(n^2) in memory (triangular usage), while both seq and select build up the result in one run and are O(n) in memory (up to gc and other maple-isms). It could also be done with `map`. Of course the constant factors in the time complexity of such different methods are each different, so in practice timings amongst them will differ. This complexity talk relates to asymptotic behavior, naturally. (I mention that in the hope that disingenuous dissemblers will not strive to muddy the waters. I'm most definitely not referring to Tom, by that.)

We haven't been told the precise nature of the expressions that may be present, or what types of function call should be accepted, but the following cases can also be easily handled by type typefunc. The original question is about testing for various types of function call, and that is what type typefunc can do.

The OP may decide which of the following sieves might serve.

restart;
                                                                                                                
eq3:=diff(u(t),t)+sin(diff(x(t),t))=t+x(t)-1+sin(x(t))
     +cos(t)+G(t,(D(x))(t),v(t))+D(w)(t)+P(n)(t)+K[m](t)
     +Diff(r(t),t,t):

indets(eq3, {name, 'typefunc(name, Non({last_name_eval,specfunc(D)}))'});

            {t, r(t), u(t), v(t), x(t), K[m](t), P(n)(t)}

indets(eq3, 'typefunc(name, Non({last_name_eval,specfunc(D)}))');

              {r(t), u(t), v(t), x(t), K[m](t), P(n)(t)}

indets(eq3, {name, 'typefunc(name, Non({last_name_eval,function}))'});

                {t, r(t), u(t), v(t), x(t), K[m](t)}

indets(eq3, 'typefunc(name, Non({last_name_eval,function}))');

                  {r(t), u(t), v(t), x(t), K[m](t)}

indets(eq3, {name,
             'typefunc(name, Non({last_name_eval,
                                  function,indexed}))'});

                     {t, r(t), u(t), v(t), x(t)}

indets(eq3, 'typefunc(name, Non({last_name_eval,
                                 function,indexed}))');

                       {r(t), u(t), v(t), x(t)}

[edit] Markiyan's use of x'(t) in plaintext 1D Maple Notation code is a syntax error. Code with 2D-Math-specific syntax is not sensible in plaintext. It's difficult to take seriously a seasoned user who makes such a fundamental mistake.

@John Fredsted Yes, sorry, lazy cut & paste. Fixed.

@John Fredsted In Kitonum's code the name F is assigned the list of anonymous procedures, and loop index name i takes integer values. But none of the names in play are ever assigned any procedure as value, so last-name-evaluation doesn't come into play.

Last-name-evaluation (LNE) serves a few useful purposes. It allows you to pass the name of a procedure as an argument (to some other procedure), without that name being evaluated to the procedure body of its value. Under normal evaluation rules arguments are evaluated.

Similarly, LNE allows you to pass the name of a table as an argument to a procedure, without that table being copied. Hence you can do in-place operations on tables (or other mutable data structures like the now-deprecated array/matrix/vector which are table-based under-the-hood).

While LNE is a rather brilliant solution (IMO) to the technical issue of allowing these beasts to be passed -- without copying and full evaluation -- as arguments to procedures, it can sometimes require explicit eval calls, as in your example. Sometimes it gets you into a mild muddle, from which the term last-name-evaluation-disease (LNED) was coined. Older users will remember the burden of using evalm when handling array/matrix/vector.

LNE is an important piece of the puzzle of Maple evaluation rules, as worth learning as special-evaluation-rules, and the fact that assigned locals and parameters of a procedure get only 1-level evaluation within the procedure body (following normal full eval of the arguments). For the last of those, see subsection "Statement Sequence Interpretation" of section 6.6 of the Programming Guide.

@John Fredsted A problematic case, for your particular candidate procs, would be when y had been assigned a value of 0. But the following tweak to the select predicate protects against that. Eg,

y:=0:

select(proc(f) local y; f(y)<>y; end proc,
       [x->x, x->2*x, x->3*x]);

               [x -> 2 x, x -> 3 x]

So that protects against y being assigned at the higher level. You might still need to consider whether it matters that f(y) might simplify to just y (which would matter equally in any of the other approaches suggested). I'll leave it to you whether you want or need a comparison stronger than just the implied evalb.

If that condition holds then x-y=0 for some x in the domain of integration, no?

It may be obvious to others, but to me it's not clear whether you are asking how to make all plots get left-aligned in a worksheet (wherever they are output, singly or otherwise), or how to get just one plot left-aligned (leaving some others centrally aligned).

My answer below relates to the second scenario -- where alignment of each single output plot is wanted independent.

When I do the Tools->Check for Updates->Download and Install on my 64bit Windows 7 Pro then, after it downloads, Maple's Standard GUI throws up a pop-up dialogue titled "Maple is running".

That pop-up offers me the choices of Exit/Cancel, Retry, Ignore, etc. I don't recall your mentioning such a dialog box, John. Did you see that? What's your platform?

I've never tried that pop-up's "Ignore" choice. But if I do quit/close the running Maple GUI instance (while that pop-up menu is left there), then I can then choose "Retry" in the pop-up dialog and the Installer progress pop-up appears and it updates from 2017.0 to 2017.1.

I wonder whether you might not be seeing that popup because, say, it's hidden behind your Maple GUI window, or perhaps because you're using OS X? But I don't recall your mentioning seeing that dialog.

@Markiyan Hirnyk The question posed is about a particular example. Your continual grasping for one-upmanship is sad.

`tar` is a Unix/Linux/OSX shell utility for unpacking archives.

`tar xzvf foobar.tar.gz` is a call to uncompress and unpack the archive whose filename is foobar.tar.gz .

The instructions almost certainly don't tell you to use "tar xzvf" in any filename or path. You are likely misreading and conflating separate steps in the instructions.

Similarly, there will likely not be a directory named blahblah.tar.gz to add to libname. Instead, after you unpack the archive, you'll see a new directory containing the unpacked contents, and that's what you should use instead.

`tar` is to MS-Windowz `zip` like archive file `foo.tar.gz` is to MS-Windows archive file `foo.zip`. 

@kuwait1 You can do what I said by running the second attachment I added before, the one named ANALYTIC_1_M13.00.mw . That works, in Maple 13.00. And one of the included ways runs reasonably quickly.

@Markiyan Hirnyk He is using Maple 13.00, and in that version RootFinding:-Analytic does not do so well as can be easily achieved using Calculus1:-Roots . 

Also, if you had bother to see my previous attachments you'd see that for this example the performance using Calculus1:-Roots can be much improved by first combining and (optionally) applying fnormal.

In my Maple 13.00, if I call Analytic(ee,phi=0-I..10+I) on ee the original expression it produces the 12 roots between 0 and 10 (as well as 0.+0.*I) in 10.8 seconds. But calling Calculus1:-Roots on fnormal(combine(ee)) produces those same 12 real roots in 1.4 seconds, while calling Analytic on fnormal(combine(ee)) produces and error message about "too many levels of recursion" after 72 seconds.

ANALYTIC_2_M13.00.mw

@Markiyan Hirnyk I had already considered that aspect when I made my Answer.

I still believe that the `timelimit` command best addresses the actual Question asked, which was about simple stopping of a subcomputation taking too long. There's no other action that would interrupt during a kernel built-in rather than an interpreted (e.g. Library) call, so it doesn't bear on the choice of mechanism.

I would hope the OP would read the Help page of the command I suggested.

First 276 277 278 279 280 281 282 Last Page 278 of 592