John May

Dr. John May

2616 Reputation

18 Badges

17 years, 5 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 Posts that have been published by John May

Here is a stupid trick. Did you know that you can use maple as a scripting language in Unix? Here's a little example.

On his blog, Jaime Zawinski (of Netscape and XEmacs fame) relates a tale of finding limits in the (supposedly) unlimited big number representation on a TI Lisp machine in the early 1990s. It is an amusing story, and it makes me wonder if GnuMP is has a similar limit on a different scale.  Or in other words, is there a positive integer small enough to fit into memory  (assuming 64 bit address space) but that cannot actually be constructed in GnuMP due to limits in the implementation? Does someone here know enough about the GnuMP internals to give the answer?

Of all the ways to decompose a numerical (floating point) matrix, my favorite is the singular value decomposition (SVD).  There are a lot of applications of the SVD (see my dissertation for one related to polynomial algebra) but my favorite ones are probably two applications related to image processing.

The first one I want to talk about comes from the cover of James Demmel's book "Applied Numerical Linear Algebra": image compression.  This example gives a really cool intuitive understanding of the Rank of Matrix and is also nice excuse to play with Maple's ImageTools package.

So, the first thing you need a test image. I used the classic image compression benchmark of a Mandrill.



Read this in with:


mandrill:=ImageTools:-Read("4.2.03.tiff");


The result is a 512x512x3 array.  In order to do something with this, we need to make it into a matrix so, call


manmat:=convert(ArrayTools:-Reshape(mandrill, 512*3, 512), Matrix);


Now we can compute a singular value decomposition of the image:


(U, S, V) := LinearAlgebra:-SingularValues(manmat, output = ['U', 'S', 'Vt']);

Now we can zero-out small singular values and multiply things back together to create low-rank approximations of the matrix that are also compressed versions of the image.
Rank 32 will give us 1/8 of the data (64 dimension 512 vectors: 32 rows of U, 32 columns of V, and the 32 corresponding singular values) but still a pretty good image:


rank32approx:=MatrixMatrixMultiply(`.`(U, DiagonalMatrix(S[1..32], 3*512, 512)), V, outputoptions = [order = C_order]);


This reshape it back to an image and display:


Preview((Reshape(rank32approx, 512, 512, 3)));


Taking things down to rank 8, is leaving only 1/32 of the data, but it is amazing how what is left resembles the original image:


rank8approx:=MatrixMatrixMultiply(`.`(U, DiagonalMatrix(S[1..8], 3*512, 512)), V, outputoptions = [order = C_order]);
Preview((Reshape(rank8approx, 512, 512, 3)));


To look at more images in order of descending rank, take a look at my worksheet:
Download 5480_SVD-face-colour-improved.mw
View file details

Next time: eigenfaces

I spotted this today whist wandering the blogosphere: Who Among You are Geek Enough to Decorate Your Easter Eggs in Mathematica? (via BoingBoing). Clearly there is a challenge here.

I am not a master of the plot command, but I would like to see what others can come up with. 

Here's a simple egg to start people off:

I use Maple primarily in a Unix text window (TTY or "command-line" Maple), so I am used to seeing common subexpression labeling in the output of my computations. However, in Maple 11, GUI users don't see subexpression labeling by default.  I'll begin by talking about subexpression labeling as it appears in TTY Maple, then I'll talk about it in the GUI.

For starters lets look at an example in which a single subexpression is labeled:

First 7 8 9 10 Page 9 of 10