Education

Teaching and learning about math, Maple and MapleSim

Hi,
Relevant developments in Physics happened during the last month and a 1/2, some of them of interest beyond the use of this package. Among the most exciting things I can mention:

  1. The redefinition of the derivative rule for the complex components (abs, argument, conjugate, Im, Re, signum) together with the introduction of Wirtinger calculus, as an user-option to work with complex variables. In other words: it is now possible to compute taking z and its conjugate as independent variables and in equal footing.
  2. Introduction of textbook mathematical display for all the inert functions of the mathematical language, also for unknown functions f(x).
  3. New options in Physics:-Setup to indicate that some mathematical objects are real (different from assume(x, real), while integrated with `is` and `coulditbe`).
  4. A rather large number of micro developments advancing the integration of Physics with simplify, expand and combine.
  5. Another large number of micro developments for quantum mechanics.
  6. New options in Physics:-Setup to redefine sum as Physics:-Library:-Add, and with that have access to multiindex summation directly from sum, for instance as in sum(f(i, j), i + j <= n), including related typesetting copy & paste.

As usual the latest version of the package is available for download in the Maplesoft Physics: Research & Development webpage  and in the zip there is a worksheet illustrating all these developments. Below I'm copying the section related to the new redefinesum option of Physics:-Setup and multiindex summation.

Thanks to everyone who provided feedback, it has been of great value and at the root of this new round of developments.

December 4

 
• 

New option in Setup: redefinesum, so that the sum command is redefined in such a way that
    a) the sum arguments are processed in a way avoiding premature evaluation and related unexpected results or error interruptions
    b) the sum command includes new functionality present in Physics:-Library:-Add to perform sum over integer values of many indices, as in

"(&sum;)S(i,j)"     or  "(&sum;)S(i,j)" 

restart; with(Physics); Setup(notation = true)

`* Partial match of  'notation' against keyword 'mathematicalnotation'`

 

[mathematicalnotation = true]

(1.1)

New option: redefine sum so that its arguments are processed by the more modern Physics:-Library:-Add and so that it can perform multiindice summation.

 

Example:

By default, the sum command is not redefined, so the value of redefinesum is

Setup(redefinesum)

[redefinesum = false]

(1.2)

Consider this multiindex summation functionality of the Physics:-Library:-Add command

Library:-Add(f[i, j], 1 <= i+j and i+j <= n)

Physics:-Library:-Add(f[i, j], i+j <= n, lowerbound = 1)

(1.3)

For instance, for n = 2,

eval(Physics[Library]:-Add(f[i, j], i+j <= n, lowerbound = 1), n = 2)

f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.4)

This functionality can be plugged directly into the sum command. For that purpose, set redefinesum to true

Setup(redefinesum = true)

[redefinesum = true]

(1.5)

You can now compute directly with sum. The left-hand side is inert while the right-hand side is computed

(%sum = sum)(f[i, j], i+j <= 2)

%sum(f[i, j], i+j <= 2) = f[0, 0]+f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.6)

(%sum = sum)(f[i, j], 1 <= i+j and i+j <= 2)

%sum(f[i, j], 1 <= i+j and i+j <= 2) = f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.7)

value(%sum(f[i, j], 1 <= i+j and i+j <= 2) = f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0])

f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0] = f[0, 1]+f[1, 0]+f[0, 2]+f[1, 1]+f[2, 0]

(1.8)

The formula for the integer power of a sum

(a+b+c)^n = sum(factorial(n)*a^p*b^q*c^r/(factorial(p)*factorial(q)*factorial(r)), p+q+r = n)

(a+b+c)^n = sum(Physics:-`*`(Physics:-`*`(Physics:-`*`(Physics:-`*`(factorial(n), Physics:-`*`(1, Physics:-`^`(Physics:-`*`(Physics:-`*`(factorial(p), factorial(q)), factorial(r)), -1))), Physics:-`^`(a, p)), Physics:-`^`(b, q)), Physics:-`^`(c, r)), p+q+r = n)

(1.9)

