acer

32358 Reputation

29 Badges

19 years, 331 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

You don't need to issue with(Units) for this particular computation.

You might want to try these alternatives for some of the later commands in your worksheet (where it appeared to have problems),

plot(convert(combine(subs(const, L[vpeak](T)), 'units'), 'unit_free'), T = 2000 .. 5500);
plot(convert(simplify(subs(const, L[vpeak](T))), 'unit_free'), T = 2000 .. 5500);

evalf(combine(subs(const, L[vpeak](2000.0)), 'units'));
evalf(simplify(subs(const, L[vpeak](2000.0))));

map(t -> map(convert, combine(t, 'units'), 'unit_free'), const);
map(t -> map(convert, simplify(t), 'unit_free'), const);

When you attempted a units replacement at the end, using the context-menus, did you intend to replace kg/(s^2*K^3) by kg*Hz^2/K^3 ?

acer

You don't need to issue with(Units) for this particular computation.

You might want to try these alternatives for some of the later commands in your worksheet (where it appeared to have problems),

plot(convert(combine(subs(const, L[vpeak](T)), 'units'), 'unit_free'), T = 2000 .. 5500);
plot(convert(simplify(subs(const, L[vpeak](T))), 'unit_free'), T = 2000 .. 5500);

evalf(combine(subs(const, L[vpeak](2000.0)), 'units'));
evalf(simplify(subs(const, L[vpeak](2000.0))));

map(t -> map(convert, combine(t, 'units'), 'unit_free'), const);
map(t -> map(convert, simplify(t), 'unit_free'), const);

When you attempted a units replacement at the end, using the context-menus, did you intend to replace kg/(s^2*K^3) by kg*Hz^2/K^3 ?

acer

The reason that it looks shorter in python is because someone's already written its functions urlencode, urlopen, etc.

So one might reasonably ask how hard it would be to write the equivalent functions in maple, so as not to have to type all that out like John did. That's how to use Maple effectively -- to write re-usable procedures for repeating queries. Also possible is to distribute them (as the python community does) for others to use.

For example, are the undocumented HTTP:-Post and HTTP:-URLEncode close, or do they require changes in order to do this task?

acer

Is vim's maple mode primarily for editing (eg, syntax highlighting, autoindent, etc)? Does it also provide macros for pumping the buffer into a new commandline Maple session?

Perhaps people could post some of their favourite .vimrc gems that relate to Maple.

acer

Is vim's maple mode primarily for editing (eg, syntax highlighting, autoindent, etc)? Does it also provide macros for pumping the buffer into a new commandline Maple session?

Perhaps people could post some of their favourite .vimrc gems that relate to Maple.

acer

Live and learn. Thanks. Sorry to have doubted you, Alec.

acer

> StringTools:-Soundex("links");
                                    "L520"
 
> StringTools:-Soundex("lynx");
                                    "L520"

Alec may have been thinking of the lynx browser.

acer

For me, the most interesting bit of the above post is the methodology of programmatically importing data from tables in HTML files into a Maple session.

The use of StringTools:-Metaphone looks fun, in an over-the-top way.

I look forward to seeing the way the Sockets package was used to grab the HTML directly from the remote server. See also here.

For those who would wish to fully automate these tasks (to grab, manupulate, and analyze web-published data that changes often), such methods could be very useful.

acer

Ok, thanks. There is something going on with print of a proc from within a procedure, but I'm not sure exactly what.

I got the following to work, in the Standard GUI in Linux,

mint := proc(f,extras::string:="")
local fname,k,oldiface;
   fname := "/tmp/foo";
   oldiface := interface('verboseproc');
   interface('verboseproc'=3);
   writeto(fname);
   printf("%a := ", f);
   printf("%a",eval(f));
   printf(":\n");
   writeto(terminal):
   fclose(fname);
   interface('verboseproc'=oldiface);
   k:=ssystem(cat("/usr/local/maple/maple12.01/bin/mint ",extras," ",fname));
   if k[1]>=0 then printf("%s",k[2]); end if;
   NULL; 
end proc:

mint(`convert/CompSeq`);

It could be made nicer, by using StringTools to Drop the mint preamble text in the 2nd operand of the result from ssystem.

acer

Thanks Alejandro,

Does it work in the Standard GUI for you, if you set interface('verboseproc'=3) outside of the procedure?

Is it a surprise to anyone else, if verboseproc could not be set inside a proc in a Standard worksheet?

acer

It's a consequence of the module's having `option package`.

Without `option package`, one can assign to the export without having first unprotected it. In that case, issuing `with` on the module causes a Warning (but succeeds).

> restart:
> myD:=module() option package; export D; end module:
> with(myD);
                                      [D]
> D:=4: 17*D;
Error, attempting to assign to `D` which is protected
                                     17 D
 
