### Navigation

- index
- modules |
- next |
- previous |
- Interpreter Interfaces »

# Library interface to 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 documentation, are in French.) For many links to Maxima documentation, see http://maxima.sourceforge.net/documentation.html.

AUTHORS:

- William Stein (2005-12): Initial version
- David Joyner: Improved documentation
- William Stein (2006-01-08): Fixed bug in parsing
- William Stein (2006-02-22): comparisons (following suggestion of David Joyner)
- William Stein (2006-02-24): greatly improved robustness by adding sequence numbers to IO bracketing in _eval_line
- Robert Bradshaw, Nils Bruin, Jean-Pierre Flori (2010,2011): Binary library interface

For this interface, Maxima is loaded into ECL which is itself loaded as a C library in Sage. Translations between Sage and Maxima objects (which are nothing but wrappers to ECL objects) is made as much as possible directly, but falls back to the string based conversion used by the classical Maxima Pexpect interface in case no new implementation has been made.

This interface is the one used for calculus by Sage and is accessible as \(maxima_calculus\):

    sage: maxima_calculus
    Maxima_lib

Only one instance of this interface can be instantiated, so the user should not try to instantiate another one, which is anyway set to raise an error:

    sage: from sage.interfaces.maxima_lib import MaximaLib
    sage: MaximaLib()
    Traceback (most recent call last):
    ...
    RuntimeError: Maxima interface in library mode can only be instantiated once

