<<

A morsel of

Alasdair McAndrew

March 26, 2007

This report details the information presented to the RGMIA group at a seminar titled “Maxima: An Open-source System”, given on March 26, 2007: see http://rgmia.vu.edu.au/seminars/index.html.

1 A bit of history

Maxima is a descendant of the , which was initially developed at MIT as part of Project MAC in the late 1960’s. By the mid 1980’s, although early versions of Mathematica and were then gaining market share, Macsyma was clearly the strongest such system, with robust , excellent interfaces, and a fine hypertext help system. Macsyma was written in the dialect of lisp, a language which many considered perfect for mathematical computations. In 1982, William Schelter, of the University of Texas at Austin, had managed to acquire the source code to a version of Macsyma which had been licensed to the US Department of Energy; this version was known as DOE Macsyma. The source code, adapted By Schelter for , was released under the GPL by Schelter in 1998. Schelter maintained this version of Macsyma (renamed GNU Maxima) until his death from a heart attack in 2001, at the untimely age of 52. Since then Maxima has been maintained by an enthusiastic group of developers, including several of the original developers of Macsyma. The original Macsyma, although sold as a commercial package until the mid 1990’s, lost ground to Maple and Mathematica partly because of some poor business decisions, and partly because of some of its weaknesses—in particular its numerics. However, such was the power and strength of Macsyma that some commentators believe that Maple and Mathematica have taken decades to get to the stage where Macsyma was. As of 2007, Macsyma still exists, and has been acquired by a holding company Tenedos LLC; this company had previously bought Symbolics, the distributor of Macsyma. Tenedos LLC has not released Macsyma again, or resold it. Symbolics still officially sell Macsyma.

2 Maxima now

To all intents and purposes, Macsyma is now unobtainable, and the best current version of this once-great CAS is Maxima. Maxima has several points in its favour:

it is licensed under the GPL; it is now, and always will be, free. • it is being actively developed. • the Maxima mail group is extremely active. • because Maxima is being developed by its users, it is very attuned to its user community. •

1 Maxima, in its current form, has excellent, calculus, linear algebra and general symbolic • capabilities.

However, being based on an early version of Macsyma, many of the later refinements of Macsyma—believed to be in the order of 50 man-years of work—have not made it as far as Maxima (yet). So Maxima is deficient in some areas:

its interface is non-standard, a bit clunky and described as “something out of the 1970’s”. • it is very weak in discrete mathematics. • its numerics are still weak—there is still no robust solid method for finding numeric roots • of (systems of) nonlinear equations.

its plotting is based on , which is good at plotting functions y = f(x) or z = f(x,y) • and for plotting data sets, but not for much else. It can’t, for example, plot two surfaces at once and so show their intersections.

Maxima does not have a Package system, such as Maple and MuPAD; individual files • can be loaded into a running session, and a single file may contain one or more Maxima commands.

In its current form, Maxima is unsuitable as a teaching tool. • Maxima’s home on the Web is at http://maxima.sourceforge.net/index.shtml and this page should provide a jumping off point for any investigations into it. There are screenshots, tutorials, other documentation, and links to related projects such as other CASs or Maxima interfaces.

3 Interfaces

Maxima has several interfaces, from plain console, to some reasonable full featured windows applications. The main difference between them is their ability to output typeset mathematics. Figure 1 shows input and output taken from a window running Maxima in console mode; the result, typeset in ASCII, although readable, is not pleasant.

Figure 1: Maxima running in console mode

A slightly better interface, in that it allows cutting and pasting between commands, and incorporates a help browser, is Xmaxima, which comes standard with the software. Xmaxima also allows included graphics, and provides a sort of very cut-down windowing interface.

2 Figure 2: Maxima running in TeXmacs

A better result is obtained by running Maxima within the text processor TeXmacs; an input-output pair is shown in figure 2. Probably the best interface under MS Windows is wxMaxima, which is a third party project developed by Andrej Vodopivec; you can find it at http://wxmaxima.sourceforge.net/wiki/ index.php/Main_Page. It is built with the wxWidgets toolkit, so is designed to work across different platforms. It provides reasonably well typeset output, a good menu system, and access to a help browser. An example of its typesetting is shown in figure 3.

Figure 3: Typesetting in wxMaxima

