Some starting information
Maxima is case sensitive. It also executes the entire cell: if a cell contains three commands, Maxima runs all three (in order). In wxMaxima, a cell is marked by the left-hand bracket [. The active cell is shown in red (edit mode) or as a grey rectangle (selection). A cell with an error is highlighted with a red rectangle.
Running a cell: select it and press Shift + Enter.
Maxima works in input/output mode. Inputs and outputs are numbered. You can refer to them using %i... (input) and %o... (output). In practice you will mostly use % (the last output) and, when the last output is a list, %[n] (the n-th element).
Statement endings matter. Every statement must end with a terminator. Use ; to compute and print the result; use $ to compute but hide the result. Hiding intermediate outputs is often useful when you want a clean worksheet (especially in teaching).
Sometimes it is convenient to split code into several cells (for debugging or classroom pacing). But don’t overdo it: a cell is also a “logical unit” of computation, and too many tiny cells makes it harder to see the structure of a solution.
How to enter commands: you can type them, copy/paste from notes, or use the GUI menu. The GUI is fine for discovery, but for learning and reproducibility it is better to type and keep the code.
If Maxima becomes unstable, restart it: Menu → Maxima → Restart Maxima.
The beginning of the code: kill(all);
kill(all); should be at the beginning of your work. It clears Maxima’s memory.
Maxima remembers previous variable values and declarations. Without kill(all);, future calculations may silently reuse old values and produce confusing results (especially if you assigned something like x1: ... earlier).
Example 1a (problematic if re-run):
eq1: 100 = x1^2*x2^4;
solve(eq1,x1);
x1: rhs(%[2]);
If you run this two or three times, you may get unpredictable behaviour because x1 keeps the previously assigned value and starts affecting later computations.
Example 1b (recommended):
kill(all);
eq1: 100 = x1^2*x2^4;
solve(eq1,x1);
x1: rhs(%[2]);
Declaring properties
Maxima becomes much more cooperative if you tell it what your variables “are”. There are two basic commands: assume(...) declares conditions (domains/intervals) for variables (for example, a > 0), and declare(...) declares symbolic properties (for example, integer vs noninteger).
Syntax:
assume(variable > value, ...);
assume(variable < value, ...);
declare(variable1, property1, property2, ...);
Even simple assumptions like a > 0 or 0 < b can speed up Maxima, prevent procedures from getting stuck, and restrict calculations to the domain you actually care about.
Example 2a (may not finish without assumptions):
kill(all);
load(newton1);
newton(x^2 - a^2, x, a/2, a^2/100);
''(x^2 - a^2, x = %);
Example 2b (works after declaring a > 0):
assume(a > 0);
Maxima may ask interactive questions (e.g., whether a parameter is an integer). You can avoid repeated prompts by declaring properties at the start of your worksheet.
Example 3a (interactive prompt):
kill(all);
assume(x > 0);
eq1: 10 = x^a;
solve(eq1, x);
Example 3b (no prompt):
kill(all);
assume(x > 0);
declare(a, noninteger);
eq1: 10 = x^a;
solve(eq1, x);
Operators =, :, :=
Three operators look similar but do very different jobs. Use : to assign a value/expression to a variable, use = to state an equation (something you want to solve or analyse), and use := to define a function.
kill(all);
h: 3;
f1(x1,x2) := h*x1*h/2*x2;
eq1: 100 = h*x1*h/2*x2;
Substitution: ' and ''
Maxima sometimes inserts previously declared values automatically. You can control this behaviour: '' forces substitution (insert assigned values into the expression), while ' prevents substitution (keep the expression symbolic).
kill(all);
h: 3;
f1(x1,x2) := '(h*x1*h/2*x2);
eq1: 100 = '(h*x1*h/2*x2);
f1(x1,x2) := ''(h*x1*h/2*x2);
eq1: 100 = ''(h*x1*h/2*x2);
Using the last result: %
% refers to the most recently computed output. It keeps code compact and is especially useful in classroom demos, where you want to minimise naming clutter.
kill(all);
assume(x > 0);
declare(a, noninteger);
10 = x^a;
solve(%, x);
