Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@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].

@Joe Riel 

Thank you for the example. Yes, I already understood what "return an unevaluated call to a constructor" meant. What I am asking for is an example of a practical use of the parsing of that unevaluated call. (I guess that I emphasized the wrong sentence.)

@Prashanth Please post code as plaintext, not pictures.

I'm not sure, but I don't think that parametric and piecewise can be used together.

You do not have any Array. Your f is a table. An Array must be explicitly created or declared. Making assignments to subscripted entries of an undeclared variable creates a table. Whether it's a table or an Array, the number of elements can be found with numelems.

@Kitonum You raise an important point. For the case of polynomial systems (your first counterexample), the problem can still be handled by a single call to solve (but multiple calls to eval), if you use the parametric option, which returns a piecewise solution. Thus:

solve({b*x+y=1, x+b*y=1}, {x,y}, parametric= full);

     piecewise(b-1 = 0, [{x = -y+1, y = y}], b+1 = 0, [],
     And(b-1 <> 0, b+1 <> 0), [{x = 1/(b+1), y = 1/(b+1)}])

Thus, a solution of this form can be sequenced by 

{b=j, 'eval'(solve({b*x+y=1, x+b*y=1}, {x,y}, parametric= full), b= j)[][]} $ j= -2..2;

     {b = -2, x = -1, y = -1}, {b = -1},
     {b = 0, x = 1, y = 1}, {b = 1, x = -y+1, y = y}, {b = 2, x = 1/3, y = 1/3}

The absence of and y in the b=-1 term indicates that there's no solution for b=-1. And, of course, note the special form of the b=1 term. The unevaluation quotes around eval force it to be evaluated for every value of j.

@yader

There are much easier and better ways to make a procedure distribute over container classes (lists, sets, tables, rtables (Vectors, Matrices, Arrays)). The easiest way is to use the elementwise operator ~ (see ?elementwise). So, for example, if is a Vector, do

Cancel10s~(A);

If isn't a container, then the above command behaves just like Cancel10s(A).

The command map is more general in its definition of "container" (see ?map):

map(Candel10s, A);

There is an inplace option for map so that it operates on rtables (Vectors, Matrices, and Arrays) without making a copy:

map[inplace](Cancel10s, A);

The above command alters itself, so there's no need to assign the result to a variable.

Regarding copy-and-paste of plaintext code: The preservation of indentation seems browser dependent. My experience is that it is preserved in Firefox and lines are left-justified in Chrome. My most common use modality is to use Chrome and manually re-add the indentation (because, on my favorite computer, I can't post at all with Firefox). Regardless, it is nearly worthless to your readers to post Maple input as a picture unless you also attach a worksheet.

@Markiyan Hirnyk The resolution (or granularity) of the Maple clock is so large that CPU times less than about 0.05 sec can't accurately be measured directly. That resolution is system dependent, but on every system that I've ever used (mostly Windows), it's been exactly 1/64 = 0.015625 seconds. To measure small times more accurately, use the iterations option to CodeTools:-Usage. This will execute the code multiple times and report the average time.

You can verify what I say about the resolution by measuring a variety of small times with kernelopts(cputime). For example, you can execute the following:

st:= kernelopts(cputime):
for k do t:= kernelopts(cputime); if t > st then break end if end do:
t-st, k;

     0.015625, 9731

That means that for the first 9730 iterations of the loop, the measured time was exactly zero. You can repeat this code any number of times. The number of iterations will vary wildly, but the first number---the first nonzero time measured---will be constant.

@yader 

Yes, I said that it wouldn't work with nested floats. Here's an improvement using frontend (which prevents it from seeing anything inside a function call, such as sin) that will work:

Cancel10s:= proc(E::algebraic)
local T,P,N,D;
     T:= And(float,Not(identical(0.)));
     if not frontend(hastype, [E], [{`+`,`*`}, {}], T) then return E end if;
     P:= 10^ilog10~(frontend(indets, [E], [{`+`, `*`}, {}], T)[1]);
     N:= numer(E)/P;
     D:= denom(E)/P;
     N/D
end proc:

I can't explain the error that you got earlier except to say that the big "1/" in your prettyprinted output is suspicious.

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