Applications, Examples and Libraries

Share your work here

Maplesoft is a long standing supporter of the Who Wants to Be a Mathematician contest for high school students. For years, we have donated Maple as prizes to winners of the national and regional contests.

This year, being the 25th anniversary of Maplesoft’s incorporation, the company decided to support several projects that encourage the use of math amongst high school students and young adults. We dedicated a bigger budget towards projects that would enable us to make a significant impact on students and impress upon them the need for math and science in their future careers.

One project we undertook this year is giving an extreme makeover to the Who Wants to Be a Mathematician contest! With Maplesoft as a “Technology Sponsor”, the contest that was administered on pen-and-paper moved to a digital format. We donated our testing and assessment tool, Maple T.A. to administer the tests online, making the software accessible to every student that participated. This meant the students took an online test, and were automatically and instantly graded using Maple T.A.

The 2013 competition is underway, and the results are extremely positive:

  • The number of students that participated in the contest doubled this year, with over 2000 students from over 150 schools participating.
  • The competition introduced a second level of tests, making the competition more rigorous. After the first elimination round, eligible contestants moved to a second round with questions of increased difficulty levels.
  • By avoiding much of the paper work and manual corrections, the organizers saw significant savings in time and money.

Custom test questions were created in Maple T.A., which were accessed by students from a server hosted by Maplesoft. The simple and easy to use interface of Maple T.A. enabled the students to take the test without spending time learning the tool. Maple T.A. supports the use of standard mathematical notation in both the question text and student responses. Maple T.A. also allows free-response questions, including questions that have more than one correct answer.

Who Wants to Be a Mathematician is a math contest for high school students, organized by the American Mathematical Society (AMS), as part of its Public Awareness Program. Ten students will be chosen for the semifinals and two will qualify for the finals to be held at the Joint Math Meetings in January 2014.

More information about the contest that is currently in progress can be found on the AMS website

 

I made a small change to the Task Filtering code I uploaded a few weeks ago.  The new code has better memory performance and, most importantly has more stable memory usage which means it can actually run very large examples.  Here is the new version of the code:

FilterCombPara := module( )
    local ModuleApply,
            doSplit,
            splitCombs,
            makeNewPrefix,
            lessThanX,
            filterCombs;

    lessThanX := proc( x, i ) x<=i; end;

    doSplit := proc( i::integer, prefix::set(posint), rest::set(posint),
                                                k::posint, filter::appliable, $ )
        splitCombs( prefix union {i}, remove( lessThanX, rest, i ), k-1, filter );
    end;

    splitCombs := proc( prefix::set(posint), rest::set(posint), k::posint,
                                                                filter::appliable, $ )
        if ( numelems( rest ) < k ) then
            NULL;
        elif ( k = 1 ) then
            filterCombs( prefix, rest, filter );
        else
            op( Threads:-Map( doSplit, rest, prefix, rest, k, filter ) );
        end;
    end;

    makeNewPrefix := proc( i, prefix ) { i, op( prefix ) } end;
    filterCombs := proc( prefix::set(posint), rest::set(posint), filter::appliable, $ )
        local i, f;

        op(select( filter, map( makeNewPrefix, rest, prefix ) )):
    end;

    ModuleApply := proc( n::posint, k::posint, filter::appliable, $ )
        [ splitCombs( {}, {seq( i,i=1..n )}, k, filter ) ];
    end;

end:

This code has the small mapping functions as module members instead of declared inline.  This means that less memory is churned as this code is excuted.  For a long runs, this helps keeps the memory stable.

As an example, I ran the following example:

> CodeTools:-Usage( FilterCombPara( 113,7, x->false ) );
memory used=17.39TiB, alloc change=460.02MiB, cpu time=88.52h, real time=20.15h
                                                  []

It used 88 CPU hours to run, but only 20 hours of real time (go parallelism!)  It used 17 Terabytes of memory, but only allocated 500 M.  This example is pretty trival, as the filter returned false for all combinations, so it did not collect any matches during the run.  However as long as the number of matches is small, that shouldn't be an issue.  If the number of matches is too large to fit in memory, then this code may need to be modified to write the matches out to disk instead of trying to hold them all in memory at once.

