Abstract 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/docs.shtml/.
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
This is an abstract class implementing the functions shared between the Pexpect and library interfaces to Maxima.
- class sage.interfaces.maxima_abstract.MaximaAbstract(name='maxima_abstract')[source]¶
Bases:
ExtraTabCompletion,InterfaceAbstract interface to Maxima.
INPUT:
name– string
OUTPUT: the interface
EXAMPLES:
This class should not be instantiated directly, but should be used through its subclass MaximaLib (which is a singleton), or through the Pexpect interface Maxima.
sage: from sage.interfaces.maxima_abstract import MaximaAbstract sage: from sage.interfaces.maxima_lib import maxima sage: isinstance(maxima, MaximaAbstract) True
- completions(s, verbose=True)[source]¶
Return all commands that complete the command starting with the string
s. This is like typing s[tab] in the Maxima interpreter.INPUT:
s– stringverbose– boolean (default:True)
OUTPUT: array of strings
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: sorted(maxima.completions('gc', verbose=False)) ['gc', 'gcd', 'gcdex', 'gcfactor', 'gctime']
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> sorted(maxima.completions('gc', verbose=False)) ['gc', 'gcd', 'gcdex', 'gcfactor', 'gctime']
from sage.interfaces.maxima_lib import maxima sorted(maxima.completions('gc', verbose=False))
- console()[source]¶
Start the interactive Maxima console. This is a completely separate maxima session from this interface. To interact with this session, you should instead use
maxima.interact().OUTPUT: none
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.console() # not tested (since we can't) Maxima 5.46.0 https://maxima.sourceforge.io using Lisp ECL 21.2.1 Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.console() # not tested (since we can't) Maxima 5.46.0 https://maxima.sourceforge.io using Lisp ECL 21.2.1 Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1)
from sage.interfaces.maxima_lib import maxima maxima.console() # not tested (since we can't)
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.interact() # not tested --> Switching to Maxima <-- maxima: 2+2 4 maxima: --> Exiting back to Sage <--
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.interact() # not tested --> Switching to Maxima <-- maxima: 2+2 4 maxima: --> Exiting back to Sage <--
from sage.interfaces.maxima_lib import maxima maxima.interact() # not tested
- cputime(t=None)[source]¶
Return the amount of CPU time that this Maxima session has used.
INPUT:
t– float (default:None); if var{t} is not None, then it returns the difference between the current CPU time and var{t}
OUTPUT: float
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: t = maxima.cputime() sage: _ = maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'], [1,1,1]) sage: maxima.cputime(t) # output random 0.568913
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> t = maxima.cputime() >>> _ = maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'], [Integer(1),Integer(1),Integer(1)]) >>> maxima.cputime(t) # output random 0.568913
from sage.interfaces.maxima_lib import maxima t = maxima.cputime() _ = maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'], [1,1,1]) maxima.cputime(t) # output random
- de_solve(de, vars, ics=None)[source]¶
Solve a 1st or 2nd order ordinary differential equation (ODE) in two variables, possibly with initial conditions.
INPUT:
de– string representing the ODEvars– list of strings representing the two variablesics– a triple of numbers [a,b1,b2] representing y(a)=b1, y’(a)=b2
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'], [1,1,1]) y = 3*x-2*%e^(x-1) sage: maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y']) y = %k1*%e^x+%k2*%e^-x+3*x sage: maxima.de_solve('diff(y,x) + 3*x = y', ['x','y']) y = (%c-3*(...-x...-1)*%e^-x)*%e^x sage: maxima.de_solve('diff(y,x) + 3*x = y', ['x','y'],[1,1]) y = -...%e^-1*(5*%e^x-3*%e*x-3*%e)...
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'], [Integer(1),Integer(1),Integer(1)]) y = 3*x-2*%e^(x-1) >>> maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y']) y = %k1*%e^x+%k2*%e^-x+3*x >>> maxima.de_solve('diff(y,x) + 3*x = y', ['x','y']) y = (%c-3*(...-x...-1)*%e^-x)*%e^x >>> maxima.de_solve('diff(y,x) + 3*x = y', ['x','y'],[Integer(1),Integer(1)]) y = -...%e^-1*(5*%e^x-3*%e*x-3*%e)...
from sage.interfaces.maxima_lib import maxima maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y'], [1,1,1]) maxima.de_solve('diff(y,x,2) + 3*x = y', ['x','y']) maxima.de_solve('diff(y,x) + 3*x = y', ['x','y']) maxima.de_solve('diff(y,x) + 3*x = y', ['x','y'],[1,1])
- de_solve_laplace(de, vars, ics=None)[source]¶
Solve an ordinary differential equation (ODE) using Laplace transforms.
INPUT:
de– string representing the ODE (e.g., de = “diff(f(x),x,2)=diff(f(x),x)+sin(x)”)vars– list of strings representing the variables (e.g.,vars = ["x","f"])ics– list of numbers representing initial conditions, with symbols allowed which are represented by strings (eg, f(0)=1, f’(0)=2 is ics = [0,1,2])
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.clear('x'); maxima.clear('f') sage: maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"], [0,1,2]) f(x) = x*%e^x+%e^x
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.clear('x'); maxima.clear('f') >>> maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"], [Integer(0),Integer(1),Integer(2)]) f(x) = x*%e^x+%e^x
from sage.interfaces.maxima_lib import maxima maxima.clear('x'); maxima.clear('f') maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"], [0,1,2])sage: maxima.clear('x'); maxima.clear('f') sage: f = maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"]) sage: f f(x) = x*%e^x*('at('diff(f(x),x,1),x = 0))-f(0)*x*%e^x+f(0)*%e^x sage: print(f) ! x d ! x x f(x) = x %e (-- (f(x))! ) - f(0) x %e + f(0) %e dx ! !x = 0
>>> from sage.all import * >>> maxima.clear('x'); maxima.clear('f') >>> f = maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"]) >>> f f(x) = x*%e^x*('at('diff(f(x),x,1),x = 0))-f(0)*x*%e^x+f(0)*%e^x >>> print(f) ! x d ! x x f(x) = x %e (-- (f(x))! ) - f(0) x %e + f(0) %e dx ! !x = 0
maxima.clear('x'); maxima.clear('f') f = maxima.de_solve_laplace("diff(f(x),x,2) = 2*diff(f(x),x)-f(x)", ["x","f"]) f print(f)Note
The second equation sets the values of \(f(0)\) and \(f'(0)\) in Maxima, so subsequent ODEs involving these variables will have these initial conditions automatically imposed.
- demo(s)[source]¶
Run Maxima’s demo for
s.INPUT:
s– string
OUTPUT: none
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.demo('cf') # not tested read and interpret file: .../share/maxima/5.34.1/demo/cf.dem At the '_' prompt, type ';' and <enter> to get next demonstration. frac1:cf([1,2,3,4]) ...
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.demo('cf') # not tested read and interpret file: .../share/maxima/5.34.1/demo/cf.dem At the '_' prompt, type ';' and <enter> to get next demonstration. frac1:cf([1,2,3,4]) ...
from sage.interfaces.maxima_lib import maxima maxima.demo('cf') # not tested
- example(s)[source]¶
Return Maxima’s examples for
s.INPUT:
s– string
OUTPUT: Maxima’s examples for
sEXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.example('arrays') a[n]:=n*a[n-1] a := n a n n - 1 a[0]:1 a[5] 120 a[n]:=n a[6] 6 a[4] 24 done
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.example('arrays') a[n]:=n*a[n-1] a := n a n n - 1 a[0]:1 a[5] 120 a[n]:=n a[6] 6 a[4] 24 done
from sage.interfaces.maxima_lib import maxima maxima.example('arrays')
- function(args, defn, rep=None, latex=None)[source]¶
Return the Maxima function with given arguments and definition.
INPUT:
args– string with variable names separated by commasdefn– string (or Maxima expression) that defines a function of the arguments in Maximarep– an optional string; if given, this is how the function will print
OUTPUT: Maxima function
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: f = maxima.function('x', 'sin(x)') sage: f(3.2) # abs tol 2e-16 -0.058374143427579909 sage: f = maxima.function('x,y', 'sin(x)+cos(y)') sage: f(2, 3.5) # abs tol 2e-16 sin(2)-0.9364566872907963 sage: f sin(x)+cos(y)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> f = maxima.function('x', 'sin(x)') >>> f(RealNumber('3.2')) # abs tol 2e-16 -0.058374143427579909 >>> f = maxima.function('x,y', 'sin(x)+cos(y)') >>> f(Integer(2), RealNumber('3.5')) # abs tol 2e-16 sin(2)-0.9364566872907963 >>> f sin(x)+cos(y)
from sage.interfaces.maxima_lib import maxima f = maxima.function('x', 'sin(x)') f(3.2) # abs tol 2e-16 f = maxima.function('x,y', 'sin(x)+cos(y)') f(2, 3.5) # abs tol 2e-16 fsage: g = f.integrate('z') sage: g (cos(y)+sin(x))*z sage: g(1,2,3) 3*(cos(2)+sin(1))
>>> from sage.all import * >>> g = f.integrate('z') >>> g (cos(y)+sin(x))*z >>> g(Integer(1),Integer(2),Integer(3)) 3*(cos(2)+sin(1))
g = f.integrate('z') g g(1,2,3)The function definition can be a Maxima object:
sage: an_expr = maxima('sin(x)*gamma(x)') sage: t = maxima.function('x', an_expr) sage: t gamma(x)*sin(x) sage: t(2) sin(2) sage: float(t(2)) 0.9092974268256817 sage: loads(t.dumps()) gamma(x)*sin(x)
>>> from sage.all import * >>> an_expr = maxima('sin(x)*gamma(x)') >>> t = maxima.function('x', an_expr) >>> t gamma(x)*sin(x) >>> t(Integer(2)) sin(2) >>> float(t(Integer(2))) 0.9092974268256817 >>> loads(t.dumps()) gamma(x)*sin(x)
an_expr = maxima('sin(x)*gamma(x)') t = maxima.function('x', an_expr) t t(2) float(t(2)) loads(t.dumps())
- help(s)[source]¶
Return Maxima’s help for
s.INPUT:
s– string
OUTPUT: Maxima’s help for
sEXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.help('gcd') -- Function: gcd (<p_1>, <p_2>, <x_1>, ...) ...
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.help('gcd') -- Function: gcd (<p_1>, <p_2>, <x_1>, ...) ...
from sage.interfaces.maxima_lib import maxima maxima.help('gcd')
- plot2d(*args)[source]¶
Plot a 2d graph using Maxima / gnuplot.
maxima.plot2d(f, ‘[var, min, max]’, options)
INPUT:
f– string representing a function (such as f=”sin(x)”) [var, xmin, xmax]options– an optional string representing plot2d options in gnuplot format
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.plot2d('sin(x)','[x,-5,5]') # not tested sage: opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-plot.eps"]' sage: maxima.plot2d('sin(x)','[x,-5,5]',opts) # not tested
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.plot2d('sin(x)','[x,-5,5]') # not tested >>> opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-plot.eps"]' >>> maxima.plot2d('sin(x)','[x,-5,5]',opts) # not tested
from sage.interfaces.maxima_lib import maxima maxima.plot2d('sin(x)','[x,-5,5]') # not tested opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-plot.eps"]' maxima.plot2d('sin(x)','[x,-5,5]',opts) # not testedThe eps file is saved in the current directory.
- plot2d_parametric(r, var, trange, nticks=50, options=None)[source]¶
Plot r = [x(t), y(t)] for t = tmin…tmax using gnuplot with options.
INPUT:
r– string representing a function (such as r=”[x(t),y(t)]”)var– string representing the variable (such as var = “t”)trange– [tmin, tmax] are numbers with tmintmaxnticks– integer (default: 50)options– an optional string representing plot2d options in gnuplot format
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.plot2d_parametric(["sin(t)","cos(t)"], "t",[-3.1,3.1]) # not tested
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.plot2d_parametric(["sin(t)","cos(t)"], "t",[-RealNumber('3.1'),RealNumber('3.1')]) # not tested
from sage.interfaces.maxima_lib import maxima maxima.plot2d_parametric(["sin(t)","cos(t)"], "t",[-3.1,3.1]) # not tested
sage: opts = '[gnuplot_preamble, "set nokey"], [gnuplot_term, ps], [gnuplot_out_file, "circle-plot.eps"]' sage: maxima.plot2d_parametric(["sin(t)","cos(t)"], "t", [-3.1,3.1], options=opts) # not tested
>>> from sage.all import * >>> opts = '[gnuplot_preamble, "set nokey"], [gnuplot_term, ps], [gnuplot_out_file, "circle-plot.eps"]' >>> maxima.plot2d_parametric(["sin(t)","cos(t)"], "t", [-RealNumber('3.1'),RealNumber('3.1')], options=opts) # not tested
opts = '[gnuplot_preamble, "set nokey"], [gnuplot_term, ps], [gnuplot_out_file, "circle-plot.eps"]' maxima.plot2d_parametric(["sin(t)","cos(t)"], "t", [-3.1,3.1], options=opts) # not tested
The eps file is saved to the current working directory.
Here is another fun plot:
sage: maxima.plot2d_parametric(["sin(5*t)","cos(11*t)"], "t", [0,2*pi()], nticks=400) # not tested
>>> from sage.all import * >>> maxima.plot2d_parametric(["sin(5*t)","cos(11*t)"], "t", [Integer(0),Integer(2)*pi()], nticks=Integer(400)) # not tested
maxima.plot2d_parametric(["sin(5*t)","cos(11*t)"], "t", [0,2*pi()], nticks=400) # not tested
- plot3d(*args)[source]¶
Plot a 3d graph using Maxima / gnuplot.
maxima.plot3d(f, ‘[x, xmin, xmax]’, ‘[y, ymin, ymax]’, ‘[grid, nx, ny]’, options)
INPUT:
f– string representing a function (such as f=”sin(x)”) [var, min, max]argsshould be of the form ‘[x, xmin, xmax]’, ‘[y, ymin, ymax]’, ‘[grid, nx, ny]’, options
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.plot3d('1 + x^3 - y^2', '[x,-2,2]', '[y,-2,2]', '[grid,12,12]') # not tested sage: maxima.plot3d('sin(x)*cos(y)', '[x,-2,2]', '[y,-2,2]', '[grid,30,30]') # not tested sage: opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-plot.eps"]' sage: maxima.plot3d('sin(x+y)', '[x,-5,5]', '[y,-1,1]', opts) # not tested
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.plot3d('1 + x^3 - y^2', '[x,-2,2]', '[y,-2,2]', '[grid,12,12]') # not tested >>> maxima.plot3d('sin(x)*cos(y)', '[x,-2,2]', '[y,-2,2]', '[grid,30,30]') # not tested >>> opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-plot.eps"]' >>> maxima.plot3d('sin(x+y)', '[x,-5,5]', '[y,-1,1]', opts) # not tested
from sage.interfaces.maxima_lib import maxima maxima.plot3d('1 + x^3 - y^2', '[x,-2,2]', '[y,-2,2]', '[grid,12,12]') # not tested maxima.plot3d('sin(x)*cos(y)', '[x,-2,2]', '[y,-2,2]', '[grid,30,30]') # not tested opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-plot.eps"]' maxima.plot3d('sin(x+y)', '[x,-5,5]', '[y,-1,1]', opts) # not testedThe eps file is saved in the current working directory.
- plot3d_parametric(r, vars, urange, vrange, options=None)[source]¶
Plot a 3d parametric graph with r=(x,y,z), x = x(u,v), y = y(u,v), z = z(u,v), for u = umin…umax, v = vmin…vmax using gnuplot with options.
INPUT:
x,y,z– string representing a function (such asx="u2+v2", …) vars is a list or two strings representing variables (such as vars = [“u”,”v”])urange– [umin, umax]vrange– [vmin, vmax] are lists of numbers with umin umax, vmin vmaxoptions– (optional) string representing plot2d options in gnuplot format
OUTPUT: displays a plot on screen or saves to a file
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],[-3.2,3.2],[0,3]) # not tested sage: opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-cos-plot.eps"]' sage: maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],[-3.2,3.2],[0,3],opts) # not tested
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],[-RealNumber('3.2'),RealNumber('3.2')],[Integer(0),Integer(3)]) # not tested >>> opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-cos-plot.eps"]' >>> maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],[-RealNumber('3.2'),RealNumber('3.2')],[Integer(0),Integer(3)],opts) # not tested
from sage.interfaces.maxima_lib import maxima maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],[-3.2,3.2],[0,3]) # not tested opts = '[gnuplot_term, ps], [gnuplot_out_file, "sin-cos-plot.eps"]' maxima.plot3d_parametric(["v*sin(u)","v*cos(u)","v"], ["u","v"],[-3.2,3.2],[0,3],opts) # not tested
The eps file is saved in the current working directory.
Here is a torus:
sage: _ = maxima.eval("expr_1: cos(y)*(10.0+6*cos(x)); expr_2: sin(y)*(10.0+6*cos(x)); expr_3: -6*sin(x);") sage: maxima.plot3d_parametric(["expr_1","expr_2","expr_3"], ["x","y"],[0,6],[0,6]) # not tested
>>> from sage.all import * >>> _ = maxima.eval("expr_1: cos(y)*(10.0+6*cos(x)); expr_2: sin(y)*(10.0+6*cos(x)); expr_3: -6*sin(x);") >>> maxima.plot3d_parametric(["expr_1","expr_2","expr_3"], ["x","y"],[Integer(0),Integer(6)],[Integer(0),Integer(6)]) # not tested
_ = maxima.eval("expr_1: cos(y)*(10.0+6*cos(x)); expr_2: sin(y)*(10.0+6*cos(x)); expr_3: -6*sin(x);") maxima.plot3d_parametric(["expr_1","expr_2","expr_3"], ["x","y"],[0,6],[0,6]) # not testedHere is a Möbius strip:
sage: x = "cos(u)*(3 + v*cos(u/2))" sage: y = "sin(u)*(3 + v*cos(u/2))" sage: z = "v*sin(u/2)" sage: maxima.plot3d_parametric([x,y,z],["u","v"],[-3.1,3.2],[-1/10,1/10]) # not tested
>>> from sage.all import * >>> x = "cos(u)*(3 + v*cos(u/2))" >>> y = "sin(u)*(3 + v*cos(u/2))" >>> z = "v*sin(u/2)" >>> maxima.plot3d_parametric([x,y,z],["u","v"],[-RealNumber('3.1'),RealNumber('3.2')],[-Integer(1)/Integer(10),Integer(1)/Integer(10)]) # not tested
x = "cos(u)*(3 + v*cos(u/2))" y = "sin(u)*(3 + v*cos(u/2))" z = "v*sin(u/2)" maxima.plot3d_parametric([x,y,z],["u","v"],[-3.1,3.2],[-1/10,1/10]) # not tested
- plot_list(ptsx, ptsy, options=None)[source]¶
Plots a curve determined by a sequence of points.
INPUT:
ptsx– [x1,…,xn], where the xi and yi are real,ptsy– [y1,…,yn]options– string representing maxima plot2d options
The points are (x1,y1), (x2,y2), etc.
This function requires maxima 5.9.2 or newer.
Note
More that 150 points can sometimes lead to the program hanging. Why?
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: zeta_ptsx = [(pari(1/2 + i*I/10).zeta().real()).precision(1) # needs sage.libs.pari ....: for i in range(70,150)] sage: zeta_ptsy = [(pari(1/2 + i*I/10).zeta().imag()).precision(1) # needs sage.libs.pari ....: for i in range(70,150)] sage: maxima.plot_list(zeta_ptsx, zeta_ptsy) # not tested # needs sage.libs.pari sage: opts='[gnuplot_preamble, "set nokey"], [gnuplot_term, ps], [gnuplot_out_file, "zeta.eps"]' sage: maxima.plot_list(zeta_ptsx, zeta_ptsy, opts) # not tested # needs sage.libs.pari
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> zeta_ptsx = [(pari(Integer(1)/Integer(2) + i*I/Integer(10)).zeta().real()).precision(Integer(1)) # needs sage.libs.pari ... for i in range(Integer(70),Integer(150))] >>> zeta_ptsy = [(pari(Integer(1)/Integer(2) + i*I/Integer(10)).zeta().imag()).precision(Integer(1)) # needs sage.libs.pari ... for i in range(Integer(70),Integer(150))] >>> maxima.plot_list(zeta_ptsx, zeta_ptsy) # not tested # needs sage.libs.pari >>> opts='[gnuplot_preamble, "set nokey"], [gnuplot_term, ps], [gnuplot_out_file, "zeta.eps"]' >>> maxima.plot_list(zeta_ptsx, zeta_ptsy, opts) # not tested # needs sage.libs.pari
from sage.interfaces.maxima_lib import maxima zeta_ptsx = [(pari(1/2 + i*I/10).zeta().real()).precision(1) # needs sage.libs.pari for i in range(70,150)] zeta_ptsy = [(pari(1/2 + i*I/10).zeta().imag()).precision(1) # needs sage.libs.pari for i in range(70,150)] maxima.plot_list(zeta_ptsx, zeta_ptsy) # not tested # needs sage.libs.pari opts='[gnuplot_preamble, "set nokey"], [gnuplot_term, ps], [gnuplot_out_file, "zeta.eps"]' maxima.plot_list(zeta_ptsx, zeta_ptsy, opts) # not tested # needs sage.libs.pari
- plot_multilist(pts_list, options=None)[source]¶
Plots a list of list of points pts_list=[pts1,pts2,…,ptsn], where each ptsi is of the form [[x1,y1],…,[xn,yn]] x’s must be integers and y’s reals options is a string representing maxima plot2d options.
INPUT:
pts_lst– list of points; each point must be of the form [x,y] wherexis an integer andyis a realvar– string; representing Maxima’s plot2d options
Requires maxima 5.9.2 at least.
Note
More that 150 points can sometimes lead to the program hanging.
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: xx = [i/10.0 for i in range(-10,10)] sage: yy = [i/10.0 for i in range(-10,10)] sage: x0 = [0 for i in range(-10,10)] sage: y0 = [0 for i in range(-10,10)] sage: zeta_ptsx1 = [(pari(1/2+i*I/10).zeta().real()).precision(1) # needs sage.libs.pari ....: for i in range(10)] sage: zeta_ptsy1 = [(pari(1/2+i*I/10).zeta().imag()).precision(1) # needs sage.libs.pari ....: for i in range(10)] sage: maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]]) # not tested sage: zeta_ptsx1 = [(pari(1/2+i*I/10).zeta().real()).precision(1) # needs sage.libs.pari ....: for i in range(10,150)] sage: zeta_ptsy1 = [(pari(1/2+i*I/10).zeta().imag()).precision(1) # needs sage.libs.pari ....: for i in range(10,150)] sage: maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]]) # not tested sage: opts='[gnuplot_preamble, "set nokey"]' sage: maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]], # not tested ....: opts)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> xx = [i/RealNumber('10.0') for i in range(-Integer(10),Integer(10))] >>> yy = [i/RealNumber('10.0') for i in range(-Integer(10),Integer(10))] >>> x0 = [Integer(0) for i in range(-Integer(10),Integer(10))] >>> y0 = [Integer(0) for i in range(-Integer(10),Integer(10))] >>> zeta_ptsx1 = [(pari(Integer(1)/Integer(2)+i*I/Integer(10)).zeta().real()).precision(Integer(1)) # needs sage.libs.pari ... for i in range(Integer(10))] >>> zeta_ptsy1 = [(pari(Integer(1)/Integer(2)+i*I/Integer(10)).zeta().imag()).precision(Integer(1)) # needs sage.libs.pari ... for i in range(Integer(10))] >>> maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]]) # not tested >>> zeta_ptsx1 = [(pari(Integer(1)/Integer(2)+i*I/Integer(10)).zeta().real()).precision(Integer(1)) # needs sage.libs.pari ... for i in range(Integer(10),Integer(150))] >>> zeta_ptsy1 = [(pari(Integer(1)/Integer(2)+i*I/Integer(10)).zeta().imag()).precision(Integer(1)) # needs sage.libs.pari ... for i in range(Integer(10),Integer(150))] >>> maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]]) # not tested >>> opts='[gnuplot_preamble, "set nokey"]' >>> maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]], # not tested ... opts)
from sage.interfaces.maxima_lib import maxima xx = [i/10.0 for i in range(-10,10)] yy = [i/10.0 for i in range(-10,10)] x0 = [0 for i in range(-10,10)] y0 = [0 for i in range(-10,10)] zeta_ptsx1 = [(pari(1/2+i*I/10).zeta().real()).precision(1) # needs sage.libs.pari for i in range(10)] zeta_ptsy1 = [(pari(1/2+i*I/10).zeta().imag()).precision(1) # needs sage.libs.pari for i in range(10)] maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]]) # not tested zeta_ptsx1 = [(pari(1/2+i*I/10).zeta().real()).precision(1) # needs sage.libs.pari for i in range(10,150)] zeta_ptsy1 = [(pari(1/2+i*I/10).zeta().imag()).precision(1) # needs sage.libs.pari for i in range(10,150)] maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]]) # not tested opts='[gnuplot_preamble, "set nokey"]' maxima.plot_multilist([[zeta_ptsx1,zeta_ptsy1], [xx,y0], [x0,yy]], # not tested opts)
- solve_linear(eqns, vars)[source]¶
Wraps maxima’s linsolve.
INPUT:
eqns– list of m strings; each representing a linear question in m = n variablesvars– list of n strings; each representing a variable
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: eqns = ["x + z = y","2*a*x - y = 2*a^2","y - 2*z = 2"] sage: vars = ["x","y","z"] sage: maxima.solve_linear(eqns, vars) [x = a+1,y = 2*a,z = a-1]
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> eqns = ["x + z = y","2*a*x - y = 2*a^2","y - 2*z = 2"] >>> vars = ["x","y","z"] >>> maxima.solve_linear(eqns, vars) [x = a+1,y = 2*a,z = a-1]
from sage.interfaces.maxima_lib import maxima eqns = ["x + z = y","2*a*x - y = 2*a^2","y - 2*z = 2"] vars = ["x","y","z"] maxima.solve_linear(eqns, vars)
- unit_quadratic_integer(n)[source]¶
Finds a unit of the ring of integers of the quadratic number field \(\QQ(\sqrt{n})\), \(n>1\), using the qunit maxima command.
INPUT:
n– integer
EXAMPLES:
sage: # needs sage.rings.number_field sage: from sage.interfaces.maxima_lib import maxima sage: u = maxima.unit_quadratic_integer(101); u a + 10 sage: u.parent() Number Field in a with defining polynomial x^2 - 101 with a = 10.04987562112089? sage: u = maxima.unit_quadratic_integer(13) sage: u 5*a + 18 sage: u.parent() Number Field in a with defining polynomial x^2 - 13 with a = 3.605551275463990?
>>> from sage.all import * >>> # needs sage.rings.number_field >>> from sage.interfaces.maxima_lib import maxima >>> u = maxima.unit_quadratic_integer(Integer(101)); u a + 10 >>> u.parent() Number Field in a with defining polynomial x^2 - 101 with a = 10.04987562112089? >>> u = maxima.unit_quadratic_integer(Integer(13)) >>> u 5*a + 18 >>> u.parent() Number Field in a with defining polynomial x^2 - 13 with a = 3.605551275463990?
# needs sage.rings.number_field from sage.interfaces.maxima_lib import maxima u = maxima.unit_quadratic_integer(101); u u.parent() u = maxima.unit_quadratic_integer(13) u u.parent()
- version()[source]¶
Return the version of Maxima that Sage includes.
OUTPUT: none
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.version() # random '5.41.0'
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.version() # random '5.41.0'
from sage.interfaces.maxima_lib import maxima maxima.version() # random
- class sage.interfaces.maxima_abstract.MaximaAbstractElement(parent, value, is_name=False, name=None)[source]¶
Bases:
ExtraTabCompletion,InterfaceElementElement of Maxima through an abstract interface.
EXAMPLES:
Elements of this class should not be created directly. The targeted parent of a concrete inherited class should be used instead:
sage: from sage.interfaces.maxima_lib import maxima sage: xp = maxima(x) sage: type(xp) <class 'sage.interfaces.maxima_lib.MaximaLibElement'>
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> xp = maxima(x) >>> type(xp) <class 'sage.interfaces.maxima_lib.MaximaLibElement'>
from sage.interfaces.maxima_lib import maxima xp = maxima(x) type(xp)
- comma(args)[source]¶
Form the expression that would be written ‘self, args’ in Maxima.
INPUT:
args– string
OUTPUT: Maxima object
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima('sqrt(2) + I').comma('numer') I+1.41421356237309... sage: maxima('sqrt(2) + I*a').comma('a=5') 5*I+sqrt(2)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima('sqrt(2) + I').comma('numer') I+1.41421356237309... >>> maxima('sqrt(2) + I*a').comma('a=5') 5*I+sqrt(2)
from sage.interfaces.maxima_lib import maxima maxima('sqrt(2) + I').comma('numer') maxima('sqrt(2) + I*a').comma('a=5')
- diff(var='x', n=1)[source]¶
Return the \(n\)-th derivative of
self.INPUT:
var– variable (default:'x')n– integer (default: 1)
OUTPUT: \(n\)-th derivative of
selfwith respect to the variable varEXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: f = maxima('x^2') sage: f.diff() 2*x sage: f.diff('x') 2*x sage: f.diff('x', 2) 2 sage: maxima('sin(x^2)').diff('x',4) 16*x^4*sin(x^2)-12*sin(x^2)-48*x^2*cos(x^2)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> f = maxima('x^2') >>> f.diff() 2*x >>> f.diff('x') 2*x >>> f.diff('x', Integer(2)) 2 >>> maxima('sin(x^2)').diff('x',Integer(4)) 16*x^4*sin(x^2)-12*sin(x^2)-48*x^2*cos(x^2)
from sage.interfaces.maxima_lib import maxima f = maxima('x^2') f.diff() f.diff('x') f.diff('x', 2) maxima('sin(x^2)').diff('x',4)sage: from sage.interfaces.maxima_lib import maxima sage: f = maxima('x^3 + 17*y^2') sage: f.diff('x') 3*x^2 sage: f.diff('y') 34*y
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> f = maxima('x^3 + 17*y^2') >>> f.diff('x') 3*x^2 >>> f.diff('y') 34*y
from sage.interfaces.maxima_lib import maxima f = maxima('x^3 + 17*y^2') f.diff('x') f.diff('y')
- dot(other)[source]¶
Implement the notation
self . other.INPUT:
other– matrix; argument to dot
OUTPUT: Maxima matrix
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: A = maxima('matrix ([a1],[a2])') sage: B = maxima('matrix ([b1, b2])') sage: A.dot(B) matrix([a1*b1,a1*b2],[a2*b1,a2*b2])
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> A = maxima('matrix ([a1],[a2])') >>> B = maxima('matrix ([b1, b2])') >>> A.dot(B) matrix([a1*b1,a1*b2],[a2*b1,a2*b2])
from sage.interfaces.maxima_lib import maxima A = maxima('matrix ([a1],[a2])') B = maxima('matrix ([b1, b2])') A.dot(B)
- imag()[source]¶
Return the imaginary part of this Maxima element.
OUTPUT: Maxima real
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima('2 + (2/3)*%i').imag() 2/3
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima('2 + (2/3)*%i').imag() 2/3
from sage.interfaces.maxima_lib import maxima maxima('2 + (2/3)*%i').imag()
- integral(var='x', min=None, max=None)[source]¶
Return the integral of
selfwith respect to the variable \(x\).INPUT:
var– variablemin– (default:None)max– (default:None)
OUTPUT: the definite integral if xmin is not
Nonean indefinite integral otherwise
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima('x^2+1').integral() x^3/3+x sage: maxima('x^2+ 1 + y^2').integral('y') y^3/3+x^2*y+y sage: maxima('x / (x^2+1)').integral() log(x^2+1)/2 sage: maxima('1/(x^2+1)').integral() atan(x) sage: maxima('1/(x^2+1)').integral('x', 0, infinity) %pi/2 sage: maxima('x/(x^2+1)').integral('x', -1, 1) 0
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima('x^2+1').integral() x^3/3+x >>> maxima('x^2+ 1 + y^2').integral('y') y^3/3+x^2*y+y >>> maxima('x / (x^2+1)').integral() log(x^2+1)/2 >>> maxima('1/(x^2+1)').integral() atan(x) >>> maxima('1/(x^2+1)').integral('x', Integer(0), infinity) %pi/2 >>> maxima('x/(x^2+1)').integral('x', -Integer(1), Integer(1)) 0
from sage.interfaces.maxima_lib import maxima maxima('x^2+1').integral() maxima('x^2+ 1 + y^2').integral('y') maxima('x / (x^2+1)').integral() maxima('1/(x^2+1)').integral() maxima('1/(x^2+1)').integral('x', 0, infinity) maxima('x/(x^2+1)').integral('x', -1, 1)sage: f = maxima('exp(x^2)').integral('x',0,1) sage: f.sage() -1/2*I*sqrt(pi)*erf(I) sage: f.numer() 1.46265174590718...
>>> from sage.all import * >>> f = maxima('exp(x^2)').integral('x',Integer(0),Integer(1)) >>> f.sage() -1/2*I*sqrt(pi)*erf(I) >>> f.numer() 1.46265174590718...
f = maxima('exp(x^2)').integral('x',0,1) f.sage() f.numer()
- integrate(var='x', min=None, max=None)[source]¶
alias of
integral().
- nintegral(var='x', a=0, b=1, desired_relative_error='1e-8', maximum_num_subintervals=200)[source]¶
Return a numerical approximation to the integral of
selffrom \(a\) to \(b\).INPUT:
var– variable to integrate with respect toa– lower endpoint of integrationb– upper endpoint of integrationdesired_relative_error– (default:'1e-8') the desired relative errormaximum_num_subintervals– (default: 200) maxima number of subintervals
OUTPUT: approximation to the integral
estimated absolute error of the approximation
the number of integrand evaluations
an error code:
0– no problems were encountered1– too many subintervals were done2– excessive roundoff error3– extremely bad integrand behavior4– failed to converge5– integral is probably divergent or slowly convergent6– the input is invalid
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima('exp(-sqrt(x))').nintegral('x',0,1) (0.5284822353142306, 4.163...e-11, 231, 0)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima('exp(-sqrt(x))').nintegral('x',Integer(0),Integer(1)) (0.5284822353142306, 4.163...e-11, 231, 0)
from sage.interfaces.maxima_lib import maxima maxima('exp(-sqrt(x))').nintegral('x',0,1)Note that GP also does numerical integration, and can do so to very high precision very quickly:
sage: # needs sage.libs.pari sage: gp('intnum(x=0,1,exp(-sqrt(x)))') 0.52848223531423071361790491935415653022 sage: _ = gp.set_precision(80) sage: gp('intnum(x=0,1,exp(-sqrt(x)))') 0.52848223531423071361790491935415653021675547587292866196865279321015401702040079
>>> from sage.all import * >>> # needs sage.libs.pari >>> gp('intnum(x=0,1,exp(-sqrt(x)))') 0.52848223531423071361790491935415653022 >>> _ = gp.set_precision(Integer(80)) >>> gp('intnum(x=0,1,exp(-sqrt(x)))') 0.52848223531423071361790491935415653021675547587292866196865279321015401702040079
# needs sage.libs.pari gp('intnum(x=0,1,exp(-sqrt(x)))') _ = gp.set_precision(80) gp('intnum(x=0,1,exp(-sqrt(x)))')
- numer()[source]¶
Return numerical approximation to
selfas a Maxima object.OUTPUT: Maxima object
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: a = maxima('sqrt(2)').numer(); a 1.41421356237309... sage: type(a) <class 'sage.interfaces.maxima_lib.MaximaLibElement'>
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> a = maxima('sqrt(2)').numer(); a 1.41421356237309... >>> type(a) <class 'sage.interfaces.maxima_lib.MaximaLibElement'>
from sage.interfaces.maxima_lib import maxima a = maxima('sqrt(2)').numer(); a type(a)
- partial_fraction_decomposition(var='x')[source]¶
Return the partial fraction decomposition of
selfwith respect to the variable var.INPUT:
var– string
OUTPUT: Maxima object
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: f = maxima('1/((1+x)*(x-1))') sage: f.partial_fraction_decomposition('x') 1/(2*(x-1))-1/(2*(x+1)) sage: print(f.partial_fraction_decomposition('x')) 1 1 --------- - --------- 2 (x - 1) 2 (x + 1)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> f = maxima('1/((1+x)*(x-1))') >>> f.partial_fraction_decomposition('x') 1/(2*(x-1))-1/(2*(x+1)) >>> print(f.partial_fraction_decomposition('x')) 1 1 --------- - --------- 2 (x - 1) 2 (x + 1)
from sage.interfaces.maxima_lib import maxima f = maxima('1/((1+x)*(x-1))') f.partial_fraction_decomposition('x') print(f.partial_fraction_decomposition('x'))
- real()[source]¶
Return the real part of this Maxima element.
OUTPUT: Maxima real
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima('2 + (2/3)*%i').real() 2
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima('2 + (2/3)*%i').real() 2
from sage.interfaces.maxima_lib import maxima maxima('2 + (2/3)*%i').real()
- str()[source]¶
Return string representation of this Maxima object.
OUTPUT: string
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima('sqrt(2) + 1/3').str() 'sqrt(2)+1/3'
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima('sqrt(2) + 1/3').str() 'sqrt(2)+1/3'
from sage.interfaces.maxima_lib import maxima maxima('sqrt(2) + 1/3').str()
- subst(val)[source]¶
Substitute a value or several values into this Maxima object.
INPUT:
val– string representing substitution(s) to perform
OUTPUT: Maxima object
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima('a^2 + 3*a + b').subst('b=2') a^2+3*a+2 sage: maxima('a^2 + 3*a + b').subst('a=17') b+340 sage: maxima('a^2 + 3*a + b').subst('a=17, b=2') 342
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima('a^2 + 3*a + b').subst('b=2') a^2+3*a+2 >>> maxima('a^2 + 3*a + b').subst('a=17') b+340 >>> maxima('a^2 + 3*a + b').subst('a=17, b=2') 342
from sage.interfaces.maxima_lib import maxima maxima('a^2 + 3*a + b').subst('b=2') maxima('a^2 + 3*a + b').subst('a=17') maxima('a^2 + 3*a + b').subst('a=17, b=2')
- class sage.interfaces.maxima_abstract.MaximaAbstractElementFunction(parent, name, defn, args, latex)[source]¶
Bases:
MaximaAbstractElementCreate a Maxima function with the parent
parent, namename, definitiondefn, argumentsargsand latex representationlatex.INPUT:
parent– an instance of a concrete Maxima interfacename– stringdefn– stringargs– string; comma separated names of argumentslatex– string
OUTPUT: Maxima function
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: maxima.function('x,y','e^cos(x)') e^cos(x)
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> maxima.function('x,y','e^cos(x)') e^cos(x)
from sage.interfaces.maxima_lib import maxima maxima.function('x,y','e^cos(x)')- arguments(split=True)[source]¶
Return the arguments of this Maxima function.
INPUT:
split– boolean; ifTruereturn a tuple of strings, otherwise return a string of comma-separated arguments
OUTPUT: string if
splitis Falsea list of strings if
splitis True
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: f = maxima.function('x,y','sin(x+y)') sage: f.arguments() ['x', 'y'] sage: f.arguments(split=False) 'x,y' sage: f = maxima.function('', 'sin(x)') sage: f.arguments() []
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> f = maxima.function('x,y','sin(x+y)') >>> f.arguments() ['x', 'y'] >>> f.arguments(split=False) 'x,y' >>> f = maxima.function('', 'sin(x)') >>> f.arguments() []
from sage.interfaces.maxima_lib import maxima f = maxima.function('x,y','sin(x+y)') f.arguments() f.arguments(split=False) f = maxima.function('', 'sin(x)') f.arguments()
- definition()[source]¶
Return the definition of this Maxima function as a string.
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: f = maxima.function('x,y','sin(x+y)') sage: f.definition() 'sin(x+y)'
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> f = maxima.function('x,y','sin(x+y)') >>> f.definition() 'sin(x+y)'
from sage.interfaces.maxima_lib import maxima f = maxima.function('x,y','sin(x+y)') f.definition()
- integral(var)[source]¶
Return the integral of
selfwith respect to the variable var.INPUT:
var– a variable
OUTPUT: Maxima function
Note that integrate is an alias of integral.
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: x,y = var('x,y') sage: f = maxima.function('x','sin(x)') sage: f.integral(x) -cos(x) sage: f.integral(y) sin(x)*y
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> x,y = var('x,y') >>> f = maxima.function('x','sin(x)') >>> f.integral(x) -cos(x) >>> f.integral(y) sin(x)*y
from sage.interfaces.maxima_lib import maxima x,y = var('x,y') f = maxima.function('x','sin(x)') f.integral(x) f.integral(y)
- integrate(var)[source]¶
alias of
integral().
- sage.interfaces.maxima_abstract.maxima_console()[source]¶
Spawn a new Maxima command-line session.
EXAMPLES:
sage: from sage.interfaces.maxima_abstract import maxima_console sage: maxima_console() # not tested Maxima 5.46.0 https://maxima.sourceforge.io ...
>>> from sage.all import * >>> from sage.interfaces.maxima_abstract import maxima_console >>> maxima_console() # not tested Maxima 5.46.0 https://maxima.sourceforge.io ...
from sage.interfaces.maxima_abstract import maxima_console maxima_console() # not tested
- sage.interfaces.maxima_abstract.maxima_version()[source]¶
Return Maxima version.
Currently this calls a new copy of Maxima.
EXAMPLES:
sage: from sage.interfaces.maxima_abstract import maxima_version sage: maxima_version() # random '5.41.0'
>>> from sage.all import * >>> from sage.interfaces.maxima_abstract import maxima_version >>> maxima_version() # random '5.41.0'
from sage.interfaces.maxima_abstract import maxima_version maxima_version() # random
- sage.interfaces.maxima_abstract.reduce_load_MaximaAbstract_function(parent, defn, args, latex)[source]¶
Unpickle a Maxima function.
EXAMPLES:
sage: from sage.interfaces.maxima_lib import maxima sage: from sage.interfaces.maxima_abstract import reduce_load_MaximaAbstract_function sage: f = maxima.function('x,y','sin(x+y)') sage: _,args = f.__reduce__() sage: g = reduce_load_MaximaAbstract_function(*args) sage: g == f True
>>> from sage.all import * >>> from sage.interfaces.maxima_lib import maxima >>> from sage.interfaces.maxima_abstract import reduce_load_MaximaAbstract_function >>> f = maxima.function('x,y','sin(x+y)') >>> _,args = f.__reduce__() >>> g = reduce_load_MaximaAbstract_function(*args) >>> g == f True
from sage.interfaces.maxima_lib import maxima from sage.interfaces.maxima_abstract import reduce_load_MaximaAbstract_function f = maxima.function('x,y','sin(x+y)') _,args = f.__reduce__() g = reduce_load_MaximaAbstract_function(*args) g == f