Getting Started with Maxima

Maxima is a free and open-source computer program that lets you perform analytical and numerical calculations in various areas of mathematics. It’s an alternative to commercial proprietary programs for mathematical calculation (think Maple, Mathematica, and MATLAB). It can probably replace Wolfram Alpha for calculations.

Download and Install

Windows and Mac OS users should download Maxima from the site. The installation should be fairly simple.

Mac OS Users: I haven’t yet tried installing Maxima on a Mac. Please let me know if the Mac version has wxMaxima, because that will be required for the tutorials.

Fellow penguins (Linux users) should install Maxima from their distributions’ package repositories. Search for the “wxmaxima” package.

A Note About wxMaxima

All the tutorials here are for wxMaxima. The difference between Maxima and wxMaxima is that wxMaxima provides extra features (like saving calculations and nice math rendering) “on top of” Maxima. It’s included in the download for Windows, and Linux users will get it by installing the right package. I believe the download for Mac includes it as well, but I’m not sure.

Running Prewritten Programs

A .wxm file is a list of calculations to perform. You can open it up in wxMaxima and they will appear. The important thing to know here is that the calculations are not automatically performed when you open the file.

To perform the calculations and get the results, go to CellEvaluate All Cells or press Ctrl-Shift-R.

wxMaxima window with the "Cell" menu open and the "Evaluate All Cells" option highlighted

If you made any changes to the calculations, you should probably rerun them using this procedure.

Just to try this out, you can download a demo .wxm file. (This file is dedicated to the public domain, so feel free to pass it around.)

Performing Your Own Calculations

You don’t need a .wxm file to do calculations: You can just type them in (and then save them to a .wxm file if you want).

You really should read this entire section before using Maxima for your own calculations. If you go straight to the tutorials, you will get errors and be generally confused.

The Short List

Okay, if you’re just modifying another program for your own use, you don’t need to read this entire section. But you will need to know a few things:

  • Maxima is picky about multiplication. It doesn’t recognize two values next to each other as a multiplication; we always need to use an asterisk (*).
  • Maxima treats e like any other variable variable: a, b, c, d, e, f. To get the constant, we need to use %e. Similarly, we would need to use %pi and %i to get those constants.

Starting Fresh

When you first open wxMaxima (or click the “new file” button), you’ll get something like this:

wxMaxima window with a blank space in the center and different sections on both sides. Near the top of the blank space is a short horizontal line.

The blank space in the center is where you will enter your calculations. The blinking horizonal line near the top of the space indicates that is ready. Start typing and a cursor will appear:

wxMaxima window with text and a cursor in the center space

Pressing Enter will not do the calculation. You need to press Shift-Enter. If you want, you can set it to do the calculation on the Enter key (EditConfigureWorksheet section → Select “Enter evaluates cells, Ctrl+Enter adds newlines”). But if you’re doing some programming with loops, it may be better to leave it as Shift-Enter.

Let’s finish entering the calculation, in this case (x+2)^5; Every calculation should end in a semicolon, but wxMaxima will automatically add it when you hit Shift-Enter (or Enter if you set it).

Calculation with result that simply repeats the input expression

Okay, this is not very useful, but it’s a start. Most likely, we want to expand it. To do that, we can use the expand() function, along with the percent sign: expand(%); The percent sign is like the “Ans” key on a calculator: It means “take the result of the last calculation”.

Calculation with result that is the expanded version of the previous expression

If you insist, you can perform the algebraic manipulations to verify the result. But the point of Maxima is to automate that task (and reduce errors).

We can also give the expression to expand() directly and have the calculation done in one fell swoop: expand((x+2)^5);

Calculation with result that is the expanded version of the given expression

Oops, that should’ve been a 1! If you make a mistake in entering the calculation, just go back and edit the line and then press Shift-Enter to recalculate it:

Adjusted calculation on the same line with result that is the expanded version of the new expression

Let’s try some numerical calculations. What is the value of 5 times e squared? If you enter 5e^2 you’ll get an error:

Calculation with an error message reading: incorrect syntax: parser: incomplete number; missing exponent?

If you’ve read “The Short List,” you can probably tell what happened. If you didn’t, go back and read it.

Let’s fix the issues and try again, using 5*%e^2 (Maxima turns the * into a dot):

Calculation with result that simply repeats the input expression

Well, that’s correct, but not what we were looking for. Maxima does this because it likes to keep things in exact form whenever possible. This prevents rounding errors in long calculations.

(Yes, Maxima gets to put two values next to each other without the asterisk, but you don’t. But it follows the rule about the percent sign in front of the “e”. [A similar thing would happen for “pi” or “i”.])

To get a decimal form, we can use the float() function, as in float(%);:

Calculation with result of 36.94528049465326

What’s Next?

Can Maxima do calculus? Linear algebra? Graphing? The answer to all those is yes. But this here is just to get you familiar with how to enter calculations. To get started with some more advanced mathematics, go to Maxima’s documentation.

Philip Chung
Philip Chung
Software Developer