CoCalc Public Filesmaxima_md test.sagewsOpen with one click!
Authors: David Cyganski, Bill Page
Views : 47
Description: Markdown mode for Maxima
Compute Environment: Ubuntu 18.04 (Deprecated)
%sage # Markdown mode for Maxima def maxima_md(s): import re #print s # insert calls to tex around expressions separated by $ or ; or as a single expression per line s=re.compile(r'((?:(?![\n\$;]).)+)([\$;\n]?)',re.M+re.S).sub(r'tex(\1,false)\2',s,count=0) #print s t = maxima.eval(s,split_lines=true, reformat=false) # cleanup generated LaTeX for MathJax t=re.compile(r'\$\$').sub('\n$$\n',t,count=0) t=re.compile(r'\\\\').sub(r'\\',t,count=0) t=re.compile(r'\\cos').sub(r'\\mathrm{cos}',t,count=0) t=re.compile(r'\\sin').sub(r'\\mathrm{sin}',t,count=0) t=re.compile(r'\\_').sub(r'_',t,count=0) t=re.compile(r'\\begin{verbatim}').sub(r'$$',t,count=0) t=re.compile(r'\\end{verbatim}').sub(r'$$',t,count=0) # strip non-escaped string quotes t=re.compile(r'[^\\]"([^"]*?)').sub(r'\1',t,count=0) # remove escape chars before quotes t=re.compile(r'\\"').sub('"',t,count=0) # Maybe this just text output? Indent as a preformatted code block t=re.compile(r'\n\s*([^\$].*)').sub(r' \1',t,count=0) # hide input and output numbers (Sage makes it impossible to use them anyway.) t=re.compile(r'\(\%o[0-9]+\)').sub(r'',t) t=re.compile(r'\(\%i[0-9]+\) ').sub(r'',t) #print "'",t,"'" md(t, hide=False) %default_mode maxima_md
x * y * z; x+1; y^2 z^3

xyz x\,y\,z
x+1 x+1
y2 y^2
z3 z^3


xcosx2sinx2 {{x\,\mathrm{cos} x^2}\over{\sqrt{\mathrm{sin} x^2}}}

integrate (1/(1+x^3), x)

log(x2x+1)6+arctan(2x13)3+log(x+1)3 -{{\log \left(x^2-x+1\right)}\over{6}}+{{\arctan \left({{2\,x-1 }\over{\sqrt{3}}}\right)}\over{\sqrt{3}}}+{{\log \left(x+1\right) }\over{3}}


μe \mu_e

me+1 me+2

μe+1 \mu_e+1
μe+2 \mu_e+2


2.718281828459045 2.718281828459045


1 1


1 1

f(x):= x^2 -x + 1

f(x):=1x+x2; f(x):=1-x+x^2;


7 7


226314577411213217192329 2^{26}\,3^{14}\,5^7\,7^4\,11^2\,13^2\,17\,19\,23\,29

s:solve(x^3=1,x) s[1]

[x=3i12,x=3i+12,x=1] \left[ x={{\sqrt{3}\,i-1}\over{2}} , x=-{{\sqrt{3}\,i+1}\over{2}} , x=1 \right]
x=3i12 x={{\sqrt{3}\,i-1}\over{2}}

ev(sum(k, k, 1, n), simpsum)

n2+n2 {{n^2+n}\over{2}}

'diff (y, x, 2) + 'diff (y, x) + y

2x2y+xy+y {{{\it \partial}^2}\over{{\it \partial}\,x^2}}\,y+{{{\it \partial} }\over{{\it \partial}\,x}}\,y+y



eigenvectors (m)

[[[3352,33+52],[1,1]],[[[1,3334]],[[1,33+34]]]] \left[ \left[ \left[ -{{\sqrt{33}-5}\over{2}} , {{\sqrt{33}+5 }\over{2}} \right] , \left[ 1 , 1 \right] \right] , \left[ \left[ \left[ 1 , -{{\sqrt{33}-3}\over{4}} \right] \right] , \left[ \left[ 1 , {{\sqrt{33}+3}\over{4}} \right] \right] \right] \right]