Darin

-- Kernel Developer Maplesoft

FilterComb.mw

Good morning to all our Mapleprimes members.

 

It is very helpful to many persons who are very passion and dedicated to teach Mathematics using Maple technology if the software package is loaded with updated maple procedures of all the topics.

I am being of them, request the technical authorities and the eminant professors to support and develop this requirement.It becomes an open door to many people to enter and aquire the immence knowledge in Maple.

 

 

With thanks & Regards

 

M.Anand

Assistant Professor in Mathematics

SR International Institute of Technology,

Hyderabad, Andhra Pradesh, INDIA.

The work consists of two independent procedures. The first procedure  IsConvex  checks the convexity of a polygon. The second procedure  IsSimple  verifies the simplicity of a polygon. Formal argument   is the list of vertices of the polygon.

Regarding the basic concepts, see  http://en.wikipedia.org/wiki/Polygon

 

IsConvex:=proc(X::listlist)

local n, Z, f, i, x, y;

n:=nops(X);

Z:=[op(X),X[1]];

f:=seq((x-Z[i,1])*(Z[i+1,2]-Z[i,2])-(y-Z[i,2])*(Z[i+1,1]-Z[i,1]),i=1..n);

   for i to n do

    if  convert([seq(is(subs(x=j[1],y=j[2],f[i])<=0), j in {op(X)} minus  {X[i],X[irem(i,n)+1]})],`or`) and      convert([seq(is(subs(x=j[1],y=j[2],f[i])>=0),

    j in {op(X)} minus {X[i],X[irem(i,n)+1]})], `or`) then break fi;

   od;

if i<=n then return false else true fi;

end proc:

 

IsSimple:=proc(X::listlist)

local n, Z, i, j, f, T, Q, x, y;

Z:=[op(X),X[1],X[2]]; n:=nops(X);

if n>nops({op(X)}) then   return false  fi;

   for i from 2 to nops(Z)-1 do

     if is((Z[i-1,1]-Z[i,1])*(Z[i+1,1]-Z[i,1])+(Z[i-1,2]-Z[i,2])*(Z[i+1,2]-Z[i,2]) =  sqrt((Z[i-1,1] -Z[i,1])^2+(Z[i-1,2]-Z[i,2])^2)*sqrt((Z[i+1,1]-Z[i,1])^2 +(Z[i+1,2]-Z[i,2])^2)) then return false fi;

   od;

f:=seq((x-Z[i,1])*(Z[i+1,2]-Z[i,2])-(y-Z[i,2])*(Z[i+1,1]-Z[i,1]),i=1..n);

_Envsignum0:= 0: 

   for i from 1 to n do

   T[i]:=[]; Q[i]:=[];

      for j from 1 to n do

      if modp(j-i,n)<>0 and modp(j-i,n)<>1 and modp(j-i,n)<>n-1 and                  not(signum(subs(x=Z[j,1],y=Z[j,2],f[i])*subs(x=Z[j+1,1],y=Z[j+1,2],f[i]))=-1 and             signum(subs(x=Z[i,1],y=Z[i,2],f[j])*subs(x=Z[i+1,1],y=Z[i+1,2],f[j]))=-1) then

      if (subs(x=Z[j,1],y=Z[j,2],f[i])=0 implies (signum((Z[j,1]-Z[i,1])*(Z[i+1,1]-Z[j,1]))=-1 or             signum((Z[j,2]-Z[i,2])*(Z[i+1,2]-Z[j,2]))=-1)) then

      T[i]:=[op(T[i]),1]; Q[i]:=[op(Q[i]),1] else  T[i]:=[op(T[i]),1]  fi; fi;   od;

       od; 

convert([seq(nops(T[i])=n-3,i=1..n), seq(nops(Q[i])=n-3,i=1..n)],`and`)  

end proc:

 

Examples:

X:=[[0,0],[1,0],[2,1],[3,0],[4,0],[2,2]]: IsConvex(X), IsSimple(X);