Further screenshots are available from the Maxima project page. There are also several modes which allow Maxima to run within the text editor ; one of these modes (imaxima) provides TeX-formatted output.

4 Some examples of Maxima in use

Arithmetic Maxima can, as all good CAS’s can, perform arithmetic to arbitrary precision: (%i1) 2+3; (%o1)

5

(%i2) 3^1000; (%o2)

132207081948080663689045525975214436596542203275214816766492036822682859734670 489954077831385060806196390977769687258235595095458210061891186534272525795367 402762022519832080387801477422896484127439040011758861804112894781562309443806 156617305408667449050617812548034440554705439703889581746536825491613622083026 856377858229022841639830788789691855640408489893760937324217184635993869551676 501894058810906042608967143886410281435038564874716583201061436613217310276890 2855220001

(%i3) sum(1/n,n,1,100);

3 (%o3) 14466636279520351160221518043104131447711 2788815009188499086581352357412492142272 (%i4) fpprec:80 (%i5) bfloat(%pi); (%o5)

3.141592653589793238462643383279502884197169399375105820974944592307816406286209b0

Polynomials and rational functions We can expect the usual things: expansion and factorization, division with remainder, partial fractions. Maxima in fact has a suite of commands to enable the efficient handling of such expressions. (%i6) expand((x+y/2-3*z)^5); (%o6)

405yz4 135y2z3 45y3z2 243z5 + + 405xz4 270xyz3 270x2z3 + − 2 − 2 − − 4 135xy2z2 15y4z 15xy3z 45x2y2z + + 135x2yz2 + 90x3z2 2 − 16 − 2 − 2 y5 5xy4 5x2y3 5x3y2 5x4y 30x3yz 15x4z + + + + + + x5 − − 32 16 4 2 2 (%i7) factor(%) (%o7)

(6z y 2x)5 − − − 32

One nice application of factor is to factor over a field extended by an element whose minimal is given: (%i8) factor(x^4+1); (%o8)

x4 + 1

(%i9) factor(x^4+1,a^2+2); (%o9)

(x2 ax 1)(x2 + ax 1) − − −

And of course partial fractions: (%i10) expand((x^3/(x^2+1))^4); (%o10)

x12 x8 + 4x6 + 6x4 + 4x2 + 1

4 (%i11) partfrac(%,x); (%o11) 20 15 6 1 + + + x4 4x2 + 10 −x2 + 1 (x2 + 1)2 − (x2 + 1)3 (x2 + 1)4 −

Calculus As you would expect, limits (directionless, or with a direction given), differentiation, integration, : (%i12) limit((sqrt(x^2+x+23)-5)/(x-1),x,1) (%o12) 3 10 (%i13) k(x):=(3*x-15)/(x^2-10*x+25)^(1/2); (%o13) 3x 15 k(x) := − 1 (x2 10x + 25) 2 − (%i14) limit(k(x),x,5,plus); (%o14) 3 (%i15) limit(k(x),x,5,minus); (%o15) 3 − (%i16) diff(bessel_i(0,x),x,4); (%i17) radcan(%); (%o17) bessel i(0,x)x3 2 bessel i(1,x)x2 + 3 bessel i(0,x)x 6 bessel i(1,x) − − x3 (%i18) integrate(1/(x^5+1),x); (%o18) (√5 3) log(2x2 + (√5 1)x + 2) (√5 + 3) log(2x2 + ( √5 1)x + 2) − − − − 10 10√5 − 10√5 + 10 − 4x+√5 1 4x √5 1 (√5 + 1) arctan − (√5 1) arctan − − √(2√5+10) − √(10 2√5) log(x + 1) +   +  −  + √5 (2√5 + 10) (√5 (10 2√5)) 5 − (%i19) t:taylor(sqrt(x^2+1),x,0,10);p p (%o19) x2 x4 x6 5x8 7x10 1+ + + 2 − 8 16 − 128 256 (%i20) pade(t,6,6); (%o20) 70x4 + 224x2 + 160 x6 + 18x4 + 48x2 + 32 , −x6 18x4 144x2 160 6x4 + 32x2 + 32 " − − − #

5 Linear Algebra We’ll create a few matrices and play with them: (%i21) A:matrix([1,2,3],[4,5,6],[7,8,-9]); (%o21)

