Carl Love

Carl Love

28100 Reputation

25 Badges

13 years, 105 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Rouben Rostamian  Another clever one, which avoids the need to repeat and `[]`~, is

plot(map2(`[]`~, x, [y1,y2]));

@ Thank you for the Reply. Yes, events are quite useful for stopping dsolve in situations that the programmer anticipates. Of course, in those situations, it is clear how the program, after stopping, can go on to return meaningful partial results. But I'm not interested (in this Question) in how to stop a program; rather, I am interested in how a program (any program, not just dsolve or odeplot)---which has been stopped via the stop button---can go on to return a result. If odeplot can do it, then other programs can do it as well, because odeplot is written in Maple---it's not builtin.   

@Rouben Rostamian  Thanks. The Maple 11 code for `convert/list` shows that when applied to a Vector, the relevant action happens on line 5 and is equivalent to my procedure CL2. In Maple 2015, the action is on line 15 and is equivalent to CL1.

@tomleslie The basic looping machinery of seq is several times faster than that of $. This can be seen with

restart:
CodeTools:-Usage([k $ k=1..2^22]):
memory used=96.08MiB, alloc change=32.00MiB, cpu time=750.00ms, real time=761.00ms, gc time=515.62ms

restart:
CodeTools:-Usage([seq(k,k=1..2^22)]):
memory used=32.00MiB, alloc change=32.00MiB, cpu time=203.00ms, real time=204.00ms, gc time=0ns

(Perhaps it's worth noting that the vast majority of the extra time for is due to garbage collection.)

However it's very easy to make a procedure f such that f(i) $ i= m..n runs significantly faster than seq(f(i), i= m..n). All that's needed is

  1. f(i) should be a relatively complicated procedure that produces a relatively simple result.
  2. f(i) shouldn't take significantly longer for symbolic i than for numeric i.

Here's such an f:

f:= proc(i)
local st:= time();
     while time()-st < 1 do end do; #Waste 1 second.
     i^2
end proc:

Now f(i) $ i= 1..9 takes 1 second and seq(f(i), i= 1..9) takes 9 seconds. This example is contrived, but solve fits the two criteria above. The key difference is that evaluates its first argument before numeric values are substituted for i and seq evaluates it anew for each value of i.

That answer about seq being thread safe makes no sense to me. is also thread safe, and I don't see why being thread safe would make something faster. The key seems to be that produces more garbage to collect.

 

@Rouben Rostamian  

Please execute my worksheet in Maple 11 and also include the result of showstat(`convert/list`) and report back. 

I doubt that there's been any relevant change to rtable_eval or the rtable evaluation rules between Maple 11 and Maple 2015. There has been a perhaps unintentional change in `convert/list`.  My CL procedures show that when the unevaluated variables are outside an rtable, they're like nitroglycerin---the slightest bump causes them to evaluate. When they're in an rtable, they're like nitroglycerin in dynamite---relatively stable.

The first two statements of procedure p need to be 

YP[1]:= Y[2];
YP[3]:= Y[4];

You have equal signs instead. This doesn't make it run any faster, but the results are total garbage without this change.

Regardless of the making the change, it gets stuck in an infinite loop at t = .27728275. The error message indicates that it thinks that this is a delay differential equation. I don't understand that. Anyway, you should be able to plot t = 0..0.27 with no problem. To get the error message, hit the stop button during the odeplot computations.

@nadjet 

You're only seeing Ex[1] because it's the only value set only one level deep in a for loop. By default, Maple doesn't show the results of statements nested two or more levels deep. If you want to see the contents of Ex and Hy, then after the loops do:

interface(rtablesize= 21):
Ex;
Hy;

@Mac Dude 

It's not the GUI. Any further manipulation of the result from convert at the command line (as opposed to in a procedure) in any GUI will result in the full evaluation of the variables. 

What does t = (t^1, t^2) mean? What does 1_\alpha mean?

@adel-00 

I said to add maxfux= 0 as an option to the dsolve command, not to the odeplot command!!

Could you be more specific? Is there a particular recurrence that you want solved and plotted? Could you indicate a specific part of your paper?

@Markiyan Hirnyk I can't duplicate this effect of typesetting= extended. Are you sure that you did a restart? If the variables already have assigned values at the time that they are put into the Vector, then there's no question that the convert will return fully evaluated.

restart:
interface(typesetting= extended):
A:= <a>:  a:= 1:  convert(A,list);

     [a]

It makes no difference whether I set the tyesetting option from the Tools menu.

@Kitonum The returned by your procedure is a global name (as it should be). It is traditional in Maple code that if a procedure needs to return a global name that isn't specified in the procedure's arguments---in other words, the procedure needs to "make up" the global name---that that made-up name begin with an underscore, such as _m. In order for this tradition to be useful, it is also traditional to never assign values to global names that begin with underscores.

@Markiyan Hirnyk The phenomenon that you show (an extra evaluation caused by the use of nested= true) is an unintended and undocumented side effect of that option. You can see this by executing the code inside a procedure, where the option will not have that effect.

restart:
proc()
local A,a;
     A:= <a>;
     a:= 1;
     convert(A,list), convert(A, list, nested= true)
end proc();

     [a], [a]

The only intended purpose of the nested option is to determine how multi-dimensional rtables (and older-style arrays) are handled.

@Kitonum If you re-execute your code after a restart, you'll see that your assignment to B makes no difference---you'll still get [a,b,c].

First 469 470 471 472 473 474 475 Last Page 471 of 709