411 REFERENCE · Wikibooks
Maxima/Getting Started Using Maxima
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Getting Started Using Maxima - Some Essentials
This section is intended for those that are new to Maxima. It may or may not be of value or interest to those having prior experience.
The Maxima Way of doing Mathematics
Imagine that you want to create a computer application to perform some general mathematical tasks - not merely numerical calculations or "number crunching" as it is sometimes referred to somewhat pejoratively. It seems likely that it would be realized early on that, unlike humans that can interpret concepts and notation using context, computers and programming software generally are intolerant of any sort of ambiguity. Progress is being made in providing programming software with the ability to interpret based on context, but not here in Maxima. The Maxima expression syntax was created to be logical as well as unambiguous and precise in meaning and intention.
Another realization likely would be that mathematical expressions are the essential object on which mathematical concepts hinge, and that these concepts are conveyed using a conventional (if not entirely standard) system of notation. So, the means to compose mathematical expressions using some syntax for interpreting mathematical notation that your program could read and process as input would be essential. So Maxima is not a programming language in the conventional sense.
With the foregoing in mind, before starting to see examples of Maxima in action, keep the following in mind while learning and using Maxima:
Expressions of various types (especially mathematical expressions) are the input to Maxima
Every expression returns a value which is displayed as output unless the display is suppressed by some means
Expressions as input are entered using an expression syntax that Maxima can read and process
Maxima expressions are of three types:
Mathematical expressions
Programming expressions
Object expressions
Maxima expressions are comprised of two "ingredients" so to speak:
Atoms
Operators
Atoms:
These are one type of the built-in basic expression ingredients of Maxima. They are:
Identifiers - names used alone or to identify other expressions by name
Literal numerals for numbers - integer, fraction, and floating point literals
Strings - quoted strings of one or more characters
Operators:
These are the second type of the built-in expression ingredients of Maxima. Including:
Mathematical operators such as + , - , * , /, ^ , ! for addition, subtraction, negation, multiplication, division, exponentiation, factorial and the like. Internally to Maxima these are short-hand symbols for operators. Maxima operators also include "functions" such as sin(x), log(x), etc.
Operators that are used to accomplish something other than for mathematical purposes
Note: It is important to point out that there is a difference between operators, functions as used in the context of programming, and the mathematical concept of functions. In this book all Maxima functions in the programming sense of the word that are built-in to Maxima (that is "out-of-the-box" so to speak) will be referred to as operators, including those from loaded packages that are included with the Maxima distribution. Maxima functions in the programming sense of the word created by the user will be referred to as functions. The context should make it clear when the mathematical concept of a function is being referred to. It is unfortunately the case that the Maxima documentation refers to operators as functions. Like so much else, the word "function" has become overloaded.
A Brief Introduction to Expressions - Atoms, Identifiers and Operators
Below follows a brief introduction to Maxima expressions. All Maxima expressions are composed of atoms (including identifiers) and operators, and every expression has a value.
With the foregoing information in mind, Maxima itself can be used to provide some examples of these various aspects of working with Maxima. This will be accomplished in the spirit of providing some insight and clarity for how to interact with Maxima, and how to compose expressions for input and how to interpret the values of expressions as output. What follows is not a "how-to" doe this or that mathematical task or application. It is more like an owner's manual for a vehicle. It describes the equipment and the features, but does not tell you how to drive the vehicle.
Atoms
There are three types of atoms used as "ingredients" for composing Maxima expressions for input:
Identifiers
Numerical literals for representing numbers
Strings
An elaboration of the technical details of each of these three types will follow in subsequent sections. In this section is a brief introduction, and examples of each of these types presented to gain a basic level of familiarity with each type of atom.
Identifiers
Identifiers are one type of what are termed atoms as used in the context of Maxima expressions, but they are unique in that they are the only type of atom that can be assigned an expression other than their literal value.
Identifiers as atoms are used in Maxima expressions for two main purposes:
To be unassigned an expression, and serve as a named variable
To name an expression by way of an assignment operator
Try the following using Python:
m + n>>> m + n
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'm' is not defined
>>> or using R:> m + n
Error: object 'm' not found
>or using Octave:octave:1> m + n
error: 'm' undefined near line 1, column 1
octave:2> Now, try this using Maxima:Maxima 5.49.0 https://maxima.sourceforge.io
using Lisp SBCL 2.0.1.debian
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) m + n;
(%o1) n + mTake it on faith that the identifiers m and n are in the Maxima namespace as a consequence of this expression, and that each has a value assigned by Maxima merely as a consequence of being used in the m + n input expression – m is m and n is n in this case.(%i2) m;
(%o2) m
(%i3) n;
(%o3) nA value for any identifier (other than itself) may never be assigned while using Maxima no matter how many times it is referenced. That is perfectly okay. Maxima doesn't care.
But sometimes a value is assigned to an identifier – either the first time it is referenced or after it is first referenced:(%i4) m : n;
(m) n
(%i5) m;
(%o5) n
(%i6) remvalue(m);
(%o6) [m]
(%i7) m;
(%o7) mIn the above expressions, the identifier m is assigned, using the : assignment operator, the value of identifier n (which is in this case n), and then the value of m is removed using the remvalue() operator. Thus, the value of m reverts to itself – m.
These expressions, while trivial in a sense, provide some insight into an important way Maxima behaves. When identifiers are first referenced as input, they have a value – either a value through some sort of assignment, or merely the identifier name itself. Identifiers can be assigned values by different means as part of expressions as input.
Below follows some examples of Maxima identifiers as a very brief introduction:(%i1) x; /* An unassigned identifier x */
(%o1) x
(%i2) mass; /* An unassigned identifier name of mass */
(%o2) mass
(%i3) f(x); /* An identifier f(x) for unassigned Maxima user-defined function */
(%o3) f(x)
(%i4) is(x = X); /* Identifiers are case-sensitive - x is not X */
(%o4) false
(%i6) y = x^2; /* Identifiers x and y used in an expression */
(%o6) y=x^2
(%i7) x : sqrt(2); /* Idenifier x assigned a value */
(x) sqrt(2)
/* An identifier w(x,y,z) for a Maxima user-defined function */
(%i8) w(x,w,z) := a*x^2 + b*y^2 + c*z^2;
(%o8) w(x,w,z):=a*x^2+b*y^2+c*z^2Maxima identifiers serve to name expressions as a value by means on some type of assignment, or they can be simply a name with a value of the name itself, in which case these unassigned identifiers may be considered to be variables. The technical details of Identifiers, assignment types, and expressions are elaborated upon in other book sections for each of these topics.
Numerical literals for representing numbers
There are four types of numerical literals used to compose Maxima expressions:
Integers
Fractions (for rational numbers)
Floating Point
Bigfloat (variable-precision floating point)
(%i8) 1234; /* This is an integer type. An atom */
(%o8) 1234
(%i9) 5/9; /* This is a fraction for a rational number type. Not an atom. */
(%o9) 5/9
(%i10) 3.14159; /* This is a floating point type. An atom. */
(%o10) 3.14159
(%i11) 5.532051841609784b-1; /* This is a bigfloat type. An atom */
(%o11) 5.532051841609784b-1
Strings
Strings are simply a quoted sequence of characters:
(%i12) "a string atom"; /* This is a string atom. */
(%o12) "a string atom"
(%i13) "Hello World!"; /* This is another string atom. */
(%o13) "Hello World!"
(%i14) "Supercalifagilisticexpialidocious"; /* This is a longer string atom. */
(%o14) "Supercalifagilisticexpialidocious"
(%i15) "C"; /* There is no Maxima character type. */
(%o15) "C"
Mathematical Operators
Along with atoms, Maxima operators are the second ingredient used to form expressions used as input. There are many Maxima operators. Some are used frequently as a consequence of their utility for forming mathematical expressions. Many others are used infrequently as these operators are used for specialized purposes.
+OperatorsOperator OperationNotesTypeArithmetic +additionalso unary addition prefixn-ary
infix
commutative -subtactionalso unary negation prefixbinary
infix
noncommutative*multiplicationn-ary infix
commutative/divisionor fractionbinary infix
noncommutative^exponentiationbinary postfix Relational<less thanbinary infix<=less than or equalbinary infix>greater thanbinary infix>=greater thanor equalbinary infixLogicalandandOperands are Boolean expressions
Result is a Boolean valuen-ary infix
noncommutativenotnotOperand is a Boolean expression
Result is a Boolean valueunary prefixororOperands are Boolean expressions
Result is a Boolean valuen-ary infix
noncommutativeEquations=equalityUnevaluated equation Syntactically equal#negation of syntactic equality =Unevaluated negation of an equationSyntactically not equalAssignment:assignment to left hand sideevaluates right hand side::assignment to left hand sideevaluates both sides:=function definitiondoes not evaluate right hand side::=macro function definition define ()function definitiondoes evaluate right hand side
+Elementary Mathematical Operators (Functions)Operators (Functions)
or
Option VariablesDescriptionNotesNumbersabs (z)mathematical absolute valueworks for both numerical and symbolic valuesceiling (x)returns the least integer that is greater than or equal to xentier (x)returns the largest integer less than or equal to x where x is numericfloor (x)returns the largest integer that is less than or equal to xfix (x) a synonym for entier (x)hstep (x)the Heaviside unit step functionlmax (L)when L is a list or a set, return
apply ('max, args (L))lmin (L)When L is a list or a set, return
apply ('min, args (L))max (x_1, …, x_n) returns a simplified value for the numerical maximum of the expressions x_1 through x_nmin (x_1, …, x_n)returns a simplified value for the numerical minimum of the expressions x_1 through x_n.round (x)when x is a real number, returns the closest integer to xsignum (x)for either real or complex numbers x, the signum function returns 0 if x is zero; for a nonzero numeric input x, the signum function returns x/abs(x)truncate (x)when x is a real number, return the closest integer to x not greater in absolute value than xComplex
Numberscabs (expr)returns the absolute value of an expression representing a complex numbercarg (z)returns the complex argument of zconjugate (x)returns the complex conjugate of ximagpart (expr)returns the imaginary part of the expression exprpolarform (expr)returns an expression r %e^(%i theta) equivalent to expr, such that r and theta are purely realrealpart (expr)returns the real part of exprrectform (expr)returns an expression a + b %i equivalent to expr, such that a and b are purely realCombinatorial!!the double factorial operatorbinomial (x, y)returns the binomial coefficient x!/(y! (x - y)!).factcomb (expr)tries to combine the coefficients of factorials in expr with the factorials themselves by converting for example, (n + 1)*n! into (n + 1)!.factorial (x)
!returns the factorial of xfactorial (x) the same as x!factlimspecifies the highest factorial which is automatically expandedoption variable
default: 100000factorial_expandcontrols the simplification of expressions like (x+n)!, where n is an integeroption variable
default: falsegenfact (x, y, z)returns the generalized factorial, defined as x (x-z) (x - 2 z) ... (x - (y - 1) z)when x is an integer, genfact (x, x, 1) = x! and genfact (x, x/2, 2) = x!!minfactorial (expr)examines expr for occurrences of two factorials which differ by an integerminfactorialthen turns one into a polynomial times the othersumsplitfactwhen sumsplitfact is false, minfactorial is applied after a factcomboption variable
default: trueRoot
Exponential
Logarithmic%e_to_numlogwhen true, r some rational number, and x some expression, %e^(r*log(x)) will be simplified into x^roption variable
default: false%emodewhen %emode is true, %e^(%pi %i x) is simplifiedoption variable
default: true%enumerwhen %enumer is true, %e is replaced by its numeric value 2.718… whenever numer is true.option variable
default: falseexp (x)represents the exponential functionli [s] (z)represents the polylogarithm function of order s and argument z, defined by an infinite series log (x)represents the natural (base ) logarithm of x.Maxima does not have a built-in function for the base 10 logarithm or other baseslogabswhen doing indefinite integration where logs are generated, e.g. integrate(1/x,x), the answer is given in terms of log(abs(...)) if logabs is true, but in terms of log(...)if logabs is false
for definite integration, the logabs:true setting is used, because here "evaluation" of the indefinite integral at the endpoints is often neededoption variable
default: falselogarc (expr)carries out the replacement of inverse circular and hyperbolic functions with equivalent logarithmic functions for an expression expr without setting the global variable logarc logarcwhen the global variable logarc is true, inverse circular and hyperbolic functions are replaced by equivalent logarithmic functions.option variable
default: falselogconcoeffpcontrols which coefficients are contracted when using logcontractoption variable
default: falselogcontract (expr)recursively scans the expression expr, transforming subexpressions of the form a1*log(b1) + a2*log(b2) + c into log(ratsimp(b1^a1 * b2^a2)) + clogexpandif true, that is the default value, causes log(a^b) to become b*log(a)
If it is set to all, log(a*b) will also simplify to log(a)+log(b)
If it is set to super, then log(a/b)will also simplify to log(a)-log(b) for rational numbers a/b, a#1(log(1/b), for integer b, always simplifies.)
if it is set to false, all of these simplifications will be turned offoption variable
default: truelognegintimplements the rule log(-n) -> log(n)+%i*%pi for n a positive integer if true option variable
default: falselogsimpif false then no simplification of %e to a power containing log is doneoption variable
default: true plog (x)represents the principal branch of the complex-valued natural logarithm with -%pi < carg(x) <= +%pi sqrt (x) the square root of x. It is represented internally by x^(1/2)Trigonometric
Hyperbolicacos (x)arc cosineacosh (x)hyperbolic arc cosineacot (x)arc cotangentacoth (x)hyperbolic arc cotangent. acsc (x)arc cosecantacsch (x)hyperbolic arc cosecant asec (x)arc secant.asech (x)hyperbolic arc secantasin (x)arc sineasinh (x)hyperbolic arc sineatan (x)arc tangentatan2 (y, x)returns the value of in the interval taking into consideration the quadrant of the point (x,y)atanh (x)hyperbolic arc tangentcos (x)cosinecosh (x)hyperbolic cosinecot (x)cotangentcoth (x)hyperbolic cotangentcsc (x)cosecant csch (x)hyperbolic cosecantsec (x)secantsech (x)hyperbolic secantsin (x)sinesinh (x Otan (x)tangenttanh (x)hyperbolic tangentRandom
Numbersmake_random_state ()a random state object represents the state of the random number generatorset_random_state (s)copies s to the random number generator staterandom (x) returns a pseudorandom number
Maxima Expressions
For the purpose of review, Maxima expressions are of three types:
Mathematical expressions
Object expressions
Programming expressions
Object expressions and programming expressions are for use in support of the intended purpose of Maxima – a computer algebra system. Mathematical expressions are those that are the essential type for doing mathematics using Maxima.
Mathematical Expressions
Mathematical expressions consist of atoms and operators that are of a mathematical nature. Mathematical expressions can be simple to relatively complex. It is helpful to understand the anatomy of Maxima expressions in terms of atoms and operators. Some expressions can consist of a single atom, but more likely it will be the case that expressions will be comprised of atoms and operators.
The simplest expressions can consists of a single atom:(%i1) 5; /* an integer atom */
(%o1) 5
(%i2) 3.14159; /* a floating point atom */
(%o2) 3.14159
(%i3) 77.3987483627298298277627928389828329382983b0; /* a bigfloat atom */
(%o3) 7.739874836272983b1
(%i4) x; /* an unassigned identifier atom */
(%o4) xAtoms are "self-evaluating" in the sense that they return themselves as values. Expressions such as these are not very useful, but they are the simplest example of mathematical expressions.
Fractions for literal rational numbers are simple expressions entered as follows, but are not atoms:(%i5) 12/33; /* A fraction expression. Maxima simplfies the expression as output */
(%o5) 4/11
(%i6) atom(12/33); /* The fraction expression is not an atom */
(%o6) false
(%i8) op(12/33); /* The overall operation of this expression is / */
(%o8) /In cases where Maxima returns an error message or the returned results are unexpected or perplexing, the atom () and op () operators may provide some insight into the nature of the error message or returned value.
Maxima evaluates the division of integers as rational numbers, and simplifies the return value if possible:(%i09) 12/33 * 3/4; /* multiplication of fractions */
(%o09) 3/11
(%i10) (12/33) / (4/3); /* division of fractions */
(%o10) 3/11
(%i11) 3/8 + 13/4; /* addition of fractions */
(%o11) 29/8Maxima will resolve mixed numerical types in expressions as returned values in a manner which might be expected :(%i12) 3/2 * 5; /* fraction and an integer */
(%o12) 15/2
(%i13) 3/2 * 5.0; /* fraction and floating point */
(%o13) 7.5
(%i14) 12.0/33; /* floating point and an integer */
(%o14) 0.36363636363636365
(%i15) 0.36363636363636365*0.36363636363636365b0; /* floating point and bigfloat */
(%o15) 1.322314049586777b-1Some expressions remain "symbolic" numerically, and are not simplified or returned as a number type:(%i16) sqrt(2); /* an algebraic irrational */
(%o16) sqrt(2)
(%i17) 3*5^(1/3); /* another algebraic irratioanl */
(%o17) 3*5^(1/3)Built-in numerical constants are atoms. Numerical expressions involving one or more operators are not, unless the expression evaluates to an atom:(%i18) %pi; /* a trancendental built-in constant */
(%o18) %pi
(%i20) atom(%pi); /* a trancendental built-in constant */
(%o20) true
(%i20) atom(%e); /* a trancendental built-in constant */
(%o20) true
(%i21) atom(%i); /* i is a built-in constant */
(%o21) true
(%i22) atom(sqrt(2)); /* sqrt(2) in not an atom */
(%o22) false
(%i23) atom(3*5^(1/3)); /* 3*5^(1/3) is not an atom */
(%o23) false
(%i24) atom(3+5); /* 3+5 evaluates to 8 which is an atom*/
(%o24) true
(%i25) atom((5^2)*3.14159); /* (5^2)*3.14159) evaluates to 78.53975 which is an atom */
(%o25) trueAn important point to understand is that expressions when evaluated may have a return value that is an atom or is not an atom:(%i26) atom(3+5); /* the value of 3+5 is an atom */
(%o26) true
(%i27) atom(5^2)*3.14159 /* the value of this expression is an atom */
(%o27) true
(%i28) (5^2)*3.14159; /* it is a floating point numeral */
(%o28) 78.53975
(%i29) op(3+5); /* an error as the value is an atom */
part: argument must be a non-atomic expression; found 8
-- an error. To debug this try: debugmode(true);More useful and interesting expressions involve identifiers, However, expressions involving identifiers and operators may or may not have a value that is atomic:(%i30) atom(z); /* the value of z is z - an atom */
(%o30) true
(%i31) atom(3); /* 3 is an atom */
(%o31) true
(%i32) atom(z+3); /* the value of z+3 is z+3 - not an atom */
(%o32) false
(%i33) op(z+3); /* the overall operator of z+3 is + */
(%o33) +
(%i34) z:5; /* assign 5 to z */
(z) 5
(%i35) atom(z+3); /* the value of z+5 is 8 - an atom */
(%o35) trueThese examples may seem simple, but what is exemplified by these simple expressions applies no matter how complex the expression may be:(%i36) expr1:(1/(15^2 + 20^2 -2*15*20*cos(%pi/3))^(1/2)); /* an expression */
(expr1) 1/(5*sqrt(13))
(%i37) atom(expr1); /* the value of expr1 is not an atom */
(%o37) false
(%i38) float(expr1); /* the value of expr1 as a floating point numeral is an atom */
(%o38) 0.05547001962252292
(%i39) atom(float(expr1)); /* an atom */
(%o39) true
(%i40) expr2:integrate(w^2, w, 0, 4); /* the value of this integration is an not an atom */
(expr2) 64/3
(%i41) atom(expr2); /* not an atom */
(%o41) false
(%i42) op(expr2); /* teh overall operator of 64/3 is / */
(%o42) /
(%i43) atom('integrate(w^2, w, 0, 4)); /* the value of this integration is an not an atom */
(%o43) false
(%i44) op('integrate(w^2, w, 0, 4)); /* the overall operation is integrate */
(%o44) integrate
(%i45) 2*s^2+5*s+1; /* a quadratic expression */
(%o45) 2*s^2+5*s+1
(%i46) solve(2*s^2+5*s+1,s); /* solve for s */
(%o46) [s=-((sqrt(17)+5)/4),s=(sqrt(17)-5)/4]
(%i47) rhs(solve(2*s^2+5*s+1,s)[1]); /* reference the right hand side */
(%o47) -((sqrt(17)+5)/4)
(%i48) atom(rhs(solve(2*s^2+5*s+1,s)[1])); /* teh value of the RHS is not an atom */
(%o48) false
(%i49) ans:float(rhs(solve(2*s^2+5*s+1,s)[1])); /* the floating point value is an atom */
(ans) -2.2807764064044154
(%i50) atom(ans);
(%o50) true
The Maxima REPL
Maxima is most useful as an interactive computer algebra system program. The means of interaction is primarily by using the Maxima REPL – which is an abbreviation for Read, Evaluate, Print, Loop. But "REPL" doesn't encapsulate all that is happening to Maxima expressions while using the user interface. The Maxima REPL is more of a "RCESDL" process:
R – read
C – construct
E – evaluate
S – simplify
D – display
L – loop
Maxima reads, constructs, evaluates, and simplifies expressions, and then displays return values and "loops" by displaying the next input prompt. Each of these (except looping) may be viewed as a layer of manipulation Maxima applies to expressions.
The next subsection describes expression reading and construction. Evaluation and simplification of expressions are described in subsections that follow. For now, consider evaluation to be the substitution of the value of an expression for the expression. Simplification is the application of a set of criteria defining what "simpler" means as a relation between expressions so that an equivalent "simplified" expression is substituted for an evaluated expression.
Expression Reading and Construction
Maxima will read lines of input and parse each one in order to determine if it is an expression that can be constructed for evaluation.
Maxima allows a sequence of expressions to be entered into an single expression by separating them by commas and putting parentheses around them:/* An example of a sequence of expressions enclosed in parentheses.
Only the value of the last expression (y) in the sequence is returned and displayed.
*/
/* The expression below is composed of three nested expression groupings in parentheses.
This expression as a whole is mathematical in that its value is an integer literal
*/
(%i51) (y : (x : 1, for i from 1 thru 10 do (x : x*i), x),y);
(%o51) 3628800
/* The value of this expression is an atom */
(%i52) atom((y : (x : 1, for i from 1 thru 9 do (x : x*i), x),y));
(%o52) true
/* The constructed expression is not a atom as evaluation is suppressed */
(%i53) atom('(y : (x : 1, for i from 1 thru 9 do (x : x*i), x),y));
(%o53) false
/* The overall operation of this expression is ( */
(%i53) op('(y : (x : 1, for i from 1 thru 9 do (x : x*i), x),y));
(%o53) (Let's take a look at some constructed expressions:(%i54) 'for i from 1 thru 9 do (x: x*i); /* a constructed expression */
(%o54) mdo(i,1,false,false,9,false,i)
(%i55) if p > q then p else q$ /* an expression */
(%i56) 'if p > q then p else q; /* the same expression as constructed */
(%o56) mcond(p>q,p,true,q)An expression as input is first read and parsed before being constructed. If the parser can construct an expression from the input, the constructed expression may then be evaluated, may be in turn simplified and may be finally displayed. However, the parser may or may not be able to construct an expression for various reasons, without displaying a warning or error message:/* the Maxima parser does not like this expression */
(%i57) ([a], a: 42, a^2 - 1600);
warning: parser: I'll let it stand, but (...) doesn't recognize local variables.
warning: parser: did you mean to say: block([a], ...) ?
(%o57) 164The parser let this expression go through to complete the process and display a return value, but not without a warning, and a suggestion. In other cases however the parser will display an error message:/* this is a syntax error - missing closing parenthesis */
(%i58) (y: (x: 1, for i from 1 thru 9 do (x: x*i), x),y;
incorrect syntax: Missing )
9 do (x: x*i), x),y;
^The parser can't construct an expression in cases where there is a syntax error. Nothing is evaluated. There is no returned value. In cases where an input expression can read and an expression can be constructed by the parser, the constructed expression may then be evaluated.
Expression Evaluation
The reading, parsing, evaluation,, simplification, and display of values are all steps in a process that, from the point of view of users, typically happens "under the hood" so to speak. It is helpful in using Maxima to have at least a familiarity with this process, while it is true that most often not much thought is given to these steps – until something unexpected results or there is an error.
However, the familiarity with the steps of this process can be put to use intentionally for practical purposes while using Maxima. For the purposes of this section of the book, it suffices to here provide a descriptive familiarity with the evaluation of expressions here, leaving the technical details for a subsequent section of this book.
All or parts of a constructed expression may or may not be evaluated for various reasons, upon which the technical details are not elaborated here. When evaluation does occur, it is essentially the composition of an expression from the constructed expression wherein the values of the atoms and operators along with their arguments are used.
Expression Simplification
To whatever extent evaluation of a constructed expression may occur, the resulting expression may or may not be simplified, again for reasons upon which the technical details are not elaborated here. A section of this book is provided to elaborate on the technical details of simplification.
There is a sense in which simplification implies a relation between expressions – " A is simpler than B" or something like that. In any case, simplification implies a set of criteria that is necessary to determine expressions which are simpler. Maxima provides a set of criteria for the purpose of simplifying expressions insofar as is possible. Whenever possible, constructed or evaluated expressions will be simplified, and the resulting simplified expression may be displayed as output.
Return Value Display
Typically, Maxima input expressions end with a semicolon ( ; ) character. In these cases, Maxima will display a return value as output unless an error occurs. The display of the output value can be suppressed by ending the input expression with a dollar sign character ( $ ) instead of a semicolon:/* the value of this expression is done */
(%i59) (x : 1, for i from 10 thru 2 step -2 do (x : x/i));
(%o59) done
(%i60) x; /* a value for x was calculated by the above expression */
(%o60) 1/3840
/* the dollar sign ( $ ) suppresses the display of done */
(%i61) (x : 1, for i from 20 thru 2 step -2 do (x : x/i))$
/* the output of done was returned, but the display was suppressed */
(%i62) %;
(%o62) done
(%i63) x; /* a different value for x was calculated by the above expression */
(%o63) 1/3715891200
Programming Expressions
Maxima was created as a CAS application using the Lisp programming language. It is evident given the perspective experienced using Maxima, that there is some "Lispiness" evident in its use. But, while Lisp is a programming language, the programming expressions that are provided by Maxima are intended to be used in support of the purpose of Maxima as a CAS. There is much that can be accomplished using Maxima programming expressions, but it should be recognized that there are limitations in this context.
A savvy and adept programmer type of person may likely be able to be somewhat creative using Maxima programming expressions, but for the typical user, these expressions are essentially used to support mathematical tasks. Some may find that Maxima programming expressions provide a reasonably complete programming language for their purposes. Other users may find that for their purposes Maxima programming expressions impose some inconvenient or awkward limitations.
There are tools available to convert or translate Maxima expressions to the code of other programming languages – FORTRAN, RATFOR, C, Python 3, and Julia as examples. But these tools may require specialized knowledge and resources to use, and using them can be tedious for some users. For those users that wish to do more in terms of programming within (or outside of for that matter) the Maxima interactive environment, and are willing to use or learn Lisp, using Lisp itself can be a useful option. Lisp is a complete general programming language. A subsequent section of this book (Maxima and Lisp) is provided for those that have an interest in this option.
Some of the foregoing examples have included programming expressions used to return a mathematical result. This book presumes that Maxima programming expressions are intended to be used in support of mathematical tasks. A subsequent section of this book provides the technical details of Maxima programming expressions for this purpose.
Object Expressions
Maxima provides several object types. These objects are created by object expressions. The value of an object may be the name of the object or refer to the data the object encapsulates depending on the type of object. Like other expressions, object expression are comprised of an operator and its arguments. The most important built-in object types are:
lists
arrays (of which there are three types)
structures
matrices
sets
Maxima list objects will likely be the most frequently encountered type of object while using Maxima expressions in general both during expression composition for input and as displayed expression results. Matrices and sets are likely to be mostly associated directly with mathematical expressions. Arrays and structures are relatively specialized object types that are most likely to be used in support of mathematical tasks and applications. This book presumes that Maxima object expressions are intended to be used in support of mathematical tasks. A subsequent section of this book provides the technical details of Maxima object expressions for this purpose.
"Maxima's current array/matrix semantics are a mess, I must say, with at least four different kinds of objects (hasharrays, explicit lists, explicit matrices, Lisp arrays) supporting subscripting with varying semantics." [1]
"Maxima's concept of arrays, lists, and matrices is pretty confused, since various ideas have accreted in the many years of the project... Yes, this is a mess. Sorry about that. These are all interesting ideas, but there is no unifying framework. " [2]
[1] Maxima: Syntax improvements by Stavros Macrakis
[2] Maxima: what does Maxima call an “array”? - answer by Robert Dodier