1 2 3  4 5 6  7 8 9  −    (%i22) B:matrix([1,-2,3],[-4,5,-6],[7,8,9]); (%o22)

1 2 3 − 4 5 6  − −  7 8 9     (%i23) A.B (%o23)

14 32 18  26 65 36  88 46 108  − − −    (%i24) invert(A); (%o24)

31 7 1 − 18 9 18  13 5 1  9 − 9 9  1 1 1   18 9 18   − −  (%i25) charpoly(B,alpha); (%i26) expand(%); (%o26)

α3 + 15α2 78α 96 − − − We can also compute eigenvalues: (%i27) eigenvalues(A); (%o27)

1 √ 1 1 43 3 i /2 2 √3 i /2 3 √8682 i 37 3 + − 1,    1 − − 2 − 3 −      3 √8682 i 37  −    1 43 √3 i /2 1 1 3 − − 2 √3 i /2 3 √8682 i 37 + 1 1, − 2 −    3  −      3 √8682 i 37 −   1 1 3 3 3 √8682 i 37 + 43/ 3 √8682 i 37 1 , [1, 1, 1] −  −  −           6 As you can see, the eigenvalues have been computed by attempting to solve the characteristic polynomial of the matrix. A more useful result can be obtained by: (%i28) allroots(charpoly(A)); (%o28) [x = 0.42488196531247785,x = 10.05933172129618,x = 12.634449755983702] − − Until the LAPACK libraries are fully integrated into Maxima (a project currently underway), Maxima’s ability to perform numerical linear algebra, such as calculating the eigenvalues of a large matrix, is limited.

Variables and functions As we have indicated above, a variable is assigned with the colon operator. Named functions are defined with colon equals: (%i29) f(x):=if x<0 then x else x^2; (%o29) f(x) := if x< 0 then x else x2 (%i30) f(-3); (%o30) 3 − (%i31) f(3); (%o31) 9

Unnamed functions are defined with the lambda operator. We can use this, for example, to define a matrix whose elements are functions of the row and column indices: (%i32) genmatrix(lambda([i,j],i^2-j^2+1),3,3); (%o32) 1 2 7 − − 4 1 4  −  9 6 1     For recursive functions, whose call may result in a long tree of other recursive calls, it may be more convenient to define an array function, where the function delimiters are square brackets, rather than parentheses. Here is Hofstadter’s chaotic function: (%i33) q[n]:=if n<2 then 1 else q[n-q[n-1]]+q[n-q[n-2]]; (%o33) q[n] := if x< 2 then 1 else q[n q[n 1]] + q[n q[n 2]] − − − − (%i34) makelist(q[n],n,1,30); (%o34) [1, 2, 3, 3, 4, 5, 5, 6, 6, 6, 8, 8, 8, 10, 9, 10, 11, 11, 12, 12, 12, 12, 16, 14, 14, 16, 16, 16, 16, 20]

7 Solving equations Maxima can solve many algebraic equations, some numerically, some symbolically: (%i35) p(x):=3x^3-18x^2+33x-19; (%i36) s:solve(p(x)=0,x); (%i37) map(lambda([x],trigsimp(rectform(x))),s); (%o37)

π π π π π 3 sin √3 cos + 6 3 sin + √3 cos 6 2 √3 cos + 6 x = 18 − 18 ,x = 18 18 − ,x = 18 "  3  −  3  3  # (%i38) eq1:a*x+b*y+c*z=A; (%i39) eq2:d*x+e*y+f*z=B; (%i40) eq3:g*x+h*y+i*z=C; (%i41) linsolve([eq1,eq2,eq3],[x,y,z]); (%o41) b (iB fC)+ c (eC hB) + (f h e i) A x = − − − , a (f h e i)+ b (d i f g)+ c (e g d h)  − − − a (iB fC)+ c (dC gB) + (f g d i) A y = − − − , − a (f h e i)+ b (d i f g)+ c (e g d h) − − − a (hB eC)+ b (dC gB) + (e g d h) A z = − − − a (f h e i)+ b (d i f g)+ c (e g d h) − − −  (%i42) allroots(p(x)); (%o42)

[x = 1.257772801031441,x = 1.605069156365301,x = 3.137158042603259]