X:=[[0,0],[2,0],[1,1],[1,-1]]: IsConvex(X), IsSimple(X);

X:=[[0,0],[2,0],[1,1],[1,0], [-1,-1]]: IsConvex(X), IsSimple(X);

X:=[[0,0],[1,0],[1,2],[-2,2],[-2,-2],[3,-2],[3,4],[-4,4],[-4,-4],[5,-4],[5,6],[-6,6],[-6,-6],[7,-6],[7,8],[-6,8],[-6,7],[6,7],[6,-5],[-5,-5],[-5,5],[4,5],[4,-3],[-3,-3],[-3,3],[2,3],[2,-1],[-1,-1],[-1,1],[0,1]]: IsConvex(X), IsSimple(X);

X:=[seq([cos(2*Pi*k/17), sin(2*Pi*k/17)], k=0..16)]: IsConvex(X), IsSimple(X);

Testing_polygons.mws 

Edited: The variables  x  and  y  are made local.

 

Congratulations to Eric Miles, a graduate teaching assistant at Colorado State University, for winning the second individual prize of The Möbius App Challenge! Eric will be receiving an iPad prize pack for his app Stretch and Translate Sin(x).

Maplesoft launched the Möbius App Challenge earlier this year to give Maplesoft community members the opportunity to get involved in the creation of Möbius Apps. This contest seeks to challenge users to create Math Apps using Maple, submit them to The Möbius Project website, then award the most useful, creative, and effective submissions. Finalists from the individual level challenge are chosen four times a year, so make sure to enter the next round of the challenge for your chance at a Maplesoft prize pack!

For full contest details and to enter, please visit: http://www.maplesoft.com/lp/mobius/index.aspx.

Jonny Zivku
Maplesoft Product Manager, Maple T.A.

Well-known problem is the problem of placing eight shess queens on an 8×8 chessboard so that no two queens attack each other. In this post, we consider the same problem of placing  m  shess queens on an  n×n  chessboard. The problem has a solution if  n>3  and  m<=n .

Work consists of two procedures. The first procedure  Queens  returns the total number of solutions and saves a complete list of all solutions (global variable  S ). The second procedure  QueensPic  shows the user-defined solutions from the list  S  on the board. Formal argument  t  is the number of solutions in each row of the display. The second procedure should be used in the standard interface, rather than in the classic one, since in the latter it may not work properly.

Queens := proc (m::posint, n::posint)

local It, K, l, L, M, P;

global S, p, q;

It := proc (L)

local P, k, i, j;

M := []; k := nops(L[1]);

for i in L do

for j to n do

if convert([seq(j <> i[s, 2], s = 1 .. k)], `and`) and convert([seq(l[k+1]-i[s, 1] <> i[s, 2]-j, s = 1 .. k)], `and`) and convert([seq(l[k+1]-i[s, 1] <> j-i[s, 2], s = 1 .. k)], `and`) then M := [op(M), [op(i), [l[k+1], j]]]

fi;

od; od;

M;

end proc;

K := combinat:-choose([`$`(1 .. n)], m);

S := [];

for l in K do P := [];

L := [seq([[l[1], i]], i = 1 .. n)];

P := [op(P), op((It@@(m-1))(L))];

S := [op(S), op(P)]

od;

p := args[1]; q := args[2];

nops(S);

end proc:

 

QueensPic := proc (M, t::posint)

local m, n, HL, VL, T, A, N;

uses plottools, plots;

m := p; n := q; N := nops(args[1]);

HL := seq(line([.5, .5+k], [.5+n, .5+k], color = black, thickness = 2), k = 0 .. n);

VL := seq(line([.5+k, .5], [.5+k, .5+n], color = black, thickness = 2), k = 0 .. n);

T := [seq(textplot([seq([op(M[i, j]), Q], j = 1 .. m)], color = red, font = [TIMES, ROMAN, 24]), i = 1 .. N)];

if m <= n and 3 < n then