class `sage.interfaces.maxima_lib.``MaximaLib`

  Bases: `sage.interfaces.maxima_abstract.MaximaAbstract`

  Interface to Maxima as a Library.

  INPUT: none

  OUTPUT: Maxima interface as a Library

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import MaximaLib, maxima_lib
      sage: isinstance(maxima_lib,MaximaLib)
      True

  Only one such interface can be instantiated:

      sage: MaximaLib()
      Traceback (most recent call last):
      ...
      RuntimeError: Maxima interface in library mode can only
      be instantiated once

  `clear`(var)

    Clear the variable named var.

    INPUT:

    - `var` - string

    OUTPUT: none

    EXAMPLES:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: maxima_lib.set('xxxxx', '2')
        sage: maxima_lib.get('xxxxx')
        '2'
        sage: maxima_lib.clear('xxxxx')
        sage: maxima_lib.get('xxxxx')
        'xxxxx'

  `eval`(line, locals=None, reformat=True, **kwds)

    Evaluate the line in Maxima.

    INPUT:

    - `line` - string; text to evaluate
    - `locals` - None (ignored); this is used for compatibility with the Sage notebook’s generic system interface.
    - `reformat` - boolean; whether to strip output or not
    - `**kwds` - All other arguments are currently ignored.

    OUTPUT: string representing Maxima output

    EXAMPLES:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: maxima_lib._eval_line('1+1')
        '2'
        sage: maxima_lib._eval_line('1+1;')
        '2'
        sage: maxima_lib._eval_line('1+1$')
        ''
        sage: maxima_lib._eval_line('randvar : cos(x)+sin(y)$')
        ''
        sage: maxima_lib._eval_line('randvar')
        'sin(y)+cos(x)'

  `get`(var)

    Get the string value of the variable `var`.

    INPUT:

    - `var` - string

    OUTPUT: string

    EXAMPLES:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: maxima_lib.set('xxxxx', '2')
        sage: maxima_lib.get('xxxxx')
        '2'

  `lisp`(cmd)

    Send a lisp command to maxima.

    INPUT:

    - `cmd` - string

    OUTPUT: ECL object

    Note

    The output of this command is very raw - not pretty.

    EXAMPLES:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: maxima_lib.lisp("(+ 2 17)")
        <ECL: 19>

  `set`(var, value)

    Set the variable var to the given value.

    INPUT:

    - `var` - string
    - `value` - string

    OUTPUT: none

    EXAMPLES:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: maxima_lib.set('xxxxx', '2')
        sage: maxima_lib.get('xxxxx')
        '2'

  `sr_integral`(*args)

    Helper function to wrap calculus use of Maxima’s integration.

    TESTS:

        sage: a,b=var('a,b')
        sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x)
        Traceback (most recent call last):
        ...
        ValueError: Computation failed since Maxima requested additional
        constraints; using the 'assume' command before evaluation
        *may* help (example of legal syntax is 'assume(a>0)', see
        `assume?` for more details)
        Is a positive or negative?
        sage: assume(a>0)
        sage: integrate(1/(x^3 *(a+b*x)^(1/3)),x)
        2/9*sqrt(3)*b^2*arctan(1/3*sqrt(3)*(2*(b*x + a)^(1/3) + a^(1/3))/a^(1/3))/a^(7/3) - 1/9*b^2*log((b*x + a)^(2/3) + (b*x + a)^(1/3)*a^(1/3) + a^(2/3))/a^(7/3) + 2/9*b^2*log((b*x + a)^(1/3) - a^(1/3))/a^(7/3) + 1/6*(4*(b*x + a)^(5/3)*b^2 - 7*(b*x + a)^(2/3)*a*b^2)/((b*x + a)^2*a^2 - 2*(b*x + a)*a^3 + a^4)
        sage: var('x, n')
        (x, n)
        sage: integral(x^n,x)
        Traceback (most recent call last):
        ...
        ValueError: Computation failed since Maxima requested additional
        constraints; using the 'assume' command before evaluation
        *may* help (example of legal syntax is 'assume(n>0)',
        see `assume?` for more details)
        Is n equal to -1?
        sage: assume(n+1>0)
        sage: integral(x^n,x)
        x^(n + 1)/(n + 1)
        sage: forget()
        sage: assumptions()  # Check the assumptions really were forgotten
        []

    Make sure the abs_integrate package is being used, trac ticket #11483. The following are examples from the Maxima abs_integrate documentation:

        sage: integrate(abs(x), x)
        1/2*x*abs(x)

        sage: integrate(sgn(x) - sgn(1-x), x)
        abs(x - 1) + abs(x)

        sage: integrate(1 / (1 + abs(x-5)), x, -5, 6)
        log(11) + log(2)

        sage: integrate(1/(1 + abs(x)), x)
        1/2*(log(x + 1) + log(-x + 1))*sgn(x) + 1/2*log(x + 1) - 1/2*log(-x + 1)

        sage: integrate(cos(x + abs(x)), x)
        -1/2*x*sgn(x) + 1/4*(sgn(x) + 1)*sin(2*x) + 1/2*x

    The last example relies on the following simplification:

        sage: maxima("realpart(signum(x))")
        signum(x)

    An example from sage-support thread e641001f8b8d1129:

        sage: f = e^(-x^2/2)/sqrt(2*pi) * sgn(x-1)
        sage: integrate(f, x, -Infinity, Infinity)
        -erf(1/2*sqrt(2))

    From trac ticket #8624:

        sage: integral(abs(cos(x))*sin(x),(x,pi/2,pi))
        1/2

        sage: integrate(sqrt(x + sqrt(x)), x).simplify_radical()
        1/12*((8*x - 3)*x^(1/4) + 2*x^(3/4))*sqrt(sqrt(x) + 1) + 1/8*log(sqrt(sqrt(x) + 1) + x^(1/4)) - 1/8*log(sqrt(sqrt(x) + 1) - x^(1/4))

    And trac ticket #11594:

        sage: integrate(abs(x^2 - 1), x, -2, 2)
        4

    This definite integral returned zero (incorrectly) in at least Maxima 5.23. The correct answer is now given (trac ticket #11591):

        sage: f = (x^2)*exp(x) / (1+exp(x))^2
        sage: integrate(f, (x, -infinity, infinity))
        1/3*pi^2

    Sometimes one needs different simplification settings, such as `radexpand`, to compute an integral (see trac ticket #10955):

        sage: f = sqrt(x + 1/x^2)
        sage: maxima = sage.calculus.calculus.maxima
        sage: maxima('radexpand')
        true
        sage: integrate(f, x)
        integrate(sqrt(x + 1/x^2), x)
        sage: maxima('radexpand: all')
        all
        sage: g = integrate(f, x); g
        2/3*sqrt(x^3 + 1) - 1/3*log(sqrt(x^3 + 1) + 1) + 1/3*log(sqrt(x^3 + 1) - 1)
        sage: (f - g.diff(x)).simplify_radical()
        0
        sage: maxima('radexpand: true')
        true

    The following integral was computed incorrectly in versions of Maxima before 5.27 (see trac ticket #12947):

        sage: a = integrate(x*cos(x^3),(x,0,1/2)).n()
        sage: a.real()
        0.124756040961038
        sage: a.imag().abs() < 3e-17
        True

  `sr_limit`(expr, v, a, dir=None)

    Helper function to wrap calculus use of Maxima’s limits.

    TESTS:

        sage: f = (1+1/x)^x
        sage: limit(f,x = oo)
        e
        sage: limit(f,x = 5)
        7776/3125
        sage: limit(f,x = 1.2)
        2.06961575467...
        sage: var('a')
        a
        sage: limit(x^a,x=0)
        Traceback (most recent call last):
        ...
        ValueError: Computation failed since Maxima requested additional
        constraints; using the 'assume' command before evaluation
        *may* help (example of legal syntax is 'assume(a>0)', see `assume?`
        for more details)
        Is a positive, negative or zero?
        sage: assume(a>0)
        sage: limit(x^a,x=0)
        Traceback (most recent call last):
        ...
        ValueError: Computation failed ...
        Is a an integer?
        sage: assume(a,'integer')
        sage: assume(a,'even')  # Yes, Maxima will ask this too
        sage: limit(x^a,x=0)
        0
        sage: forget()
        sage: assumptions() # check the assumptions were really forgotten
        []

    The second limit below was computed incorrectly prior to Maxima 5.24 (trac ticket #10868):

        sage: f(n) = 2 + 1/factorial(n)
        sage: limit(f(n), n=infinity)
        2
        sage: limit(1/f(n), n=infinity)
        1/2

    The limit below was computed incorrectly prior to Maxima 5.30 (see trac ticket #13526):

        sage: n = var('n')
        sage: l = (3^n + (-2)^n) / (3^(n+1) + (-2)^(n+1))
        sage: l.limit(n=oo)
        1/3

    The following limit computation used to incorrectly return 0 or infinity, depending on the domain (see trac ticket #15033):

        sage: m = sage.calculus.calculus.maxima
        sage: _ = m.eval('domain: real')   # much faster than 'domain: complex'
        sage: limit(gamma(x + 1/2)/(sqrt(x)*gamma(x)), x=infinity)
        1
        sage: _ = m.eval('domain: complex')

  `sr_sum`(*args)

    Helper function to wrap calculus use of Maxima’s summation.

    TESTS:

    Check that trac ticket #16224 is fixed:

        sage: k = var('k')
        sage: sum(x^(2*k)/factorial(2*k), k, 0, oo).simplify_radical()
        cosh(x)

        sage: x, y, k, n = var('x, y, k, n')
        sage: sum(binomial(n,k) * x^k * y^(n-k), k, 0, n)
        (x + y)^n
        sage: q, a = var('q, a')
        sage: sum(a*q^k, k, 0, oo)
        Traceback (most recent call last):
        ...
        ValueError: Computation failed since Maxima requested additional
        constraints; using the 'assume' command before evaluation *may* help
        (example of legal syntax is 'assume(abs(q)-1>0)', see `assume?`
        for more details)
        Is abs(q)-1 positive, negative or zero?
        sage: assume(q > 1)
        sage: sum(a*q^k, k, 0, oo)
        Traceback (most recent call last):
        ...
        ValueError: Sum is divergent.
        sage: forget()
        sage: assume(abs(q) < 1)
        sage: sum(a*q^k, k, 0, oo)
        -a/(q - 1)
        sage: forget()
        sage: assumptions() # check the assumptions were really forgotten
        []

    Taking the sum of all natural numbers informs us that the sum is divergent. Maxima (before 5.29.1) used to ask questions about \(m\), leading to a different error (see trac ticket #11990):

        sage: m = var('m')
        sage: sum(m, m, 0, infinity)
        Traceback (most recent call last):
        ...
        ValueError: Sum is divergent.

    An error with an infinite sum in Maxima (before 5.30.0, see trac ticket #13712):

        sage: n = var('n')
        sage: sum(1/((2*n-1)^2*(2*n+1)^2*(2*n+3)^2), n, 0, oo)
        3/256*pi^2

    Maxima correctly detects division by zero in a symbolic sum (see trac ticket #11894):

        sage: sum(1/(m^4 + 2*m^3 + 3*m^2 + 2*m)^2, m, 0, infinity)
        Traceback (most recent call last):
        ...
        RuntimeError: ECL says: Error executing code in Maxima: Zero to negative power computed.

    Similar situation for trac ticket #12410:

        sage: x = var('x')
        sage: sum(1/x*(-1)^x, x, 0, oo)
        Traceback (most recent call last):
        ...
        RuntimeError: ECL says: Error executing code in Maxima: Zero to negative power computed.

  `sr_tlimit`(expr, v, a, dir=None)

    Helper function to wrap calculus use of Maxima’s Taylor series limits.

    TESTS:

        sage: f = (1+1/x)^x
        sage: limit(f, x = I, taylor=True)
        (-I + 1)^I

class `sage.interfaces.maxima_lib.``MaximaLibElement`(parent, value, is_name=False, name=None)

  Bases: `sage.interfaces.maxima_abstract.MaximaAbstractElement`

  Element of Maxima through library interface.

  EXAMPLES:

  Elements of this class should not be created directly. The targeted parent should be used instead:

      sage: from sage.interfaces.maxima_lib import maxima_lib
      sage: maxima_lib(4)
      4
      sage: maxima_lib(log(x))
      log(_SAGE_VAR_x)

  `display2d`(onscreen=True)

    Return the 2d representation of this Maxima object.

    INPUT:

    - `onscreen` - boolean (default: True); whether to print or return

    OUTPUT:

    The representation is printed if onscreen is set to True and returned as a string otherwise.

    EXAMPLES:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: F = maxima_lib('x^5 - y^5').factor()
        sage: F.display2d()
                               4      3    2  2    3      4
                   - (y - x) (y  + x y  + x  y  + x  y + x )

  `ecl`()

    Return the underlying ECL object of this MaximaLib object.

    INPUT: none

    OUTPUT: ECL object

    EXAMPLES:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: maxima_lib(x+cos(19)).ecl()
        <ECL: ((MPLUS SIMP) ((%COS SIMP) 19) |$_SAGE_VAR_x|)>

  `to_poly_solve`(vars, options='')

    Use Maxima’s to_poly_solver package.

    INPUT:

    - `vars` - symbolic expressions
    - `options` - string (default=””)

    OUTPUT: Maxima object

    EXAMPLES:

    The zXXX below are names for arbitrary integers and subject to change:

        sage: from sage.interfaces.maxima_lib import maxima_lib
        sage: sol = maxima_lib(sin(x) == 0).to_poly_solve(x)
        sage: sol.sage()
        [[x == pi*z54]]

class `sage.interfaces.maxima_lib.``MaximaLibElementFunction`(parent, name, defn, args, latex)

  Bases: `sage.interfaces.maxima_lib.MaximaLibElement`, `sage.interfaces.maxima_abstract.MaximaAbstractElementFunction`

  Create a Maxima function. See `MaximaAbstractElementFunction` for full documentation.

  TESTS:

      sage: from sage.interfaces.maxima_abstract import MaximaAbstractElementFunction
      sage: MaximaAbstractElementFunction == loads(dumps(MaximaAbstractElementFunction))
      True
      sage: f = maxima.function('x,y','sin(x+y)')
      sage: f == loads(dumps(f))
      True

class `sage.interfaces.maxima_lib.``MaximaLibFunction`(parent, name)

  Bases: `sage.interfaces.maxima_abstract.MaximaAbstractFunction`

class `sage.interfaces.maxima_lib.``MaximaLibFunctionElement`(obj, name)

  Bases: `sage.interfaces.maxima_abstract.MaximaAbstractFunctionElement`

`sage.interfaces.maxima_lib.``add_vararg`(*args)

  Addition of a variable number of arguments.

  INPUT:

  - `args` - arguments to add

  OUTPUT: sum of arguments

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import add_vararg
      sage: add_vararg(1,2,3,4,5,6,7)
      28

`sage.interfaces.maxima_lib.``dummy_integrate`(expr)

  We would like to simply tie Maxima’s integrate to sage.calculus.calculus.dummy_integrate, but we’re being imported there so to avoid circularity we define it here.

  INPUT:

  - `expr` - ECL object; a Maxima %INTEGRATE expression

  OUTPUT: symbolic expression

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, dummy_integrate
      sage: f = maxima_lib('f(x)').integrate('x')
      sage: f.ecl()
      <ECL: ((%INTEGRATE SIMP) (($F SIMP) $X) $X)>
      sage: dummy_integrate(f.ecl())
      integrate(f(x), x)

      sage: f = maxima_lib('f(x)').integrate('x',0,10)
      sage: f.ecl()
      <ECL: ((%INTEGRATE SIMP) (($F SIMP) $X) $X 0 10)>
      sage: dummy_integrate(f.ecl())
      integrate(f(x), x, 0, 10)

`sage.interfaces.maxima_lib.``is_MaximaLibElement`(x)

  Returns True if x is of type MaximaLibElement.

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, is_MaximaLibElement
      sage: m = maxima_lib(1)
      sage: is_MaximaLibElement(m)
      True
      sage: is_MaximaLibElement(1)
      False

`sage.interfaces.maxima_lib.``max_at_to_sage`(expr)

  Special conversion rule for AT expressions.

  INPUT:

  - `expr` - ECL object; a Maxima AT expression

  OUTPUT: symbolic expression

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, max_at_to_sage
      sage: a=maxima_lib("'at(f(x,y,z),[x=1,y=2,z=3])")
      sage: a
      'at(f(x,y,z),[x=1,y=2,z=3])
      sage: max_at_to_sage(a.ecl())
      f(1, 2, 3)
      sage: a=maxima_lib("'at(f(x,y,z),x=1)")
      sage: a
      'at(f(x,y,z),x=1)
      sage: max_at_to_sage(a.ecl())
      f(1, y, z)

`sage.interfaces.maxima_lib.``max_to_sr`(expr)

  Convert a Maxima object into a symbolic expression.

  INPUT:

  - `expr` - ECL object

  OUTPUT: symbolic expression

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, max_to_sr
      sage: f = maxima_lib('f(x)')
      sage: f.ecl()
      <ECL: (($F SIMP) $X)>
      sage: max_to_sr(f.ecl())
      f(x)

  TESTS:

      sage: from sage.interfaces.maxima_lib import sr_to_max, max_to_sr
      sage: f = function('f',x).diff()
      sage: bool(max_to_sr(sr_to_max(f)) == f)
      True

`sage.interfaces.maxima_lib.``max_to_string`(s)

  Return the Maxima string corresponding to this ECL object.

  INPUT:

  - `s` - ECL object

  OUTPUT: string

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, max_to_string
      sage: ecl = maxima_lib(cos(x)).ecl()
      sage: max_to_string(ecl)
      'cos(_SAGE_VAR_x)'

`sage.interfaces.maxima_lib.``mdiff_to_sage`(expr)

  Special conversion rule for %DERIVATIVE expressions.

  INPUT:

  - `expr` - ECL object; a Maxima %DERIVATIVE expression

  OUTPUT: symbolic expression

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, mdiff_to_sage
      sage: f = maxima_lib('f(x)').diff('x',4)
      sage: f.ecl()
      <ECL: ((%DERIVATIVE SIMP) (($F SIMP) $X) $X 4)>
      sage: mdiff_to_sage(f.ecl())
      D[0, 0, 0, 0](f)(x)

`sage.interfaces.maxima_lib.``mlist_to_sage`(expr)

  Special conversion rule for MLIST expressions.

  INPUT:

  - `expr` - ECL object; a Maxima MLIST expression (i.e., a list)

  OUTPUT: a Python list of converted expressions.

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, mlist_to_sage
      sage: L=maxima_lib("[1,2,3]")
      sage: L.ecl()
      <ECL: ((MLIST SIMP) 1 2 3)>
      sage: mlist_to_sage(L.ecl())
      [1, 2, 3]

`sage.interfaces.maxima_lib.``mqapply_to_sage`(expr)

  Special conversion rule for MQAPPLY expressions.

  INPUT:

  - `expr` - ECL object; a Maxima MQAPPLY expression

  OUTPUT: symbolic expression

  MQAPPLY is used for function as li[x](y) and psi[x](y).

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, mqapply_to_sage
      sage: c = maxima_lib('li[2](3)')
      sage: c.ecl()
      <ECL: ((MQAPPLY SIMP) (($LI SIMP ARRAY) 2) 3)>
      sage: mqapply_to_sage(c.ecl())
      polylog(2, 3)

`sage.interfaces.maxima_lib.``mrat_to_sage`(expr)

  Convert a Maxima MRAT expression to Sage SR.

  INPUT:

  - `expr` - ECL object; a Maxima MRAT expression

  OUTPUT: symbolic expression

  Maxima has an optimised representation for multivariate rational expressions. The easiest way to translate those to SR is by first asking Maxima to give the generic representation of the object. That is what RATDISREP does in Maxima.

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import maxima_lib, mrat_to_sage
      sage: var('x y z')
      (x, y, z)
      sage: c = maxima_lib((x+y^2+z^9)/x^6+z^8/y).rat()
      sage: c
      (_SAGE_VAR_y*_SAGE_VAR_z^9+_SAGE_VAR_x^6*_SAGE_VAR_z^8+_SAGE_VAR_y^3+_SAGE_VAR_x*_SAGE_VAR_y)/(_SAGE_VAR_x^6*_SAGE_VAR_y)
      sage: c.ecl()
      <ECL: ((MRAT SIMP (|$_SAGE_VAR_x| |$_SAGE_VAR_y| |$_SAGE_VAR_z|)
      ...>
      sage: mrat_to_sage(c.ecl())
      (x^6*z^8 + y*z^9 + y^3 + x*y)/(x^6*y)

`sage.interfaces.maxima_lib.``mul_vararg`(*args)

  Multiplication of a variable number of arguments.

  INPUT:

  - `args` - arguments to multiply

  OUTPUT: product of arguments

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import mul_vararg
      sage: mul_vararg(9,8,7,6,5,4)
      60480

`sage.interfaces.maxima_lib.``parse_max_string`(s)

  Evaluate string in Maxima without any further simplification.

  INPUT:

  - `s` - string

  OUTPUT: ECL object

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import parse_max_string
      sage: parse_max_string('1+1')
      <ECL: ((MPLUS) 1 1)>

`sage.interfaces.maxima_lib.``pyobject_to_max`(obj)

  Convert a (simple) Python object into a Maxima object.

  INPUT:

  - `expr` - Python object

  OUTPUT: ECL object

  Note

  This uses functions defined in sage.libs.ecl.

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import pyobject_to_max
      sage: pyobject_to_max(4)
      <ECL: 4>
      sage: pyobject_to_max('z')
      <ECL: Z>
      sage: var('x')
      x
      sage: pyobject_to_max(x)
      Traceback (most recent call last):
      ...
      TypeError: Unimplemented type for python_to_ecl

`sage.interfaces.maxima_lib.``reduce_load_MaximaLib`()

  Unpickle the (unique) Maxima library interface.

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import reduce_load_MaximaLib
      sage: reduce_load_MaximaLib()
      Maxima_lib

`sage.interfaces.maxima_lib.``sage_rat`(x, y)

  Return quotient x/y.

  INPUT:

  - `x` - integer
  - `y` - integer

  OUTPUT: rational

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import sage_rat
      sage: sage_rat(1,7)
      1/7

`sage.interfaces.maxima_lib.``sr_to_max`(expr)

  Convert a symbolic expression into a Maxima object.

  INPUT:

  - `expr` - symbolic expression

  OUTPUT: ECL object

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import sr_to_max
      sage: var('x')
      x
      sage: sr_to_max(x)
      <ECL: $X>
      sage: sr_to_max(cos(x))
      <ECL: ((%COS) $X)>
      sage: f = function('f',x)
      sage: sr_to_max(f.diff())
      <ECL: ((%DERIVATIVE) (($F) $X) $X 1)>

  TESTS:

  We should be able to convert derivatives evaluated at a point, trac ticket #12796:

      sage: from sage.interfaces.maxima_lib import sr_to_max, max_to_sr
      sage: f = function('f')
      sage: f_prime = f(x).diff(x)
      sage: max_to_sr(sr_to_max(f_prime(x = 1)))
      D[0](f)(1)

`sage.interfaces.maxima_lib.``stdout_to_string`(s)

  Evaluate command `s` and catch Maxima stdout (not the result of the command!) into a string.

  INPUT:

  - `s` - string; command to evaluate

  OUTPUT: string

  This is currently used to implement `display2d()`.

  EXAMPLES:

      sage: from sage.interfaces.maxima_lib import stdout_to_string
      sage: stdout_to_string('1+1')
      ''
      sage: stdout_to_string('disp(1+1)')
      '2\n\n'

### Navigation

- index
- modules |
- next |
- previous |
- Interpreter Interfaces »