Differential equations Maxima can solve many differential equations with ease; let’s try a simple second order linear ODE d2y dy 3 + 2y = x2, y(0) = 1,y(1) = 3. dx2 − dx This can be done in three steps: first defining the equation, then solving it, and finally entering the initial conditions: (%i43) de:’diff(y,x,2)-3*’diff(y,x)+2*y=x^2; (%o43) 2 d d 2 2 y 3 y + 2y = x dx − dx  (%i44) s:ode2(de,y,x); (%o44) 2 x x 2x + 6x + 7 y =%k1 e2 +%k2 e + 4 (%i45) bc2(s,x=0,y=1,x=1,y=3); (%o45) 3e2x 1 (3e + 3)ex 1 2x2 + 6x + 7 y = − − + 4 − 4 4

8 There are various user-provided functions to solve particular types of differential equations. For example, here is one of the Riccati type: dy = x2 + y2, y(1) = 1. dx To solve this, first we must load the ode1 riccati.mac file, which contains the necessary Maxima programs to handle such ODE’s. As above, we first define the equation, then solve it, and lastly enter the initial condition. (%i46) load(ode1_riccati); (%i47) de:’diff(y,x)=x^2+y^2; (%i48) s:ode1_riccati(de,y,x); (%o48)

x2 x2 x2 bessel j 5 , %c + bessel j 3 , x2 + bessel j 1 , %c − 4 2 − 4 2 − 4 2 x2 x2   bessel j 1 , %c + bessel j 1 , x   − 4 2 4 2      (%i49) ic1(s,x=1,y=1); (%o49)

3 x2 1 1 5 1 3 x2 bessel j 4 , 2 bessel j 4 , 2 + bessel j 4 , 2 bessel j 4 , 2 − x2 − − − x2  bessel j 5 , bessel j  3 , 1 x2  bessel j 3 , 1 besselj 1 , − − 4 2 − 4 2 − − 4 2 − 4 2 y = x2 x2 − bessel j 1 , 1 + bessel j  5 , 1 bessel j 1 , bessel j 3, 1 bessel j 1 , x − 4 2 − 4 2 4 2 − − 4 2 − 4 2           

Maxima’s knowledge and handling of Bessel functions isn’t up to simplifying this magnificent expression. Although Maxima doesn’t have an inbuilt command for producing a series solution to an ODE, such a solution can be generated very easily by repeatedly integrating the equation. This is Picard’s method and for the general equation dy = f(x,y), y(a)= b dx the initial value is y = b and then the iteration x y b + f(x,y) dx ← a Z is used to obtain better approximations to y. For the Riccati equation above, with the simpler initial condition y(0) = 1, the integration starts with y = 1 and then uses the iteration

x3 y 1+ + y2 dx ← 3 Z until as many terms of the series as desired have been computed. One problem with applying this integration is that the computation quickly becomes swamped with large powers of x. To keep the computation manageable, Maxima provides the useful command tellrat, which in the form tellrat(X) means substitute 0 for X in algebraic expressions. So, here goes:

9 (%i50) tellrat(x^11); (%i51) algebraic:true; (%i52) for i : 1 thru 12 do y : rat(1+x^3/3+integrate(y^2,x)); (%i53) expand(y); (%o53)

1961x10 428x9 369x8 404x7 37x6 6x5 7x4 4x3 + + + + + + + + x2 + x + 1 1400 315 280 315 30 5 6 3

Plotting Maxima’s plotting is based on the Gnuplot software, which allows for plotting of two and three dimensional functions, and datasets. So a plot2d or plot3d command collects the functions and parameters, and passes them all to Gnuplot for plotting. Gnuplot is bundled with Maxima, so there is no need to install it separately. Here is a selection of different plot commands, starting with two simple plots: a function, and a parametric plot: (%i54) plot2d (sin(x)+sin(3*x)/3, [x, -2*%pi, 2*%pi])$ (%i55) plot2d ([parametric, cos(t), sin(3*t), [t, 0, %pi*2],[nticks,180]]);

The outputs of these commands are shown in figure 4.

1 1 sin(3*x)/3+sin(x) cos(t), sin(3*t)

0.8 0.8

0.6 0.6

0.4 0.4

0.2 0.2

0 0

-0.2 -0.2

-0.4 -0.4

-0.6 -0.6

-0.8 -0.8

-1 -1 -8 -6 -4 -2 0 2 4 6 8 -1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1