eval((a+b+c)^n = sum(Physics[`*`](Physics[`*`](Physics[`*`](Physics[`*`](factorial(n), Physics[`*`](1, Physics[`^`](Physics[`*`](Physics[`*`](factorial(p), factorial(q)), factorial(r)), -1))), Physics[`^`](a, p)), Physics[`^`](b, q)), Physics[`^`](c, r)), p+q+r = n), n = 2)

(a+b+c)^2 = a^2+2*a*b+2*a*c+b^2+2*b*c+c^2

(1.10)

eval((a+b+c)^n = sum(Physics[`*`](Physics[`*`](Physics[`*`](Physics[`*`](factorial(n), Physics[`*`](1, Physics[`^`](Physics[`*`](Physics[`*`](factorial(p), factorial(q)), factorial(r)), -1))), Physics[`^`](a, p)), Physics[`^`](b, q)), Physics[`^`](c, r)), p+q+r = n), n = 3)

(a+b+c)^3 = a^3+3*a^2*b+3*a^2*c+3*a*b^2+6*a*b*c+3*a*c^2+b^3+3*b^2*c+3*b*c^2+c^3

(1.11)

Verify whether this equation is true

(`@`(evalb, expand))((a+b+c)^3 = a^3+3*a^2*b+3*a^2*c+3*a*b^2+6*a*b*c+3*a*c^2+b^3+3*b^2*c+3*b*c^2+c^3)

true

(1.12)

Besides this new functionality, the redefined sum does a more modern handling of its arguments, consider a typical problem posted in Maple primes

a := 1; b := 2; j := 3

1

 

2

 

3

(1.13)

In the following summation, j is a dummy summation index, so the value just assigned, j := 3, is not expected to interfer with the summation. This is the case with the redefined sum

sum(f(j), j = a .. b)

f(1)+f(2)

(1.14)

while without redefining sum the input above is interrupted with an error message. Likely, in this other case also reported in Mapleprimes

g := proc (j) options operator, arrow; if j::odd then G[j] else 0 end if end proc

proc (j) options operator, arrow; if j::odd then G[j] else 0 end if end proc

(1.15)

the following two summations can be performed after having redefining sum:

sum(g(i), i = 1 .. f)

sum(g(i), i = 1 .. f)

(1.16)

For the summation above, without redefining sum, it returns 0 instead of unevaluated, because of a premature evaluation of the function g(i) with an unassigned index i before performing the summation. Returning unevaluated as (1.16) permits evaluate the sum at a latter moment, for instance attributing a value to f

eval(sum(g(i), i = 1 .. f), f = 3)

G[1]+G[3]

(1.17)

And this other sum where f is given from the begining also returns 0 without redefining sum

sum(g(i), i = 1 .. 3)

G[1]+G[3]

(1.18)

Problems like this other one reported in Mapleprimes here also get resolved with this redefinition of sum.

 

 

Download sum_in_physics.mw

Edgardo S. Cheb-Terrab
Physics, Maplesoft

 

The attached presentation is the first one of a sequence of three that we wanted to do on Quantum Mechanics using Computer Algebra. The level is that of an advanced undergraduate QM course. Tackling this topic within a computer algebra worksheet in the way it's done below, however, is an entire novelty, and illustrates well the kind of computations that can be done today with Maple & Physics.

Ground state of a quantum system of identical boson particles
  

Pascal Szriftgiser1 and Edgardo S. Cheb-Terrab2 

(1) Laboratoire PhLAM, UMR CNRS 8523, Université Lille 1, F-59655, France

(2) Maplesoft

 

Departing from the Energy of a quantum system of identical boson particles, the field equation is derived. This is the Gross-Pitaevskii equation (GPE). A continuity equation for this system is also derived, showing that the velocity flow satisfies `&x`(VectorCalculus[Nabla], `#mover(mi("v"),mo("&rarr;"))`) = 0, i.e.: is irrotational.  

The Gross-Pitaevskii equation

 

NULL


Problem: derive the field equation describing the ground state of a quantum system of identical particles (bosons), that is, the Gross-Pitaevskii equation (GPE).

 

Background: The Gross-Pitaevskii equation is particularly useful to describe Bose Einstein condensates (BEC) of cold atomic gases [3, 4, 5], that is, an ensemble of identical quantum boson particles that interact with each other with an interaction constant G. The temperature of these cold atomic gases is typically in the w100 nano-Kelvin range. The atom-atom interactions are repulsive for G > 0 and attractive for G < 0  (which could lead to some instabilities). The GPE is also widely used in non-linear optics to model the propagation of light in optical fibers. In this area, GPE is known as "non-linear Schrödinger equation", and the non-linearity comes from the Kerr effect [6].

