14.2 Interface to Axiom

Module: sage.interfaces.axiom

Interface to Axiom

TODO: * Evaluation using a file is not done. Any input line with more than a few thousand characters would hang the system, so currently it automatically raises an exception. * All completions of a given command. * Interactive help.

Axiom is a free GPL-compatible (modified BSD license) general purpose computer algebra system whose development started in 1973 at IBM. It contains symbolic manipulation algorithms, as well as implementations of special functions, including elliptic functions and generalized hypergeometric functions. Moreover, Axiom has implementations of many functions relating to the invariant theory of the symmetric group $ S_n$ . For many links to Axiom documentation see http://wiki.axiom-developer.org.

Author Log:

If the string "error" (case insensitive) occurs in the output of anything from axiom, a RuntimeError exception is raised.

We evaluate a very simple expression in axiom.

sage: axiom('3 * 5')                     # optional
15
sage: a = axiom(3) * axiom(5); a         # optional
15

The type of a is AxiomElement, i.e., an element of the axiom interpreter.

sage: type(a)                            # optional
<class 'sage.interfaces.axiom.AxiomElement'>
sage: parent(a)                          # optional
Axiom

The underlying Axiom type of a is also available, via the type method:

sage: a.type()                           # optional
PositiveInteger

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

sage: F = axiom.factor('x^5 - y^5'); F      # optional
           4      3    2 2    3     4
- (y - x)(y  + x y  + x y  + x y + x )
sage: type(F)                               # optional
<class 'sage.interfaces.axiom.AxiomElement'>
sage: F.type()                              # optional
Factored Polynomial Integer

Note that Axiom objects are normally displayed using ``ASCII art''. In some cases you can see a normal linear representation of any Axiom object x, using str(x). This can be useful for moving axiom data to other systems.

sage: a = axiom('2/3'); a          # optional
2/3
sage: str(a)                       # optional
'2/3'
sage: a = axiom('x^2 + 3/7')       # optional
sage: str(a)                       # optional
'x*x+3/7'

The axiom.eval command evaluates an expression in axiom and returns the result as a string. This is exact as if we typed in the given line of code to axiom; the return value is what Axiom would print out.

sage: print axiom.eval('factor(x^5 - y^5)')   # optional
           4      3    2 2    3     4
- (y - x)(y  + x y  + x y  + x y + x )

Type: Factored Polynomial Integer

We can create the polynomial $ f$ as a Axiom 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 = axiom('x^5 - y^5')                  # optional
sage: f^2                                     # optional
y**10+(-2*x**5*y**5)+x**10
sage: f.factor()                              # optional
           4      3    2 2    3     4
- (y - x)(y  + x y  + x y  + x y + x )

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

sage:  f = axiom('(x^5 - y^5)^10000')       # not tested
Interrupting Axiom...
...
<type 'exceptions.TypeError'>: Ctrl-c pressed while running Axiom

sage: axiom('1/100 + 1/101')                  # optional
201/10100
sage: a = axiom('(1 + sqrt(2))^5'); a         # optional
     +-+
  29\|2  + 41

Module-level Functions

axiom_console( )

is_AxiomElement( x)

reduce_load_Axiom( )

Class: Axiom

class Axiom
Interface to the Axiom interpreter.
Axiom( self, [script_subdirectory=None], [logfile=None], [server=None], [server_tmpdir=None])

Create an instance of the Axiom interpreter.

Functions: completions,$ \,$ console,$ \,$ demo,$ \,$ describe,$ \,$ example,$ \,$ get,$ \,$ help,$ \,$ set

completions( self, s)

Return all commands that complete the command starting with the string s. This is like typing s[tab] in the maple interpreter.

get( self, var)

Get the string value of the Axiom variable var.

set( self, var, value)

Set the variable var to the given value.

Special Functions: __init__,$ \,$ __reduce__,$ \,$ _commands,$ \,$ _eval_line,$ \,$ _eval_line_using_file,$ \,$ _false_symbol,$ \,$ _object_class,$ \,$ _quit_string,$ \,$ _read_in_file_command,$ \,$ _start,$ \,$ _true_symbol

_commands( self)

Return list of all commands defined in Axiom.

Class: AxiomElement

class AxiomElement

Functions: comma,$ \,$ imag,$ \,$ numer,$ \,$ real,$ \,$ str,$ \,$ subst,$ \,$ type

str( self)

Get the linear string representation of this object, if possible (often it isn't).

Special Functions: __call__,$ \,$ __cmp__,$ \,$ __float__,$ \,$ __getitem__,$ \,$ __len__,$ \,$ __repr__,$ \,$ __str__,$ \,$ _latex_

__cmp__( self, other)

sage: a = axiom(1); b = axiom(2)                  # optional
sage: a == b                                      # optional
False
sage: a < b                                       # optional
True
sage: a > b                                       # optional
False
sage: b < a                                       # optional
False
sage: b > a                                       # optional
True

We can also compare more complicated object such as functions:

sage: f = axiom('sin(x)'); g = axiom('cos(x)')    # optional
sage: f == g                                      # optional
False

__getitem__( self, n)

Return the n-th element of this list.

Note: Lists are 1-based.

sage: v = axiom('[i*x^i for i in 0..5]'); v          # optional
[0,x,2*x*x,3*x**3,4*x**4,5*x**5]
sage: v[4]                                           # optional
3*x**3
sage: v[1]                                           # optional
0
sage: v[10]                                          # optional
Traceback (most recent call last):
...
IndexError: index out of range

__len__( self)

Return the length of a list.

sage: v = axiom('[x^i for i in 0..5]')            # optional
sage: len(v)                                      # optional    
6

Class: AxiomExpectFunction

class AxiomExpectFunction

Special Functions: _sage_doc_

Class: AxiomFunctionElement

class AxiomFunctionElement

Special Functions: _sage_doc_

Class: AxiomType

class AxiomType
AxiomType( self, x)

Special Functions: __init__,$ \,$ __repr__

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