John May

Dr. John May

3026 Reputation

18 Badges

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

Social Networks and Content at Maplesoft.com

Maple Application Center
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

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

In the 2005 Top 3: Jordan was male 72% of the time (it is a near miss on my list). Alexis was female 80% of the time, and Angel was male 82% of the time.

John

This chart uses a looser definition of "unisex" than I use.

John

You don't really need the environment variables for the solve call.   I prefer to avoid using them when possible.

Two options:

# Explicit as a option to solve:

solve({e1,e2,e3},{x,y,a}, Explicit);

# Map allvalues over the solution:

map(allvalues, [solve({e1,e2,e3})]);

The _EnvAllSolutions only really affects equations with an infinite number of solutions, so it doesn't have any effect on this system.

John

You don't really need the environment variables for the solve call.   I prefer to avoid using them when possible.

Two options:

# Explicit as a option to solve:

solve({e1,e2,e3},{x,y,a}, Explicit);

# Map allvalues over the solution:

map(allvalues, [solve({e1,e2,e3})]);

The _EnvAllSolutions only really affects equations with an infinite number of solutions, so it doesn't have any effect on this system.

John

I guess this is more what was intended:

 for i from 1 to 5 do cat(`f_`,i) := unapply(i,x); end do;

John

I guess this is more what was intended:

 for i from 1 to 5 do cat(`f_`,i) := unapply(i,x); end do;

John

The problem with not specifying variables, rather than specifying them all as a list (with variables first) is that you will get parameters solved in terms of variables. 

solve({eq});
{Pi00 = p2 + p6, Pi01 = 1 - p2 - sigma01 - sigma00 - p6, Pi10 = p6,
    Pi11 = 1 - p6 - sigma11 - sigma10,
    p0 = 1 - p1 - p2 - sigma01 - sigma00 - p6, p1 = p1, p10 = -p11 + sigma10,
    p11 = p11, p2 = p2, p3 = 0, p4 = sigma01 - sigma11 - sigma10 + sigma00,
    p5 = 0, p6 = p6, p7 = 0, p8 = sigma01, p9 = -sigma01 + sigma11,
    sigma00 = sigma00, sigma01 = sigma01, sigma10 = sigma10, sigma11 = sigma11
    }

While with a list, some of the solvers try to respect the variable order. In this case that works (as below) even if it does not work in every case.

John

The problem with not specifying variables, rather than specifying them all as a list (with variables first) is that you will get parameters solved in terms of variables. 

solve({eq});
{Pi00 = p2 + p6, Pi01 = 1 - p2 - sigma01 - sigma00 - p6, Pi10 = p6,
    Pi11 = 1 - p6 - sigma11 - sigma10,
    p0 = 1 - p1 - p2 - sigma01 - sigma00 - p6, p1 = p1, p10 = -p11 + sigma10,
    p11 = p11, p2 = p2, p3 = 0, p4 = sigma01 - sigma11 - sigma10 + sigma00,
    p5 = 0, p6 = p6, p7 = 0, p8 = sigma01, p9 = -sigma01 + sigma11,
    sigma00 = sigma00, sigma01 = sigma01, sigma10 = sigma10, sigma11 = sigma11
    }

While with a list, some of the solvers try to respect the variable order. In this case that works (as below) even if it does not work in every case.

John

Take a look at:
http://maplesoft.com/products/Maple/system_requirements.aspx

Under Macintosh®, it says "10.4.5 or later" so 10.5.5 is supported.

John

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