> restart:
> myD:=module() export D; end module:
> with(myD);
Warning, myD is not a correctly formed package - option `package' is missing
                                      [D]

> D:=4: 17*D;
                                      68
It wasn't actually due to the fact that global :-D is protected.
> restart:
> myG:=module() option package; export G; end module:
> with(myG):
> G:=4;
Error, attempting to assign to `G` which is protected

> restart:
> myG:=module() export G; end module:
> with(myG):
Warning, myG is not a correctly formed package - option `package' is missing
> G:=4;
                                    G := 4

I guess that the idea is that one would want package exports (but not all other modules' exports) to be protected. Discounting the Warning message, there is some flexibility.

An alternative is to use bind directly,

> restart:
> myD:=module() export D; end module:

> bind(myD:-D);
                                       D
 
> D:=4: 17*D;
                                      68
 
> :-D(sin);
                                      cos
> convert(diff(f(x),x),:-D);
                                    D(f)(x)
 
> eval(%,f=tan);
                                            2
                                  1 + tan(x)

acer

It's a consequence of the module's having `option package`.

Without `option package`, one can assign to the export without having first unprotected it. In that case, issuing `with` on the module causes a Warning (but succeeds).

> restart:
> myD:=module() option package; export D; end module:
> with(myD);
                                      [D]
> D:=4: 17*D;
Error, attempting to assign to `D` which is protected
                                     17 D
 
> restart:
> myD:=module() export D; end module:
> with(myD);
Warning, myD is not a correctly formed package - option `package' is missing
                                      [D]

> D:=4: 17*D;
                                      68
It wasn't actually due to the fact that global :-D is protected.
> restart:
> myG:=module() option package; export G; end module:
> with(myG):
> G:=4;
Error, attempting to assign to `G` which is protected

> restart:
> myG:=module() export G; end module:
> with(myG):
Warning, myG is not a correctly formed package - option `package' is missing
> G:=4;
                                    G := 4

I guess that the idea is that one would want package exports (but not all other modules' exports) to be protected. Discounting the Warning message, there is some flexibility.

An alternative is to use bind directly,

> restart:
> myD:=module() export D; end module:

> bind(myD:-D);
                                       D
 
> D:=4: 17*D;
                                      68
 
> :-D(sin);
                                      cos
> convert(diff(f(x),x),:-D);
                                    D(f)(x)
 
> eval(%,f=tan);
                                            2
                                  1 + tan(x)

acer

> convert(simplify(diff(sqrt(u(x)^2),x)),abs) assuming u(x)::real;
                                     /d      \
                                u(x) |-- u(x)|
                                     \dx     /
                                --------------
                                   | u(x) |
 
> PDEtools:-declare(u(x));
                        u(x) will now be displayed as u
 
> convert(simplify(diff(sqrt(u(x)^2),x)),abs) assuming u(x)::real;
                                    u u[x]
                                    ------
                                    | u |

acer

I agree with you that the task of wholly scripted generation of plots (in any interface of Maple) is important. As far as I know, that is not possible (in any interface) if the plot must have typeset 2D Math and be exported as bmp/gif/jpeg. For some people, the bit about it being wholly scripted is important.

The statement that commandline interface is not "intended" for plotting reads as doublethink for me.

But it could be true that there is no secret, hidden command to get the desired effects. In the commandline interface, plot will eventually call INTERFACE_PLOT. I suspect that is a call to something which is not a Library function, nor a kernel built-in, but rather a function of the interface itself. In Standard, there likely is java code which does the rest of the work, and in commandline it is something inside the cmaple binary.

Trying to fool the commandline interface, by some crude assignments like the following, didn't bypass anything.

IsWorksheetInterface():=true:
Plot:-CheckStandardInterface(('feature') = "caption"):=true:

Now consider, if the commandline interface can fire up the java runtime in order to throw up graphical plots when the plotdevice is set to 'maplets' (and indeed it can and does!) then it could in principle start it up to access Standard's plot export functions too. It should be fixable.

acer

I agree with you that the task of wholly scripted generation of plots (in any interface of Maple) is important. As far as I know, that is not possible (in any interface) if the plot must have typeset 2D Math and be exported as bmp/gif/jpeg. For some people, the bit about it being wholly scripted is important.

The statement that commandline interface is not "intended" for plotting reads as doublethink for me.

But it could be true that there is no secret, hidden command to get the desired effects. In the commandline interface, plot will eventually call INTERFACE_PLOT. I suspect that is a call to something which is not a Library function, nor a kernel built-in, but rather a function of the interface itself. In Standard, there likely is java code which does the rest of the work, and in commandline it is something inside the cmaple binary.

Trying to fool the commandline interface, by some crude assignments like the following, didn't bypass anything.

IsWorksheetInterface():=true:
Plot:-CheckStandardInterface(('feature') = "caption"):=true:

Now consider, if the commandline interface can fire up the java runtime in order to throw up graphical plots when the plotdevice is set to 'maplets' (and indeed it can and does!) then it could in principle start it up to access Standard's plot export functions too. It should be fixable.

acer

First 508 509 510 511 512 513 514 Last Page 510 of 592