Figure 4: Simple plots

Next we show a point plot; in this case a plot of the first 1000 values of Hofstadter’s chaotic function: (%i56) xs:makelist(n,n,1,1000)$ (%i57) qs:makelist(q[n],n,1,1000)$ (%i58) plot2d([discrete,xs,qs],[gnuplot_curve_styles,["with points"]]);

This graph is shown in figure 5. Finally, a clutch of three-dimensional plots, all with different parameters: (%i59) plot3d(sin(sqrt(x^2+y^2))/sqrt(x^2+y^2),[x,-4*%pi,4*%pi],[y,-4*%pi,4*%pi])$ (%i60) plot3d(sin(sqrt(x^2+y^2))/sqrt(x^2+y^2),[x,-4*%pi,4*%pi],[y,-4*%pi,4*%pi], [’grid,180,180])$

10 700 discrete1

600

500

400

300

200

100

0 0 100 200 300 400 500 600 700 800 900 1000

Figure 5: A point plot

(%i61) plot3d(sin(sqrt(x^2+y^2))/sqrt(x^2+y^2),[x,-4*%pi,4*%pi],[y,-4*%pi,4*%pi], [plot_format,openmath])$ (%i62) plot3d ([cos(x)*(3 + y*cos(x/2)), sin(x)*(3 + y*cos(x/2)),y*sin(x/2)], [x, -%pi, %pi], [y, -1, 1], [’grid, 50, 15])$

These graphs are shown in figure 6.

User contributed functions Many of Maxima’s commands are automatically loaded when Maxima is started. But there is a vast collection of further material, stored within the share directory, which extends Maxima’s functionality. Much of this material has been provided by users; some, after enough testing, gets moved into the Maxima “core” with newer releases. Some of these functions are:

Symbolic evaluation (using the Gosper-Zeilberger algorithm) of finite sums. • Solving difference equations. • Solving particular types of differential equations. • String processing. • The simplex algorithm for linear programming. • Some numerical routines for interpolation, FFT, quadrature. • LU and Cholesky factorization of matrices. • Here are a few examples; first a symbolic sum n 1

k k(k + 1)(k + 2) X=1 (%i63) load(zeilberger); (%i64) GosperSum(1/(k*(k+1)*(k+2)),k,1,n);

11 Function Function

1 1 0.8 0.8 0.6 0.6 0.4 0.4 0.2 0.2 0 0 -0.2 -0.2 -0.4 -0.4 15 15 10 10 5 5 -15 -15 -10 0 -10 0 -5 -5 -5 -5 0 0 5 -10 5 -10 10 10 15-15 15-15

Function

1

0.5

0

-0.5

-1 4 3 2 1 -4 -3 0 -2 -1 -1 0 -2 1 2 -3 3 4-4

Figure 6: Three dimensional plots

12 (%o64)

1 1 4 − 2 (n + 1) (n + 2)

Now a difference equation;

2 an 5an + 6an = n , a = 2, a = 0. +2 − +1 0 1

(%i65) load(recur); (%i66) char(a(n+2)-5*a(n+1)+6*a(n),n^2,a,n,2,[a(0)=2,a(1)=0]); (%o66) n 2 7 3 n n 3 n 5 a (n)= + 3 2 + + + − 2 2 2 2

Now an example of string processing: reducing a string of capital letters into a sequence giving their position from the start of the alphabet (so A = 0, B = 1, C = 2 and so on.): (%i67) load(stringproc); (%i68) str:"GIVEMEALLYOURMONEY"; (%i69) strl:charlist(str); (%o69)

[G, I, V, E, M, E, A, L, L, Y, O, U, , M, O, N, E, Y]

(%i70) stn:maplist(lambda([x],cint(x)),strl); (%o70)

[71, 73, 86, 69, 77, 69, 65, 76, 76, 89, 79, 85, 82, 77, 79, 78, 69, 89]

(%i71) stn2:maplist(lambda([x],x-65),stn); (%o71)

[6, 8, 21, 4, 12, 4, 0, 11, 11, 24, 14, 20, 17, 12, 14, 13, 4, 24]

Of course the last two commands could be written as one, using lambda([x],cint(x)-65).

5 Programming in Maxima

