PatrickT

Dr. Patrick T

2088 Reputation

18 Badges

14 years, 91 days

MaplePrimes Activity


These are replies submitted by PatrickT

@JacquesC 

Interesting piece of information ... buried deep in the depths of mapleprimes. These links deserve to appear in a post of their own. Any update since 2007? Also the OP is definitely a FAQ. So let me "bump" it with this comment.

 

 

@JacquesC 

Interesting piece of information ... buried deep in the depths of mapleprimes. These links deserve to appear in a post of their own. Any update since 2007? Also the OP is definitely a FAQ. So let me "bump" it with this comment.

 

 

mattm, one thing you should realize is that 0.5 is a float. When Maple encounters floats in an expression it does not care to keep them "as is" or to display in an elegant or natural way. If instead you use an integer or a rational, then Maple takes more care. Contrast:

0.5*Pi*2; # "inelegant seemingly redundant" 1.0 multiplier
1.0 Pi


1/2*Pi*2; # more elegant output
Pi

Maple still simplifies where it can, but it does a "prettier" job. If you want to keep 1/2 as a "block" then you can follow acer's or Alejandro's suggestions.

 

 

follow up, compare: 

value(s1);
    sqrt(2)*sqrt(Pi/z) 


expand(s) assuming positive;  # ruling out complex values
    sqrt(2)*sqrt(Pi)/sqrt(z)

However, the way you would type this expression in text is presumably more like:

     sqrt(2*Pi/z)

any simple way to get that? Thanks.

 

 

follow up, compare: 

value(s1);
    sqrt(2)*sqrt(Pi/z) 


expand(s) assuming positive;  # ruling out complex values
    sqrt(2)*sqrt(Pi)/sqrt(z)

However, the way you would type this expression in text is presumably more like:

     sqrt(2*Pi/z)

any simple way to get that? Thanks.

 

 

This should become part of my bag of tricks. It should be part of a FAQ too.

@Alejandro Jakubi 

 

 

This should become part of my bag of tricks. It should be part of a FAQ too.

@Alejandro Jakubi 

 

 

Gracias Alejandro, 

 

@Alejandro Jakubi 

 

 

Doug, Alejandro, acer, thanks a lot for sharing your thoughts.

@Doug,

I have used select in the past, and searching through my archives I see that I had used it for that same purpose as you describe, but it had sunk into the chasm of my memory. Thanks a lot for pointing it out. A few years back, that is exactly the approach I would have found intuitive. It reads like English grammar, doesn't it: 

select(is, L, negative)

Perfectly intuitive. This syntax is certainly to be recommended to people like me who forget syntax from one session to the next. 

How efficient is it? I'm not sure what to make of the results posted by acer above. While "memory used" is at the high end (relative to other approaches), "cpu time" and "real time" are at the low end. I have noticed that, in the past, when someone points out that "oh great cpu time is low", someone else points out that "well but memory used is high". I was under the impression that "memory used" was the indicator to look at. 

 


Comment in passing: nops is one of those commands that feels very mysterious the first time you encounter it, then becomes indispensable. I have just discovered that nops(L) is not a costless operation. I hadn't put a thought to that before, but it's a potentially important point. This suggests that if nops(L) is needed repeatedly, it is more efficient to assign it, e.g. n:=nops(L); rather than having seq (and similar constructs) compute it repeatedly. By contrast, the size of a Vector is stored within the construct and accessed cheaply. This is really trivial stuff. I'm hoping that by writing it down I will remember it.


CodeTools:-Usage(
nops(L)
):

CodeTools:-Usage(
ArrayTools:-Size(V)
):

memory used=408 bytes, alloc change=0 bytes, cpu time=109.00ms, real time=110.00ms
memory used=5.16KiB, alloc change=0 bytes, cpu time=0ns, real time=0ns

 

 

 

@Alejandro

interesting examples, I can reverse-engineer the first two, but I'm not sure what to make of the third one (about the ode)...

@acer

It's great to have all of these methods side by side in one place for future reference. Thanks for posting the worksheet. I keep copies of these and, quite often, search through them for inspiration or salvation.

Thanks acer, this is a great insight to have from someone who knows Maple pretty much inside out!

I guess I was just using the wrong package!

I have made this exchange one of my favourites. (it's still not possible to do that with "comments," nor is it possible to vote)

@Thomas Richard 

Thanks, I hadn't seen that. I had searched for `if` but I seem to have missed it somehow, strange.


http://www.maplesoft.com/support/help/search.aspx?term=%60if%60&pr=All&sa.x=0&sa.y=0

 

 

@hossayni 

It sounds like one package may have been redefining commands used by another package, with incompatibilities in the syntax. This is known to happen once in a while.

I have developed the habit of NOT using:

with(SomePackage);
SomeCommand(x);


and instead use either:

SomePackage:-SomeCommand(x);

or, if the former complains and throws an error, instead:

SomePackage[SomeCommand](x);


This way you keep track of which package you have loaded and what each package does.

Also, you can load only specific commands from a given package:

with(SomePackage,x);

The list of commands available for the package is generated by: with(SomePackage) ;

Edit: removed stuff that could have been misinterpreted.

@hossayni 

It sounds like one package may have been redefining commands used by another package, with incompatibilities in the syntax. This is known to happen once in a while.

I have developed the habit of NOT using:

with(SomePackage);
SomeCommand(x);


and instead use either:

SomePackage:-SomeCommand(x);

or, if the former complains and throws an error, instead:

SomePackage[SomeCommand](x);


This way you keep track of which package you have loaded and what each package does.

Also, you can load only specific commands from a given package:

with(SomePackage,x);

The list of commands available for the package is generated by: with(SomePackage) ;

Edit: removed stuff that could have been misinterpreted.

@Alejandro Jakubi 

@Alejandro Jakubi

Thanks Alejandro for these points, the Mathematica document is interesting: it's obviously biased against Maple in that it selects examples where Mathematica does much better, but all the same it's a convincing suggestion that more could be done to improve Maple's plotting capabilities. The 3d example you give is particularly alarming when considering that the 'discont' option does not work with 3d plots...

"The discont option is not available in the 3-D case. In this situation, it is recommended that you divide the plotting ranges into subranges to avoid the discontinuities, generate the individual plots and then combine them using the plots[display] command.  "

@Alejandro Jakubi 

@Alejandro Jakubi

Thanks Alejandro for these points, the Mathematica document is interesting: it's obviously biased against Maple in that it selects examples where Mathematica does much better, but all the same it's a convincing suggestion that more could be done to improve Maple's plotting capabilities. The 3d example you give is particularly alarming when considering that the 'discont' option does not work with 3d plots...

"The discont option is not available in the 3-D case. In this situation, it is recommended that you divide the plotting ranges into subranges to avoid the discontinuities, generate the individual plots and then combine them using the plots[display] command.  "

First 9 10 11 12 13 14 15 Last Page 11 of 93