acer

32400 Reputation

29 Badges

19 years, 344 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

I had noticed that Christopher2222's integral wasn't quite the same as the SIAM Challenge problem, but I didn't mention it above. In Maple 14 one can get some more digits by specifying the method, etc, as above. But 100 digits accuracy, over the whole range from 0 to 1, should prompt one to hunt for another scheme altogether, I think. (Robert's solutions implemented in Maple to that SIAM 100 Digits Challenge, which he has linked to above, are a thrilling read.)

> evalf(Int(cos(log(x)/x)/x, x = .0001 .. 1, epsilon=1e-8)); # takes 20-30 secs to fail...

                       /1.      /ln(x)\   
                      |      cos|-----|   
                      |         \  x  /   
                      |      ---------- dx
                     /            x       
                      0.0001              

> evalf(Int(cos(log(x)/x)/x, x = .00001 .. 1,
>           maxintervals=50000, epsilon=1e-8, method=_d01akc));

                          0.3233669608

acer

I had noticed that Christopher2222's integral wasn't quite the same as the SIAM Challenge problem, but I didn't mention it above. In Maple 14 one can get some more digits by specifying the method, etc, as above. But 100 digits accuracy, over the whole range from 0 to 1, should prompt one to hunt for another scheme altogether, I think. (Robert's solutions implemented in Maple to that SIAM 100 Digits Challenge, which he has linked to above, are a thrilling read.)

> evalf(Int(cos(log(x)/x)/x, x = .0001 .. 1, epsilon=1e-8)); # takes 20-30 secs to fail...

                       /1.      /ln(x)\   
                      |      cos|-----|   
                      |         \  x  /   
                      |      ---------- dx
                     /            x       
                      0.0001              

> evalf(Int(cos(log(x)/x)/x, x = .00001 .. 1,
>           maxintervals=50000, epsilon=1e-8, method=_d01akc));

                          0.3233669608

acer

In 1D Maple notation, the following takes a range from -1 to 1 (one).

plot(x, x=-1...1);

But if one takes that code and simply pastes it in as 2D input in either a Worksheet or a Document then the range will be taken from -1 to 0.1 (1/10). It's totally different. Some implicitplot's will come out empty if mistakenly pasted like this.

There are decades' worth of 1D code around, including as content on web pages. Some one (or people) may have thought that they were doing everyone a minor favour, by implementing the 2D Math parser to suit their own new ideas of what's best. But the actual result is that there are these major rifts between old legacy code and the newest versions' default mode's parser.

All such "differences of minor convenience" should be fixed, changing 2D mode to be compatible with 1D mode as far as is possible.

acer

@icedragon You must be using 2D Math input.

Notice that your original had ranges like -10...10 with three dots. Your professors' may not have, but your own originally version posted above did have it so. The 1D parser interprets those as ranges from -10 to 10. The 2D parser, in its infinite wisdom, interprets it as the range from -10 to .1 or something.

If you take the above code and intend on pasting it as 2D input then you'll have to get rid of the third dots in the ranges -10..10 and -20..20 etc. Or insert a space after each third dot, before the upper value that comes next. Then it should work if pasted in either mode.

The Maple input "modes" named 1D Maple Notation and 2D Math are in fact different programming languages. Yes, this is sad.

I'll add this example to this page I wrote, on the parsers' differences.

@icedragon You must be using 2D Math input.

Notice that your original had ranges like -10...10 with three dots. Your professors' may not have, but your own originally version posted above did have it so. The 1D parser interprets those as ranges from -10 to 10. The 2D parser, in its infinite wisdom, interprets it as the range from -10 to .1 or something.

If you take the above code and intend on pasting it as 2D input then you'll have to get rid of the third dots in the ranges -10..10 and -20..20 etc. Or insert a space after each third dot, before the upper value that comes next. Then it should work if pasted in either mode.

The Maple input "modes" named 1D Maple Notation and 2D Math are in fact different programming languages. Yes, this is sad.

