4.8 Interface to Maxima

Module: sage.interfaces.maxima

Maxima is a free GPL'd general purpose computer algebra system whose development started in 1968 at MIT. It contains symbolic manipulation algorithms, as well as implementations of special functions, including elliptic functions and generalized hypergeometric functions. Moreover, Maxima has implementations of many functions relating to the invariant theory of the symmetric group $ S_n$ . (However, the commands for group invariants, and the corresponding Maxima documenation, are in French.) For many links to Maxima documentation see http://maxima.sourceforge.net/docs.shtml/.

Author Log:

We evaluate a very simple expression in maxima.

sage: maxima('3 * 5')
15

We factor $ x^5 - y^5$ in Maxima in several different ways. The first way yields a Maxima object.

sage: F = maxima.factor('x^5 - y^5')
sage: F
-(y - x)*(y^4 + x*y^3 + x^2*y^2 + x^3*y + x^4)
sage: type(F)
<class 'sage.interfaces.maxima.MaximaElement'>

Note that Maxima objects can also be displayed using ``ASCII art''; to see a normal linear representation of any Maxima object x, use str(x).

sage: F.display2d()
                           4      3    2  2    3      4
               - (y - x) (y  + x y  + x  y  + x  y + x )

We can make this the default:

sage: maxima.display2d(True)
sage: F
                           4      3    2  2    3      4
               - (y - x) (y  + x y  + x  y  + x  y + x )

You can always use x.str() to obtain the linear representation of an object, even without changing the display2d flag. This can be useful for moving maxima data to other systems.

sage: F.str()
'-(y - x)*(y^4 + x*y^3 + x^2*y^2 + x^3*y + x^4)'

sage: maxima.display2d(False)
sage: F
-(y - x)*(y^4 + x*y^3 + x^2*y^2 + x^3*y + x^4)

The maxima.eval command evaluates an expression in maxima and returns the result as a string.

sage: print maxima.eval('factor(x^5 - y^5)')
-(y - x)*(y^4 + x*y^3 + x^2*y^2 + x^3*y + x^4)

We can create the polynomial $ f$ as a Maxima polynomial, then call the factor method on it. Notice that the notation f.factor() is consistent with how the rest of SAGE works.

sage: f = maxima('x^5 - y^5')
sage: f^2
(x^5 - y^5)^2
sage: f.factor()
-(y - x)*(y^4 + x*y^3 + x^2*y^2 + x^3*y + x^4)

Control-C interruption works well with the maxima interface, because of the excellent implementation of maxima. For example, try the following sum but with a much bigger range, and hit control-C.

sage: maxima('sum(1/x^2, x, 1, 10)')
1968329/1270080



Subsections
See About this document... for information on suggesting changes.