Maxima Basics

I will assume that you have added a Maths String by Selecting Strings and pressing the Add Command button and then clicking the Maths button followed by OK. If you Edit a Maths String a Text Editor will open in which the text is Syntax Highlighted.

Here I have typed a simple sum. Now press Maths, Maxima is an external program which must load and initialize so there is a short delay.

#

The original sum (called a statement, command or Line) is on the top line which now starts with a Label in brackets, (%i1), and ends with a ;. A label consists of % a letter and a number, the i means that this is an Input line, and the number 1 means it is the first. When you pressed Maths the text was checked to make sure it had a Statement Terminator at the end if not the default ; was added, then it is passed to Maxima. The editor is cleared and the output from Maxima is shown. The second line starts with (%o1) this means that it contains the output or result that line %i1 produces. The last line starts with (%i2) this is where you can type another input statement before pressing the Maxima (was Maths) button to produce more output. If this last line contains nothing when you press Maxima the current Maxima session will end and all of the output lines and labels will be removed, that is just the input lines will be copied to the Maths String being edited.
%i1Input Line
%o1Output Line
%t1Temporary or Part Output

2+2$ %*3;
----------------------
(%i1) 2+2$
(%i2) %*3;
(%o2) 12
(%i3)
You can put multiple inputs on one line, just be careful to put a space after any $ so that Czimps will not get confused. The first line above ends in a $ not a ;, this tells Maxima not to print the result. %*3 means multiply the last output by 3, even though it was not printed %i1 is still calculated. For the sake of compactness I'll leave out the %i lines below.
;Print Output
$Do not print
%Last Output
%th1Output %-n
%%Last Compound Output

x^3+1,x=2;
----------------------
(%o1) 9
x above is a Maxima Variable, it is completely internal to Maxima, it has nothing to do with Czimps Symbols and Variables apart from there names may be the same. in the above the value 2 will be substituted for x. x^3+1,x=2; is an abbreviated way of writing ev(x^3+1,x=2); which evaluates everything upto the first comma according to the conditions listed after it.
x=2Substitute

a$ b$ c$ %i1+%i2+%i3;
----------------------
(%o4) c+b+a
You can use Maxima Labels to refer to previous statements inside other statements. When Maxima processes a statement the result will not necessarily be printed in the expected order, but it will be mathematically correct.

x:3$ '(x+2-1)*(x+2);
----------------------
(%o2) 5*(x+1);
x:3 makes the Maxima Symbol or Label x stand for the expression 3, so that whenever x occurs in subsiqennt expressions 3 can be substituted. The ' prevents substitutions inside the brackets. ' can also be used to prevent the evaluation of Maxima Functions and the substitution of individual expressions for Symbols. ' does not prevent simplification, which is the first stage of Maxima processing. 'x is called a Noun form because it is just a name, x alone is a Verb form because it causes an action.
'
''

kill(all)$ L:[x+1,x+2,x+3]*x; L[1];
----------------------
(%o2) [x*(x+1),x*(x+2),x*(x+3)]
(%o3) x*(x+1)
kill(all) tells Maxima to forget previous definitions i.e. x:3 above. [] are used to contain Maxima Lists, the statements in a list are seperated by ,. If you perform a mathematical operation on a list it will be performed on each element and a new list will result. You can get individual elements from a list by using L[index] where the first element has index number 1. Lines %i2 and %i3 above could be replaced by ([x+1,x+2,x+3]*x)[1];
kill(all)All Names etc.

f(x):=1+2*x+x^2$ f([1,2,3]);
----------------------
(%o2) [4,9,16]
:= defines a function, in this case called f with one dummy parameter called x. %i2 invokes the function by replacing the dummy parameter x everywhere on the right of the definition then evaluating the resulting expression and returning the result. In this case the value passed is a list so a new list is formed by passing each item in the input list to the function and building an output list from the results. If instead of := we had used ::= a macro would have been defined. When a function is evaluated it knows nothing about values and settings in effect where it was called from. On the other hand a macro can use any such values and settings. In Maxima jargon a function is evaluated in a global context and a macro a local context.
kill$ L:[a,b,c]$ L::[1,2,3]$ a; b; c;
----------------------
(%o4) 1
(%o5) 2
(%o6) 3
:: does an element wise assignment whereas : assigns the list as a whole to L, [a,b,c]::[1,2,3] works too. In Maxima jargon both the left and right sides are evaluated by :: but only the right by :.
:Single Assign
::Multiple Assign
:=Define Function
::=Define Macro

a:1$ b:2$ c:3$ block([a,b,c],a:10,b:20,c:a+b); a; b; c;
----------------------
(%o4) 30
(%o5) 1
(%o6) 2
(%o7) 3
In a block the optional list at the start declares variables as local, that is any variable outside the block with the same name is replaced with a temporary variable, and the original replaced when the block ends. If return(value) is encountered in a block execution of it will end early and value will be returned. If go(label),...,label, is found in a block execution of statements will continue with the one after label, label can be before or after go but must be in the current block.
%%Last Compound Output
return(value)Leave
go(label)Jump to
f:lambda([x,y,z],x+y,%%+z)$ f(1,2,3);
----------------------
(%o2) 6
lambda creates an unnamed function, the list in brackets is its dummy arguments which are local, an additional final list item can be added to this list e.g lambda([x,[y,z]],...) the items in it are optional local dummy arguments. lambda() looks like a block but cannot contain go or return. %% can be used inside block or lambda, it refers to the output of the previous item in a compound statement like these. Of course % can also occur it is the result of the statement before the compound one. lambda([x,y,z],x+y+z)(1,2,3); will produce the same result but on a single line.
(...,...)Compoind Statement
block([locals],...)Block of Statements
lambda([args],...)Anonimous Function

A Maxima Expression may consist of a single Atom, an Atom is a Number, a String in quotes or a Name. An Expression is built from Atoms, Operators and/or Expressions. An expression can also be thought of as consisting of a Top Level Operator and a series of Atoms or Subexpressions called Terms, 1*a+2*b+*c has top level Operator + and Terms 1*a. 2*b and 3*c. Each term then has a Top Level Operator, all * in this example and its own Terms which are Atoms in this case. Using a series of numbers any Term or Subterm of an Expression can be identified, Term 1 is the Expression 1*a and Term 2,2 is the Atom b. Internally Maxima converts Expressions which are not Atoms into Lists which have an Operator as the first element and terms thereafter, each Term is then converted into a list if it is not an Atom, this is repeated as far as possible. The Expression above would be ["+",["*",1,a],["*",2,b],["*",3,c]], from this you can see where the Term numbers above come from. Functions are also converted into lists, sin(x+y) becomes [sin,["+",x,y]] with Term 1,1 x, the same is true for other Maxima constructs.

A:a+b+c+d; part(A,2); part(A,allbut(2,3)); part(A,[2,4]);
----------------------
(%o1) d+c+b+a
(%o2) c
(%o3) d+a
(%o4) c+a

part(expression,...) is used to extract Terms from an expression. %i2 will extract a single Term, as many numbers as needed to identify it are included in the brackets. Part 0 is the Operator. The other two examples extract one or more top level Terms. In %i3 the list in the inner brackets is of the Terms which are not required and those in %i4 are the required terms. Use length(Expression) if you need to know haow many parts there are.