batch ("critpts.max")
read and interpret file: /projects/b04b5777-e269-4c8f-a4b8-b21dbe1c93c6/critpts.max
critpts(f):=(print("program to find critical points"),newline(),
print(" f = ",f),eqs:[diff(f,x),diff(f,y)],unk:[x,y],

critpts ((y+x)*%e^(y^2+x^3))
program to find critical points 
f =  (y+x)*%e^(y^2+x^3) 

[[x=0.4588955685487001i+0.3589790871086935,y=0.4942017368275118i0.1225787367783657],[x=0.35897908710869350.4588955685487001i,y=0.4942017368275118i0.1225787367783657],[x=0.4187542327234816i0.6923124204420268,y=0.4559120701116990.8697262692814121i],[x=0.4187542327234816i0.6923124204420268,y=0.8697262692814121i+0.455912070111699]] \left[ \left[ x=0.4588955685487001\,i+0.3589790871086935 , y= 0.4942017368275118\,i-0.1225787367783657 \right] , \left[ x= 0.3589790871086935-0.4588955685487001\,i , y=-0.4942017368275118\,i- 0.1225787367783657 \right] , \left[ x=0.4187542327234816\,i- 0.6923124204420268 , y=0.455912070111699-0.8697262692814121\,i \right] , \left[ x=-0.4187542327234816\,i-0.6923124204420268 , y= 0.8697262692814121\,i+0.455912070111699 \right] \right]

computes 10\sqrt{10}

w: 1.$ r:for n: 1 thru 10 do (w0: w, w: .5*(w + 10./w), if w = w0 then return(w)); r^2

3.162277660168379 3.162277660168379
9.999999999999998 9.999999999999998

assume (b > 0)$ integrate (1/(1 + x), x, 0, b)

log(b+1) \log \left(b+1\right)

eqn: 'diff(x,t,2) + r*'diff(x,t)^2 = 0 sol: ode2(eqn, x, t)

2t2x+3.162277660168379(tx)2=0 {{{\it \partial}^2}\over{{\it \partial}\,t^2}}\,x+3.162277660168379 \,\left({{{\it \partial}}\over{{\it \partial}\,t}}\,x\right)^2=0
rat: replaced 3.162277660168379 by 39480499/12484830 = 3.16227766016838

x=12484830log(39480499t+39480499%k1)39480499+%k2 x={{12484830\,\log \left(39480499\,t+39480499\,{\it \%k_1}\right) }\over{39480499}}+{\it \%k_2}

-- Function: integrate
integrate (<expr>, <x>)
integrate (<expr>, <x>, <a>, <b>)
Attempts to symbolically compute the integral of <expr> with
respect to <x>.  'integrate (<expr>, <x>)' is an indefinite
integral, while 'integrate (<expr>, <x>, <a>, <b>)' is a definite
integral, with limits of integration <a> and <b>.  The limits
should not contain <x>, although 'integrate' does not enforce this
restriction.  <a> need not be less than <b>.  If <b> is equal to
<a>, 'integrate' returns zero.
See 'quad_qag' and related functions for numerical approximation of
definite integrals.  See 'residue' for computation of residues
(complex integration).  See 'antid' for an alternative means of
computing indefinite integrals.
The integral (an expression free of 'integrate') is returned if
'integrate' succeeds.  Otherwise the return value is the noun form
of the integral (the quoted operator ''integrate') or an expression
containing one or more noun forms.  The noun form of 'integrate' is
displayed with an integral sign.
In some circumstances it is useful to construct a noun form by
hand, by quoting 'integrate' with a single quote, e.g., ''integrate
(<expr>, <x>)'.  For example, the integral may depend on some
parameters which are not yet computed.  The noun may be applied to
its arguments by 'ev (<i>, nouns)' where <i> is the noun form of
'integrate' handles definite integrals separately from indefinite,
and employs a range of heuristics to handle each case.  Special
cases of definite integrals include limits of integration equal to
zero or infinity ('inf' or 'minf'), trigonometric functions with
limits of integration equal to zero and '%pi' or '2 %pi', rational
functions, integrals related to the definitions of the 'beta' and
'psi' functions, and some logarithmic and trigonometric integrals.
Processing rational functions may include computation of residues.
If an applicable special case is not found, an attempt will be made
to compute the indefinite integral and evaluate it at the limits of
integration.  This may include taking a limit as a limit of
integration goes to infinity or negative infinity; see also
Special cases of indefinite integrals include trigonometric
functions, exponential and logarithmic functions, and rational
functions.  'integrate' may also make use of a short table of
elementary integrals.
'integrate' may carry out a change of variable if the integrand has
the form 'f(g(x)) * diff(g(x), x)'.  'integrate' attempts to find a
subexpression 'g(x)' such that the derivative of 'g(x)' divides the
integrand.  This search may make use of derivatives defined by the
'gradef' function.  See also 'changevar' and 'antid'.
If none of the preceding heuristics find the indefinite integral,
the Risch algorithm is executed.  The flag 'risch' may be set as an
'evflag', in a call to 'ev' or on the command line, e.g., 'ev
(integrate (<expr>, <x>), risch)' or 'integrate (<expr>, <x>),
risch'.  If 'risch' is present, 'integrate' calls the 'risch'
function without attempting heuristics first.  See also 'risch'.
'integrate' works only with functional relations represented
explicitly with the 'f(x)' notation.  'integrate' does not respect
implicit dependencies established by the 'depends' function.
'integrate' may need to know some property of a parameter in the
integrand.  'integrate' will first consult the 'assume' database,
and, if the variable of interest is not there, 'integrate' will ask
the user.  Depending on the question, suitable responses are 'yes;'
or 'no;', or 'pos;', 'zero;', or 'neg;'.
'integrate' is not, by default, declared to be linear.  See
'declare' and 'linear'.
'integrate' attempts integration by parts only in a few special
* Elementary indefinite and definite integrals.
integrate (sin(x)^3, x);
cos (x)
                   ------- - cos(x)
integrate (x/ sqrt (b^2 - x^2), x);
2    2
                    - sqrt(b  - x )
integrate (cos(x)^2 * exp(x), x, 0, %pi);
3 %e      3
                      ------- - -
5      5
integrate (x^2 * exp(-x^2), x, minf, inf);
* Use of 'assume' and interactive query.
assume (a > 1)$
    integrate (x**a/(x+1)**(5/2), x, 0, inf);
    2 a + 2
    Is  -------  an integer?
    Is  2 a - 3  positive, negative, or zero?
                      beta(a + 1, - - a)
    * Change of variable.  There are two changes of variable in this
    example: one using a derivative established by 'gradef', and
    one using the derivation 'diff(r(x))' of an unspecified
    function 'r(x)'.
    gradef (q(x), sin(x**2));
    diff (log (q (r (x))), x);
    d               2
    (-- (r(x))) sin(r (x))
    integrate (%, x);
    * Return value contains the ''integrate' noun form.  In this
    example, Maxima can extract one factor of the denominator of a
    rational function, but cannot factor the remainder or
    otherwise find its integral.  'grind' shows the noun form
    ''integrate' in the result.  See also 'integrate_use_rootsof'
    for more on integrals of rational functions.
    expand ((x-4) * (x^3+2*x+1));
    4      3      2
                  x  - 4 x  + 2 x  - 7 x - 4
    integrate (1/%, x);
    /  2
    [ x  + 4 x + 18
    I ------------- dx
    ]  3
    log(x - 4)   / x  + 2 x + 1
                ---------- - ------------------
    73               73
    grind (%);
* Defining a function in terms of an integral.  The body of a
function is not evaluated when the function is defined.  Thus
the body of 'f_1' in this example contains the noun form of
'integrate'.  The quote-quote operator '''' causes the
integral to be evaluated, and the result becomes the body of
f_1 (a) := integrate (x^3, x, 1, a);
           f_1(a) := integrate(x , x, 1, a)
ev (f_1 (7), nouns);
/* Note parentheses around integrate(...) here */
f_2 (a) := ''(integrate (x^3, x, 1, a));
a    1
                   f_2(a) := -- - -
4    4
f_2 (7);
There are also some inexact matches for `integrate'.
Try `?? integrate' to see them.

true \mathbf{true}