A := seq(display(HL, VL, T[k], axes = none, scaling = constrained), k = 1 .. N), seq(display(plot([[0, 0]]), axes = none, scaling = constrained), k = 1 .. t*ceil(N/t)-N);

Matrix(ceil(N/t), t, [A]);

display(%);

fi;

end proc:

 

Examples of work:

Queens(5, 6);  

S[70], S[140], S[210];

QueensPic([%], 3); 

                                                                            248

[[1, 5], [2, 3], [3, 6], [4, 4], [6, 1]], [[1, 3], [2, 5], [4, 1], [5, 4], [6, 2]], [[2, 1], [3, 4], [4, 2], [5, 5], [6, 3]]

 

Two solutions of classic problem:

Queens(8, 8); 

S[64..65];

QueensPic(%, 2);

                                                                                      92

[[[1, 5], [2, 8], [3, 4], [4, 1], [5, 7], [6, 2], [7, 6], [8, 3]], [[1, 6], [2, 1], [3, 5], [4, 2], [5, 8], [6, 3], [7, 7], [8, 4]]]

 

 

Queens_problem.mw

Voting is open for the next individual prize to be awarded as part of the Möbius App Challenge.  The winner will receive an iPad Prize Pack! 

Here are the finalist Apps:

Hi
Just finished updating the comparison between Maple 17.02 and Mathematica 9.01 in solving the 1390 Ordinary Differential Equations (ODEs) of Kamke's book:

  • Mathematica solved 80% in 7 hours and 8 minutes
     
  • Maple solved 97.5% in 43 minutes

While trying to solve the whole set, Mathematica hanged with 90 of these ODEs while Maple hanged with 6 ODEs. A pdf with a summarizing table and all the details is linked below

It is also relevant here that Maple's dsolve has close to half of its code implementing more modern methods, not found in Kamke, illustrated in the Maple 'what's new in DEs' help pages of the last 10 releases; for these other kinds of equations the difference is more impressive. I'll see to prepare another post about that.

Edgardo S. Cheb-Terrab
Physics, Maplesoft

Comparison_Kamke.pdf