I'll add this example to this page I wrote, on the parsers' differences.

You'll need to attend to the issues raised in both (or the first two, by date) Answers below.

acer

I suggest the copy command instead of LinearAlgebra:-Copy, for three reasons (not applicable here, but worth knowing):

The copy command is global, and not part of any package. So it works without requiring that LinearAlgebra be loaded (or that the long-form name LinearAlgebra:-Copy be used).

The copy command works on all of Arrays and Matrices and Vectors, while LinearAlgebra:-Copy only works on Matrices and Vectors.

The copy command does not pass along the readonly attribute that a Vector/Matrix might have. I think that's sensible; the target object might be read-only but in that case there is little purpose to having any new duplicate also be immutable. Who needs two immutable instances of the same data?!

showstat(LinearAlgebra:-Copy,6);

showstat(copy,1..2);

The copy command does pass along other attributes (the rtable constructor handles that part automatically, and the ('attributes') = [attributes(_MV)] part of Copy's source is not needed, I suspect. I don't see much point to LinearAlgebra:-Copy's existing.

acer

I suggest the copy command instead of LinearAlgebra:-Copy, for three reasons (not applicable here, but worth knowing):

The copy command is global, and not part of any package. So it works without requiring that LinearAlgebra be loaded (or that the long-form name LinearAlgebra:-Copy be used).

The copy command works on all of Arrays and Matrices and Vectors, while LinearAlgebra:-Copy only works on Matrices and Vectors.

The copy command does not pass along the readonly attribute that a Vector/Matrix might have. I think that's sensible; the target object might be read-only but in that case there is little purpose to having any new duplicate also be immutable. Who needs two immutable instances of the same data?!

showstat(LinearAlgebra:-Copy,6);

showstat(copy,1..2);

The copy command does pass along other attributes (the rtable constructor handles that part automatically, and the ('attributes') = [attributes(_MV)] part of Copy's source is not needed, I suspect. I don't see much point to LinearAlgebra:-Copy's existing.

acer

Most of the "new in Mma 8" features looked to me to fall into just a few categories. In particular,

Control & Dynamical Systems
(Group &) Graph Theory
Images and wavelet analysis
(Univariate & Multivariate) Statistics

One set in particular, Control, is something Maple has had for a while with the functionality being spread between the DynamicSystems, Linearization, LinearAlgebra's CARE/DARE, and the Control toolbox for MapleSim (which contains higher level routines such as for Linear Quadratic Regulators, etc). The functionality of that toolbox can pretty much be built from the components already in Maple proper, eg. see one of the worksheets on the MapleCloud which introduced the Riccati equation solvers in LinearAlgebra.

As for the others, well, Maple has packages for those disciplines. So a more interesting question might be more along the lines of: what particular functionality of "new in Mma 8" would be useful to have. Without being very specific, it's not so interesting. In other words: what specific new-in-Mma-8 commands would be really useful (and not just cool) in Maple?

I 've always noticed that Wolfram Research has the habit of add lots of routines. They tend to split functionlity into separate routines which might otherwise be combined or omitted in the beginning. (Example, who really needs a dedicated command for generating Pascal matrices, when it can be done 5 ways in 1 line?)

There was some very neat efficiency changes in Mma 8, particulary related to the speed of LinearAlgebra on large exact integer Matrices. See here. It's a great shame if they have not provided both Maple and Mma source code used in the benchmarking, especially given the important distinction between Maple's time and time[real] utilities (I didn't see sources, can anyone else?)

acer

The `else` clause in the system Library routine `-`, for the case of strictly more than 2 arguments, is not at all  funny because it didn't have to be coded recursively. (Is `-` thus quadratic in time as well as memory allocation, as a function of nargs?)

Technically this crash doesn't fit the criteria originally listed in the parent post, as it merely runs out of memory. But the crash manifests as a popup error message that the kernel is gone, not as any nice regular error about failure to allocate enough memory -- so maybe it fits. Certainly it ought to be easy to fix.

The following crashes a 64bit Maple 14 (Windows 7) with 6GB of RAM.

`-`($1..1e5);

 

> restart:
> T:=$1..1e3:

> st,ba:=time(),kernelopts(bytesalloc):
> T[1]-`+`(T[2..-1]);
> time()-st,kernelopts(bytesalloc)-ba;
                            -500498
                             0., 0

> st,ba:=time(),kernelopts(bytesalloc):
> `-`(T);
> time()-st,kernelopts(bytesalloc)-ba;
                            -500498
                         0.016, 4062488

> T:=$1..1e4:
> st,ba:=time(),kernelopts(bytesalloc):
> T[1]-`+`(T[2..-1]);
> time()-st,kernelopts(bytesalloc)-ba;
                           -50004998
                           0., 131048

> st,ba:=time(),kernelopts(bytesalloc):
> `-`(T);
> time()-st,kernelopts(bytesalloc)-ba;
                           -50004998
                        1.498, 400941356

> showstat(`-`);

`-` := proc(x, y)
   1   if nargs = 1 then
   2     -x
       elif nargs = 2 then
   3     x-y
       else
   4     `-`(x-y,args[3 .. -1])
       end if
end proc

acer

@BSchor 

Here below is a Document containing a customized context-sensitive menu addition for splitting a complex number into the polar form you've described (ie, into that expression sequence of two values). You could take the red code portion and stick it in your Maple initialization file, or I suppose in a hidden code region or the Document's Startup Code area. At the end is a link to the displayed Document, as well as to a version containing the code in the Startup Code area.

The new context menu item appears under the usual "Complex Maps" submenu.

The clickable-math style of operating in Maple (context-menus, palettes, command-completion in 2D entry mode, etc) is convenient but cannot encapsulate all that Maple can do. That's because there will always be an infinite amount of mathmatical/scientific computational tasks which are not exactly captured by a prebuilt utility. But Maple is a full fledged programming environment, and so learning Maple as a programming language is useful and important, so that you can extend upon the "canned" clickable functionality. I suggest reading the Maple manuals, and in particular the Programming Manual(s). You can download those here.

 

XYZnewCM := ContextMenu:-CurrentContext:-Copy():

XYZnewCM:-Entries:-Add(

    "Polar Split",

    "(evalc@abs,evalc@argument)(%EXPR)",

    `algebraic`,

    'helpstring'="(evalc@abs,evalc@argument)",

    'operator'=Typesetting:-mover(Typesetting:-mo("→"),
                                  Typesetting:-mtext("polar split")),

    'category'="Category 1",

    'submenu'=["Complex Maps"],

    NULL):

ContextMenu:-Install(XYZnewCM);

 



Download polarsplit.mw

polarsplit_startu.mw

@BSchor 

Here below is a Document containing a customized context-sensitive menu addition for splitting a complex number into the polar form you've described (ie, into that expression sequence of two values). You could take the red code portion and stick it in your Maple initialization file, or I suppose in a hidden code region or the Document's Startup Code area. At the end is a link to the displayed Document, as well as to a version containing the code in the Startup Code area.

The new context menu item appears under the usual "Complex Maps" submenu.

The clickable-math style of operating in Maple (context-menus, palettes, command-completion in 2D entry mode, etc) is convenient but cannot encapsulate all that Maple can do. That's because there will always be an infinite amount of mathmatical/scientific computational tasks which are not exactly captured by a prebuilt utility. But Maple is a full fledged programming environment, and so learning Maple as a programming language is useful and important, so that you can extend upon the "canned" clickable functionality. I suggest reading the Maple manuals, and in particular the Programming Manual(s). You can download those here.

 

XYZnewCM := ContextMenu:-CurrentContext:-Copy():

XYZnewCM:-Entries:-Add(

    "Polar Split",

    "(evalc@abs,evalc@argument)(%EXPR)",

    `algebraic`,

    'helpstring'="(evalc@abs,evalc@argument)",

    'operator'=Typesetting:-mover(Typesetting:-mo("→"),
                                  Typesetting:-mtext("polar split")),

    'category'="Category 1",

    'submenu'=["Complex Maps"],

    NULL):

ContextMenu:-Install(XYZnewCM);

 



Download polarsplit.mw

polarsplit_startu.mw

@Alejandro Jakubi Alejandro this is something like the 3rd time in as many weeks that you have used applyrule to nice effect, deftly providing a more general solution.

This is great because applyrule deserves more notice, if not as a bug-free command then certainly as representative of a symbolic problem-solving methodology. (And heavier use can lead to more bug reports on it, which can ideally lead to it getting stronger. It has its share of weaknesses.)

Sometimes I think that Maple could learn more from Mathematica, in broad terms of how patterns are utilized. I'm not saying that Maple never uses patterns -- maybe see inttrans for example.

It's not really related to the posted topic but I'm reminded of something Alec once wrote here. I can't find the particular post, so I'll make up an example. The essence was that a human can immediately find a candidate explicit solution (namely, 1/4) of something like the following. But `solve` returns only an implicit RootOf:

> expr:=arcsin(exp(erfc(x))-x);
expr := -arcsin(-exp(erfc(x)) + x)

> eval(expr,x=1/4);
arcsin(exp(erfc(1/4)) - 1/4)

> solve(expr=eval(expr,x=1/4),x);
exp(RootOf(_Z - erfc(exp(_Z) - exp(erfc(1/4)) + 1/4))) - exp(erfc(1/4)) + 1/4

> evalf(%);
0.2500000000

With a little initiative one can see that the earlier suggestions can be made to do this example.

> restart: with(Student:-Precalculus):
> expr := x^4/sin(x)^4+2*x^2/sin(x)^2:

> a := algsubs(x^2 = y*sin(x)^2, expr):
> ans1 := CompleteSquare(a, y):
> eval(ans1, y = x^2/sin(x)^2);
                                    2    
                       /   2       \     
                       |  x        |     
                       |------- + 1|  - 1
                       |      2    |     
                       \sin(x)     /     

And,

> restart: with(Student:-Precalculus):
> expr := x^4/sin(x)^4+2*x^2/sin(x)^2:

> thaw(algsubs(x^2=freeze(x^2/sin(x)^2)*sin(x)^2, 'CompleteSquare'(expr, x^2/sin(x)^2) ));
                                    2    
                       /   2       \     
                       |  x        |     
                       |------- + 1|  - 1
                       |      2    |     
                       \sin(x)     /     

Sure, some harder example may also be taken, which in turn might be tractable (with a judicious `isolate` call, or whatever other augmenting trick). Every approach has its limitations, naturally. (Finding such is only sometimes interesting.)

acer

With a little initiative one can see that the earlier suggestions can be made to do this example.

> restart: with(Student:-Precalculus):
> expr := x^4/sin(x)^4+2*x^2/sin(x)^2:

> a := algsubs(x^2 = y*sin(x)^2, expr):
> ans1 := CompleteSquare(a, y):
> eval(ans1, y = x^2/sin(x)^2);
                                    2    
                       /   2       \     
                       |  x        |     
                       |------- + 1|  - 1
                       |      2    |     
                       \sin(x)     /     

And,

> restart: with(Student:-Precalculus):
> expr := x^4/sin(x)^4+2*x^2/sin(x)^2:

> thaw(algsubs(x^2=freeze(x^2/sin(x)^2)*sin(x)^2, 'CompleteSquare'(expr, x^2/sin(x)^2) ));
                                    2    
                       /   2       \     
                       |  x        |     
                       |------- + 1|  - 1
                       |      2    |     
                       \sin(x)     /     

Sure, some harder example may also be taken, which in turn might be tractable (with a judicious `isolate` call, or whatever other augmenting trick). Every approach has its limitations, naturally. (Finding such is only sometimes interesting.)

acer

First 446 447 448 449 450 451 452 Last Page 448 of 592