As we have indicated earlier, Maxima contains all the programming structures required to build programs of any complexity. Maxima’s base language is Lisp, but Maxima can either be programmed in Lisp, or in its own language. We shall look at a very simple program: Heun’s method (or the Modified Method)1 for solving a single ODE numerically. The ODEs to be solved are of the form dy = f(x,y), y(a)= b dx 1Some writers distinguish carefully between these two; others claim they are two descriptions of the same method. I don’t care, really.

13 Assuming that (xn,yn) is a point on the solution curve (for example, x = a, y = b), then another solution point (xn+1 = xn + h, yn+1) can be determined by integrating through the equation: xn+1 yn+1 = yn + f(x,y) dx. x Z n We can approximate the by the left-hand rule b f(x) dx (b a)f(a) a ≈ − Z which leads to yn+1 = yn + hf(xn,yn). This is known as Euler’s method. Heun’s method is obtained by approximating the integral with the trapezoidal rule: b b a f(x) dx − (f(a)+ f(b)) a ≈ 2 Z which leads to h yn = yn + (f(xn,yn),f(xn ,yn )) . +1 2 +1 +1 The trouble with this equation is that the right hand side refers to yn+1, which we don’t actually know. We overcome this by substituting the value obtained from Euler’s method above; thus: h yn = yn + (f(xn,yn),f(xn ,yn + hf(xn,yn))) . +1 2 +1 This is normally written as a sequence of three steps:

xn+1 = xn + h

