# Exploring Advanced Math with Maxima

When I took Calculus in college, my Professor would give us substantial partial credit for test problems that we got wrong for minor arithmetic errors, and rightfully so, too. Sometimes even simple-sounding problems resulted in a full page, or more, of calculations. Simply changing a -1 to a +1 early on in a problem could be completely devastating. Avoiding simple errors like that is what Computer Algebra Systems (CAS) are all about and I've found Maxima to be an extremely powerful CAS program.

Maxima is licensed under the GPL, so it has to be good! However, Maxima is a text based program, which means it's a bit clumsy by today's standards. Fortunately, there are a few front ends which make the program much easier to use and more polished. For this article, I'm using the wxMaxima front end.

Anyone who's taken a high school Algebra class remembers spending endless hours factoring polynomials, multiplying them together, and evaluating them for given values of x. Factoring polynomials always seemed to have an element of guess work built in, and I found it to be quite frustrating. Of course, the teacher spent weeks teaching various ways to factor these formulas, and then they finally introduced the Quadratic Equation, which made factoring second order polynomials almost trivial. For those of you who don't completely geek out over Math, a second order polynomial is one like this: ax^2 + bx + c, where the highest exponent is 2.

Manipulating polynomials with Maxima is very easy, as shown in Figure 1. Here you see 7 steps that I've asked Maxima to perform. My commands are indicated by the “%i” and a step number. The corresponding output is indicated by the “%o” and then the step number. So, (%i90) is my 90th input step and the result is on the line indicated by (%o90). So, at step 90, you see that I entered a simple polynomial equation. Then I asked Maxima to factor it. Here you see that I used a shortcut. The “%” character represents the return value of the previous step. So, when I entered “factor(%);” Maxima retrieved the previous step's value (that polynomial) and factored it. The expected result is on the next line. In step 92, I entered two polynomials multiplied by each other. As you can see, Maxima doesn't immediately do anything special with this formula. But when I asked it to expand the formula, it multiplied the two together, as you can see in step 93. At step 94, I asked Maxima to factor the resulting 4th order polynomial, and behold, we get the original equation back, as we expect. I don't think we even discussed factoring 4th order polynomials in high school Algebra! But we did a lot of evaluating polynomials at a given value of x, which I demonstrate in steps 95 and 96. In step 95, I assign a value to x. In step 96, I re-enter the polynomial, and Maxima calculates it's value at the given value of x. Figure 1. Manipulating Polynomials

Of course, Maxima can also solve equations, both symbolically, and numerically, as in Figure 2. Here we see that I've asked it to solve a quadratic equation, and it gives me the answer in symbolic form. Then I used the “numer” directive to ask Maxima to give it's answers in numerical form, which it does in step 13. Finally, I ask Maxima to use 25 digits of accuracy, instead of the default 16, and recalculate. Maxima will calculate to any degree of accuracy that you want and can handle arbitrarily large numbers. For example, Maxima can easily handle 2^200, and can even factor (2^200)-1. Figure 2. Symbolic and Numeric Manipulation

Maxima will even handle calculations that you'd never even think about doing manually. For example, you can ask Maxima to solve a 4th order polynomial equation, and it will give you all 4 solutions, both real and complex. However, in symbolic form, these solutions are often so ugly that they scroll off your screen! But, you can then turn around and ask it to give you the same answers in numerical form, to any degree of accuracy that you need.

Maxima uses either GnuPlot or Xmaxima to plot expressions and can plot 2D, 3D and parametric equations. In Figure 3, I entered a fairly complex expression, and asked Maxima to plot it on a 2D plot. In Figure 4, I took an example from Maxima's documentation and plotted a 3D image. You can rotate this image and view it from any angle you like. Figure 3. 2D Plot of an Expression Figure 4. 3D Plot of an Expression  