John May

Dr. John May

2616 Reputation

18 Badges

17 years, 14 days
Maplesoft
Pasadena, California, United States

Social Networks and Content at Maplesoft.com

I have been a part of the Mathematical Software Group at Maplesoft since 2007. I have a Ph.D in Mathematics from North Carolina State University as well as Masters and Bachelors degrees from the University of Oregon. I have been working on research in computational mathematics since 1997. I currently work on symbolic solvers and visualization as well as other subsystems of Maple.

MaplePrimes Activity


These are replies submitted by John May

Since I use many different versions of Maple all day, I extended the idea of a comment prompt so that I have version information at a glance.  I have the following proc in my .mapleinit

setprompt := proc()
    local versionstring;

    if not IsWorksheetInterface()=true then

        versionstring := StringTools:-Split(ssystem("echo $MAPLE")[2][1..-2], "/")[-1];
        if length(versionstring) > 5 and versionstring[2..5] = "aple" then
            versionstring := versionstring[6..-1];
        end if;

        if not kernelopts(opaquemodules) then
            versionstring := cat(versionstring, "O");
        end if;

        interface(prompt=cat("(*",versionstring,"*)")):
    end if:

end proc;

So that my prompt in Maple 13 looks like (*13*), or (*13O*) if I have modules set to opaque.  It does rely on your different versions of maple being installed in directories named ../mapleXX, so it is probably unix specific.

If one were committed to not using the directory name, you could translate the output of version() into a release number using a lookup table.

John

solve does not use any assumptions on the variables for which you are solving so the first three work just as well without the assuming.  This is because solve restricts itself to real values of the variables when it is solving inequalities (< or <= but not <>).

John

solve does not use any assumptions on the variables for which you are solving so the first three work just as well without the assuming.  This is because solve restricts itself to real values of the variables when it is solving inequalities (< or <= but not <>).

John

The Maple specific %a can also be used here:

printf("No Roots Between The Interval %a\n", [a,b]);

John

This is a slightly wierd thing to being trying to solve: the second two equations are already solved:

{c = RootOf(_Z^2+_Z+1), b = RootOf(_Z^3-RootOf(_Z^2+_Z+1))}

So the first equation is just confusing solve.
 

For what it is worth, in general, when solve has a RootOf expression which contains a variable it needs to solve for, it adds an extra variable and equation:

b = RootOf(_Z^3+c^2+1)  becomes  {b = _Temp1,  _Temp1^3+c^2+1 = 0}

so you are better off just giving the equation as b^3+c^2+1=0 to to begin with, when possible.

 

John

solve is returning NULL, indicating that it found no solutions.  Which makes sense.  Written as a fraction, your input is  560 / ( 243*(x+1)^(13/3) ).  Since the numerator is constant, the expression can never be 0.

John

computing the exact value of the approximated integrand:

convert(x*sin(Pi*x)*sin(3.141592653*x),rational,exact);
int(% ,x=0..1);
evalf(evalf[Digits+3](%));

To do the whole thing with numerical methods:

> int(x*sin(Pi*x)*sin(3.141592653*x),x=0.0..1.0); # float range
                                 0.2500000000

> evalf(Int(x*sin(Pi*x)*sin(3.141592653*x),x=0..1)); # capital I
                                 0.2500000000

Pretty picture:

Ie:=int(x*sin(Pi*x)*sin((Pi-e)*x),x=0..1);
plot(Ie, e=0..10^(-6));

 

You need to apply coeff once for each "variable" (with frontend where necessary):

coeff( frontend(coeff, [t, sin(y),2]) ,x,1);

John

You need to apply coeff once for each "variable" (with frontend where necessary):

coeff( frontend(coeff, [t, sin(y),2]) ,x,1);

John

While working on my Ph.D and in research work afterwards I wrote and collaborated in writing a lot of prototype code in Maple for various numerical polynomial algorithms.  Keeping that code in plain text ".mpl" files made it easier to keep track of changes in a revision control system (or with "diff").

We also ran a lot of benchmarks on against various prototype and existing code.  For reliability of timings it is best to run each benchmark in a new maple session so we would put one benchmark example to a file and run them through the command line maple one at a time via a loop in a shell script

Most prototyping and benchmarking would start in the worksheet, but eventually it would move into text files when things got big, or it was time to start running lots of trials.

John

While working on my Ph.D and in research work afterwards I wrote and collaborated in writing a lot of prototype code in Maple for various numerical polynomial algorithms.  Keeping that code in plain text ".mpl" files made it easier to keep track of changes in a revision control system (or with "diff").

We also ran a lot of benchmarks on against various prototype and existing code.  For reliability of timings it is best to run each benchmark in a new maple session so we would put one benchmark example to a file and run them through the command line maple one at a time via a loop in a shell script

Most prototyping and benchmarking would start in the worksheet, but eventually it would move into text files when things got big, or it was time to start running lots of trials.

John

There was for a while a links browser  created to support tables and frames (which were not supported by lynx at the time).  Since, lynx has caught up and I don't know if links is still actively developed.

John

For a one-off, it is definitely simplier to cut and paste the table to make it plain text.  That is in fact the very first thing I did with this page. 

However, my goals with this post and the follow up, were to 1. do those whole thing automatically for as many years worth of data as I wanted, and 2. do it all in Maple.

John

This turns out to not be too bad. It is just a matter of isolating the desired table and then stripping out the non-table elements from that.


s := FileTools:-Text:-ReadFile("online.html");
# Split over the tables
ssplits := [StringTools:-RegSplit("<table[^>]*>|</table>", s)];

# Find the largest table and use it
l:=max(map(length,ssplits));
member(l, map(length,ssplits), 'loc');
s := cat("<table>",ssplits[loc],"</table>");

with(XMLTools):
xt := ParseString(s);
thedata := map(GetChildByName, GetChildByName(xt, "tr"), "td");
thedata := remove(x->x=[], thedata);

# The try/catch here is because I am too lazy to parse
# the non table HTML elements more carefully
# It is not very safe but gets the job done here

thedata := map(x->map(proc(y)
  try
    StringTools:-Trim(TextText(GetChild(y,1)))
  catch:
    "0"
   end try end proc
, x), thedata);

# maybe you want this?
header := thedata[1];

# remove the , from numbers and then parse:
numbdata := map(x->map(
    y->parse(StringTools:-Substitute(y,",","")), x), thedata[2..-3]);

 

John

If I save the page to "foo.html", I am not able to import it directly with XMLTools.

> XMLTools:-ParseFile("foo.html");
Error, (in XMLTools:-ParseFile) White spaces are required between 
publicId and systemId.

It might be easy to massage it, however.  I will look at it after I finish Part 2 of this post.

John

First 8 9 10 11 12 13 14 Last Page 10 of 19