Applications, Examples and Libraries

Share your work here

Continuing on in this series of posts, here is a way to test the randomness of a sequence of bits from a PRNG that is the appropriate to the first morning back after the August long weekend.  It is a very fast, and not very formal test done by checking how well a sequence compresses. This is really easy in Maple 14, with the new commands ?StringTools:-Compress and StringTools:-Uncompress which use ...

A while back, someone asked me for a good way to plot a Klein Bottle in Maple. I didn't have a good answer at the time, but I recently stumbled upon the following, which does a pretty good job if you don't mind the use of Heaviside in the parameterization.

plot3d(
[4*(1-1/2*cos(u))*sin(v),
6*cos(u)*(1+sin(u))+4*(1-1/2*cos(u))*(cos(u)*(1-Heaviside(u-Pi))+Heaviside(u-Pi))*cos(v+Pi*Heaviside(u-Pi)),

In a previous post, I promised to write about testing the quality of pseudo-random number sequences.  I'll post later about some of the statistical tests often used, but I first wanted to mention a sort of practical test one can do. One of the many things you might want to do with pseudorandomly generated numbers is Monte Carlo integration/simulatation/etc.  As mentioned by acer in this comment, Monte Carlo integration can be shown to work better with some of the pseudorandom number generators (PRNGs) which are considered inferior in a statistical sense.  In this post, we will play with a simple Monte Carlo approximation of π.

There are two pieces of extended functionality that I quite often want from the Maple Compiler. The first (task A) is to be able to link in and use an arbitrary function from some other external ("3rd party") shared library, within my Compile'd Maple procedure. The second (task B) is to directly call the compiled Maple procedure from within some computational routine in a 3rd party shared library (which I would then access using define_external). This post is about the first of those, task A.

A user recently asked how to find the set of indices corresponding to a given value of a two-dimensional Array.

There are several ways to handle this problem.  For  a single value, a simple scan through the Array suffices:

FindIndices1 := proc(A :: Array, val)
local i,j,irng,jrng;
    (irng,jrng) := rtable_dims(A);
    {seq(seq(`if`(A[i,j]=val, [i,j], NULL), i=irng), j=jrng)};
end proc:

With a multi-core machine, the ...

The hardest and/or most important part of answering a question is making sure the real question is understood. The July 1, 2010 question Using fsolve with a dispersion relation posted to MaplePrimes seemed to be about obtaining a numeric solution of an equation. Turns out it was more a question about the behavior of an implicit function.

Create a maplet or worksheet for the game Blokus. 

On that note, we should have a counter or tally in the post to show how many people want to work on or are attempting to work on the challenge.  That way people can see if there is progress happening behind the scenes.

Jacques' post on the maple.vim project spurred this post.  Vim users cannot have all the fun.

About a year ago I wrote an Emacs front-end for the Maple debugger.  I've used it since---it is now my primary debugging tool for Maple code.  What it does is allow stepping through interpreted Maple code in an Emacs buffer.  That is, rather than being presented with a single line of...

This is a follow-up to a rather old posting about maple.vim.  There is now a maplevim project on google code to helpfully get the community to work on upgrading maple.vim a bit more frequently. 

Right now there is a shipping version of maple.vim checked-in, as well as a set of 'pieces' (in the pieces sub-directory...

While reviewing code the other day, I came across the following snippet (here converted to a procedure).

Ds := proc(V::set, n::posint, t)
local i,v;
    {seq(seq((D@@i)(v)(t), i=1..n), v in V)};
end proc:

The purpose of this is to generate a set of derivatives at a point of a set of unassigned names. For example

 Ds({x,y},2,0);
               ...

It always makes me happy to see people using Maple for interesting things.  So I was pleased to see this blog post on Technology Review about this paper on arXiv on quantum randomness.  In this case, they are just comparing random numbers generated from lasers (this is why physicists get better press than mathematicians: LASERS!) with pseudo-random numbers generated using Meresenne Twister implemented in Maple, pseudo-random numbers generated using a Celluar Automata method implemented in another computer algebra system, and then binary digits of π treated as a pseudo-random sequence.  (Spoiler: the lasers win)

While not a particularly interesting use of computer algebra systems, it did inspire me to revisit my old blog post on pseudo-random numbers in Maple and now I am working on a follow up that talks about some of the mathematical and statitical tests used to test the quality of pseudo-random number sequences which I hope to post soon.

Just for fun, I'm reviving the Maple soccer ball in anticipation of the FIFA final. You can make a simple animation by adding the option viewpoint=[circleleft] to the display command.

with(plots):
geom3d[TruncatedIcosahedron](p);
V := evalf(geom3d[faces](p));
display(seq(polygonplot3d(V[i], color = `if`(nops(V[i]) = 5, black, white)), i = 1 .. 32), scaling = constrained);

The Maple ?Compiler can compile a limited subset of Maple commands to native code. The result is substantially faster than running interpreted Maple code. This article shows how you can save a compiled procedure for reuse.

When a Maple procedure is compiled, a shared object library (dynamic-linked library for Windows) is created on the file system, as a temporary file.  When the Maple...

I had started to create a procedure for finding the centroid of a list of points.

Centroid := proc (list)
local a, centroid, x, y, i:
a := nops(list):
x := 0:
yi := 0:
for i from 1 to a do
x := x+list[i, 1]:
y := y+list[i, 2]:
end do:
print(`Centroid is at`,([xi, yi]/a)):
end proc:

But I thought there needs to be something simpler than that.  And here we are.

Centroid2 := proc (list)
local i:
print(`Centroid is at`, add(i, i = list...

Having Maple 12 I try to use concurrent gfun version 3.52 and have problems
to run an example (from a lecture):

libname:= "D:\\_Work\\Maple_Work\\z_Packages\\gfun", libname; # my setting

with(gfun) : gfun:-version();
with(NumGfun) :
                                 3.52
First 66 67 68 69 70 71 72 Page 68 of 75