pn+1 = yn + hf(xn,yn) h yn = yn + (f(xn,yn)+ f(xn ,pn )) . +1 2 +1 +1 In this form it is a simple example (in fact, the simplest example), of a predictor-corrector method: the value of yn+1 is first predicted (by Euler’s method) and then corrected (by the trapezoidal rule). Now to programming. Rather than produce three sequences xn, yn and pn, we shall just have the variables x, y, xnew ynew and p. The heart of our program, the bit which actually does the calculation, will be: xnew:x+h, p:y+h*f(x,y), ynew:y+(h/2)*(f(x,y)+f(xnew,p) This will be placed inside a loop, which will be computed a number of times entered by the user; this value will be denoted steps: for i:1 thru steps do block( xnew:x+h, p:y+h*f(x,y), ynew:y+(h/2)*(f(x,y)+f(xnew,p), x:xnew, y:ynew ),

14 where in Maxima the block construct simply groups together a list of commands and treats them as a single statement. Now we can turn the whole thing into a command heun, as follows: heun(f,initial,xfinal,steps):=block( [h:(xfinal-initial[1])/steps, x:initial[1], y:initial[2], xnew, ynew, p], for i:1 thru steps do block( xnew:float(x+h), p:float(y+h*f(x,y)), ynew:float(y+(h/2)*(f(x,y)+f(xnew,p))), x:xnew, y:ynew ), return([x,y]) );

The first block statement allows us to initialize some local variables; these are delineated by square brackets. The initial value is a list of two elements, being the initial values (x,y) = (a, b). The xfinal variable is the value of x for which we require the corresponding y value. And steps is the number of steps! We have also placed float calls around the calculations for xnew, ynew and p to ensure that all values are computed numerically. This program can be saved in a file called heun.mac and placed somewhere in Maxima’s search path. Now for an example: dy = y x, y(0) = 2 dx − for which the analytic solution can be determined to be y(x)= ex + x + 1. Try y(1): (%i72) load(heun); (%i73) f(x,y):=y-x; (%i74) heun(f,[0,2],1,10), (%o74)

[.9999999999999999, 4.714080846608224]

(%i75) heun(f,[0,2],1,20), (%o75)

[1.0, 4.717191054354884]

(%i76) exp(1.0)+1+1; (%o76)

4.718281828459045

The program could be easily modified to list intermediate values of x and y, or to write all values to an array for nice display. Also, the program assumes that the variables will be x and y; it doesn’t allow the use of different variables.

15 6 Help and documentation

Plenty of help is provided. Its main fault is that it is not properly typeset: all the mathematical material is presented as ASCII. Here, for example, is a section for the help section on integration: (%i1) assume(a > 0)$ (%i2) ’integrate (%e**sqrt(a*y), y, 0, 4); 4 / [ sqrt(a) sqrt(y) (%o2) I%e dy ] / 0 The advantage of using ASCII though, means that Maxima’s help can be read on many systems and interfaces, from plain console mode to a PDF file (in which the math still appears as ASCII). So a loss, possibly, of typesetting elegance may be compensated by flexibility. Many users, however, will consider the slightly clunky appearance as a negative.

7 Some current Maxima projects

MaximaPHP This is a very new project, available at http://www.my-tool.com/mathematics/maximaphp/. It aims to provide access to Maxima from any web browser, without the user having to download and install Maxima first. Although it is still in early stages of development, it provides an easy way of testing out Maxima’s strengths. Figure 7 shows part of a screenshot of MaximaPHP in action. As you see, output is presented as ASCII.

Z transforms Although Maxima contains some Laplace transform functionality, the discrete counterpart, the z-transform, does not yet exist. However, a z-transform package is currently underway; it is an excellent example of Maxima’s rules and patterns usage. Here is a selection of some of the rules: defrule(r5,zt(a^(n-1),n,z),1/(z-a)); defrule(r6,zt(n^b,n,z),block([tmp:z/(z-1)], for i:1 thru b do tmp:-z*diff(tmp,z), factor(tmp))); defrule(r7,zt(sin(a*n),n,z),z*’sin(a)/((z^2-2*z*’cos(a)+1))); defrule(r8,zt(cos(a*n),n,z),z*(z-’cos(a))/(z^2-2*z*’cos(a)+1)); defrule(r9,zt(’delta(c,n),n,z),1/z^c);

Although the package is still in “pre-alpha” stage, it can be used to solve some simple difference equations. Here it is on the difference equation we solved earlier:

16 Figure 7: MaximaPHP

17 (%i77) funmake(a,[n]);a[0]:2;a[1]:0; (%i78) eq:a(n+2)-5*a(n+1)+6*a(n)-n^2; (%o78)

a (n + 2) 5 a (n + 1) + 6 a (n) n2 − − (%i79) zte:ztrans(eq,n,z); (%o79) z (z + 1) (zt (a (n) ,n,z) 2) z2 5 (zt (a (n) ,n,z) 2) z + 6 zt (a (n) ,n,z) − − (z 1) 3 − − − (%i80) s:solve(zte,zt(a(n),n,z)); (%o80)

2 z5 16 z4 + 36 z3 31 z2 + 11 z zt (a (n) ,n,z)= − − z5 8 z4 + 24 z3 34 z2 + 23 z 6 " − − − # (%i81) izt:rhs(s[1]); (%i82) invztrans(izt,z,n); (%o55) n 7 3 n (n 1) n 5 + 3 2 + − + 2 n + − 2 2 2

STACK “STACK” is the acronym for “System for Teaching and Assessment using a Computer algebra Kernel” and is the brainchild of Chris Sangwin, of the University of Birmingham. It can be seen at http://www.stack.bham.ac.uk/index.php. STACK aims to provide an online learning and assessment tool, using Maxima as its underlying mathematical “engine” in the same way that Maple TA uses Maple. A screenshot is shown in figure 8. STACK is a full-featured and mature product, and is capturing the interest of teachers world-wide. As with Maxima itself, STACK is free for download and use.

8 How good is Maxima?

Basically, we can say that it is very good at what it does, but it doesn’t have the breadth of its rivals. There is no standard benchmark for CASs, and the last major attempt to compare them dates back to 1999. However, Maxima stands up pretty well for basic mathematics, as we have seen. Here’s a simple table which sums up what we know so far (tick for “good”, cross for “bad”, empty box for “could do better”): Algebra Polynomials 2 Calculus Basic 2 Advanced 2 Linear Algebra Matrices and vectors 2 Numerical linear algebra 4 Solution of equations Polynomials 2 Other equations 2 Systems of non-linear equations 4 Graphics Simple functions 2 Data sets 2 Advanced graphics 4 Geometric figures 4 Differential equations First, second order 2 Higher order 2 Help Content 2 Appearance 4

18 Figure 8: STACK

19 9 Conclusions

Maxima is full-featured, robust and powerful software, continually being upgraded and en- hanced. It is also easy to extend. It does not have the power and breadth of Maple or Mathe- matica (yet!), but it is a very clean system, elegantly programmed, and of course available on many platforms—even, as we have seen, online. As to whether Maxima will suit your needs, the only way to find out is to test it: download it, play with it, investigate it. Over to you!

20