Solution

   

Continuity equation for a quantum system of identical particles

   

References

``

[1] Gross-Pitaevskii equation (wiki)

[2] Continuity equation (wiki)
[3] Bose–Einstein condensate (wiki)

[4] Bose-Einstein Condensation in Dilute Gases, C. J. Pethick and H. Smith, Second Edition, Cambridge (2008), ISBN-13: 978-0521846516.

[5] Advances In Atomic Physics: An Overview, Claude Cohen-Tannoudji and David Guery-Odelin, World Scientific (2011), ISBN-10: 9812774963.

[6] Nonlinear Fiber Optics, Fifth Edition (Optics and Photonics), Govind Agrawal, Academic Press (2012), ISBN-13: 978-0123970237.

 


Downlioad: QuantumMechanics1.mw,    QuantumMechanics1.pdf

Edgardo S. Cheb-Terrab
Physics, Maplesoft

Greetings to all.

As some of you may remember I made several personal story type posts concerning my progress in solving enumeration problems with the Polya Enumeration Theorem (PET). This theorem would seem to be among the most exciting in mathematics and it is of an amazing simplicity so that I never cease to suggest to mathematics teachers to present it to gifted students even before university. My previous efforts are documented at your site, namely at this MaplePrimes link I and this MaplePrimes link II.

I have been able to do another wonderful cycle index computation using Maple recently and I would like to share the Maple code for this problem, which is posted at Math StackExchange.com (this post includes the code) This time we are trying to compute the cycle index of the automorphism group of the 3-by-3-by-3 cube under rotations and reflections. I suggest you try this problem yourself before you look at my solution. Enjoy!

I mentioned in some of my other posts concerning PET that Maple really ought to come with a library of cycle indices and the functions to manipulate them. I hope progress has been made on this issue. I had positive feedback on this at the time here at your website. Do observe that you have an opportinuity here to do very attractive mathematics if you prepare a worksheet documenting cycle index facilities that you may eventually provide. This is good publicity owing to the fact that you can include images of the many geometric objects that appear which all look quite enticing and moreover potential readers get rewarded quickly as they discover that it takes little effort to master this theorem and proceed to work with symmetries themselves and investigate them. This sort of thing also makes nice slides.

With best wishes for happy combinatorics computing,

Marko Riedel

Here 'show triangle napoleon considering the sintaxis Maple, to be supplemented and explained with Math Apps.

Napoleon_Triangle.mw

 

Lenin Araujo Castillo

Hi
In connection with recent developments in the Physics package, we now have mathematical typesetting for all the inert functions of the mathematical language. Hey! This is within the Physics update available on the Maplesoft Physics: Research & Development webpage

I think this is an interesting development that will concretely change the computational experience with these functions: it is not the same to compute with something you see displayed as %exp(x) instead of the same computation but flowing with it nicely displayed as an exponential function with the e in grey, reflecting that Maple understands this object as the exponential inert function, with known properties (all those of the active exp function), and so Maple can compute with the inert one taking these properties into account while not executing the function itself - and this is the essence of the inert function behaviour.

Introducing mathematical display, copy and paste for all these inert functions of the mathematical language concretely increases the mathematical expressiveness of the system, for teaching, working and also for presenting ideas.

Attached is a brief illustration.

Edgardo S. Cheb-Terrab
Physics, Maplesoft

InertMathematicalFun.mw  InertMathematicalFun.pdf

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.

 

La aplicacion de las matrices en su más claro ejemplo, dirigido explicitamente a la criptografia; solo hay que tener conocimiento de algebra de matrices y calculo de matriz inversa. (versión español).

The application of the matrices in its most obvious example, explicitly directed to cryptography; just have to have knowledge of matrix algebra and inverse matrix calculation. (version english).

 

Criptografia.mw

 

Lenin Araujo Castillo

Physics Pure

Computer Science

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

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.

First 36 37 38 39 40 41 42 Last Page 38 of 55