The question was "Let X be the random variable uniformly distributed in the disk centered at the origin O(0,0) with radius 1 and let Y be the random variable uniformly distributed in the square having its vertices A(6,-1), B(9,-2), C(8,-5), and E(5,-4). What is the PDF of the distance between X and Y? Is it possible to find that with Maple?"
Having a long think about the topic, I draw the conclusion that the exact closed form of the PDF/CDF, even the one can be found, would be useless because of its complexity.
Thus, an approximate formula for the CDF/PDF under consideration is a proper way. That formula can be derived in such a way. First,rotating the picture, we may consider the square having its sides horizontal or vertical: K((1/5)*sqrt(1410)-(1/2)*sqrt(10),1/sqrt(10)), L((1/5)*sqrt(1410)+(1/2)*sqrt(10),1/sqrt(10), M((1/5)*sqrt(1410)+(1/2)*sqrt(10),1/sqrt(10)-sqrt(10)), Q((1/5)*sqrt(1410)-(1/2)*sqrt(10),1/sqrt(10)-sqrt(10)). The geometry behind that is omitted.
We randomly choose a point P1 belonging to the square [-1,1] x [-1.1]. If the one belongs to the disk {(x,y):x^2+y^2 <=1}, then we randomly choose a point P2 from the square [K,L] x [Q,L]. Next, we calculate the distance between P1 and P2 (The  LinearAlgebra[Norm] command http://www.maplesoft.com/support/help/Maple/view.aspx?path=LinearAlgebra/Norm is used to this end.) and add it to the set S.This is repeated 2*10^4 times.

Converting S to an Array A, we constuct the empirical distribution X by A and find its mean mu and standard deviation sigma.


7.67568900820260

1.029831470

Let us compare the obtained empirical distribution and the normal distribution with the parameters mu and sigma.

The plot suggests a good fit between these. However, it is only semblance. Applying the Kolmogorov-Smirnov test (for example, see  http://www.mapleprimes.com/posts/119903-The-KolmogorovSmirnov-Test
), we  calculate

and

3.32619143372726

while the critical value equals 1.358098639 at the level 0.05. Thus, the hypothesis about the concordance should be rejected.

Also we draw the approximation to the PDF:


CDF.mw

This blog post is a response to a post on MaplePrimes.  MaplePrimes user wkehowski asked how the Task Model could be used to filter combinations.  The basic problem is formalated like this:  We want a function, I'll call it FilterComb, that accepts positive integers...

Himmelblau.mw

     On the basis of Dragнilev method…

     Is there anyone interested in the algorithm to reduce the distance between the points of the given constraints? The algorithm is adapted for use in R ^ n. This is an example of its work on the surface:  
f = - (x1 ^ 2 x2-.3) ^ 2 - (x1 x2 ^ 2-.7) ^ 2 - 5;  

     Approximate description of the algorithm in pictures.

Himmelblau.mw

     On the basis of Dragнilev method…

     Is there anyone interested in the algorithm to reduce the distance between the points of the given constraints? The algorithm is adapted for use in R ^ n. This is an example of its work on the surface:  
f = - (x1 ^ 2 x2-.3) ^ 2 - (x1 x2 ^ 2-.7) ^ 2 - 5;  

     Approximate description of the algorithm in pictures.

Fourteen Clickable Calculus examples have been added to the Teaching Concepts with Maple area of the Maplesoft web site. Four are sequence and series explorations taken from algebra/precalculus, four are applications of differentiation, four are applications of integration, and two are problems from the lines-and-planes section of multivariate calculus. By my count, this means some 111 Clickable Calculus examples have now been posted to the section.

A kryptarithm - this is an example of arithmetic, in which all or some of the digits are replaced by letters. The rule must be satisfied: the different letters represent different digits, the identical letters represent the identical digits. See the link  http://en.wikipedia.org/wiki/Verbal_arithmetic.

The following procedure, called  Ksolve , solves kryptarithms in which are used four operations ...

Hi

It's been 1 and 1/2 months since updates for the Maple Physics package have been distributed in the Maplesoft webpage "Maple Physics: Research & Development".  The number of Mapleprimes Physics posts that got rapidly addressed in this way is already large, some of them are listed here.

The experience has been great. Suggestions are implemented and problems are fixed in a couple of days since they were posted here, and the changes are made available to everybody right away. This is moving the focus of developments into the topics people are actually working on, with feedback and related downloadable updates happening every week.

The recent Physics updates are mostly related to quantum mechanics, an advanced topic, but part of the resulting functionality is interesting for algebraic computations in general. To mention but one: the "automatic combination of products of powers of same base" is now optional.

Recalling, by default, in Maple, if you enter xn xm, in order to receive x(n+m). you need to use the combine command (the same happens with products of exponentials). The idea behind the Maple approach is to give you more control over the steps. On the other hand, depending on your problem, the automatic combination of powers of the same base is a desired automatic simplification - this is for instance the Mathematica approach.

In today's update of Physics, a new Setup option, 'combinepowersofsamebase', is implemented, so that this automatic simplification is now optional. If set to true (> Setup(combine = true))you enter xn xm or exp(A) exp(B) and you respectively receive x(n+m) and exp(A+B). Being able to turn this automatic simplification ON and OFF comes in handy in varied situations.

Those more familiar with noncommutative objects (e.g. Matrices), also know that the combination of exp(A) exp(B) is not valid when the exponents A and B do not commute, unless A and B commute with their commutator AB - BA, in which case the combination can be done using Glauber's formula (also related to Hausdorff's formula). All of these cases have been implemented too.

In summary, in the latest update of Physics the combination and expansion of powers and exponentials using combine and expand now takes into account the noncommutative character of the exponents and the value of their commutator, and there is the option of having this combination happening automatically, for both noncommutative and commutative algebraic objects in general.

Other relevant changes more related to Physics are described in the PhysicsUpdates.mw distributed inside the zip that contains the updated Physics.mla linked in the "Maple Physics: Research & Development" webpage.

First 46 47 48 49 50 51 52 Last Page 48 of 71