# Maxima

Robert P. Munafo, 2007 Jan 27.

Maxima, originally known as MACSYMA, is a symbolic-math package comparable to Mathematica, Maple and MATLAB, but available free of charge in open-source, GPL form.

For more information, go here.

To perform the math work shown in the Brown Method, lemniscates, R2.1/3a and other pages, I used SBCL 0.9.14 and maxima-5.9.3 running on a MacOS X system.

Following are some examples of operations performed with maxima, based on this tutorial by Zdzislaw Meglicki at Indiana University:

Ordinary arithmetic:

7 * 27 / 1.43;

200!; Note bignum output

factor(200!);

ezgcd(10,15); GCD of items followed by "remaining part" of each

(2^30/3^20)*sqrt(3); output is in exact form/

ev(%, numer); shows the previous result as floating-point

Converting complex numbers from polar to orthogonal form:

rectform(ev(%e^%i, numer));

a : (3+5*%i)/(7+4*%i);

rectform(a);

polarform(a);

abs(a);

carg(a);

realpart(a);

imagpart(a);

carg(-1);

Calculate the limit of a function; in this case we're approaching a removable singularity.

limit(x/x, x, 0);

Performing basic algebra, e.g. expanding a binomial raised to a power:

expand((a+b)^3);

b : (x+y)^15;

expand(b);

factor(%);

Factoring polynomials:

p1: x^3-x^2;

p2: x^2+x-2;

factor([p1, p2]); note common factor of (x-1)

e: ezgcd(p1, p2);

e[1]*e[2];

expand(%); reconstructs p1

e2 : (x^3-y^3) / (x^2+x-y-y^2);

factor(e2);

ev(e2, x=1, y=2);

at(e2, [x=1, y=2]);

ur: (u^2-7*u+12)/(4u^2-36u+72); ratio of two polynomials

part(ur, 1); just the numerator

factor(%); numerator fctored

factor(ur); factor auto-distributes and the result auto-cancels

Algebraic manipulation with trig functions:

c : cos(x)^5 + sin(x)^4 + 2*cos(x)^2 - 2*sin(x)^2 - cos(2*x);

trigexpand(c);

trigsimp(%);

d : 2*cos(x/2)^2 * cos(x)^4;

trigrat(d);

trigexpand(%);

trigsimp(%);

Solving equations:

solve(x^2 = 1); only one variable — solves automatically

solve(a*x^2=4, x); one variable and one parameter

solve(a*x^2=4, a); treating a as the variable

solve([a+b=10, 2*a+b=12], [a,b]); system of equations in two variables

Finding all (real and/or complex) roots of an arbitrary-order polynomial (uses numerical methods):

allroots(x^6+4*x^5+6*x^4+10*x^3+11*x^2+9*x+4=0);

Performing an integral. (Maxima will ask three questions — answer positive; positive; negative;)

integrate(x^2*sin(alpha*x), x, 0, beta);

Series sums, and products:

sum((1+i)/(1+i^4), i, 1, 10);

sum(1/k^2,k,1,inf); shows sigma-notation

%, simpsum; shows π^{2}/6/

sum(1/k^2,k,1,1000),numer;

%pi^2/6, numer; compare to previous

product(((i^2+3*i-11)/(i+3)), i, 0, 10);

Constructing lists and arrays:

makelist(i,i,1,31); integers from 1 to 31 inclusive

makelist((x+1)^a, a, 0, 5); first 5 binomials

expand(makelist((x+1)^a, a, 0, 5)); the same binomials, expanded (note that expand distributes)

makelist(expand((x+1)^a), a, 0, 5); same answer, different way

makelist(makelist(binomial(n, i), i, 0, n), n, 0, 10); 10 rows of Pascal's triangle

Defining functions; Taylor series (this particular Taylor series is mentioned in Darko Veberic, Having Fun with Lambert W(x) Function, arXiv:1003.1628v1 [cs.MS] 8 Mar 2010)

w1(y) := y*%e^y;

f(y) := 2*(%e*w1(y-1)+1);

functions; shows the functions you've defined so far

t1 : taylor(f(y), y, 0, 20);

makelist(coeff(t1,y,n), n, 0, 20); extracting the coefficients

makelist(ratnumer(coeff(t1,y,n)), n, 0, 20); extracting the numerators

makelist(ratdenom(coeff(t1,y,n)), n, 0, 20); extracting the denominators

Series inversion:

t1 : taylor(sin(x),x,0,10);

load ("revert")$

revert(t1, x);

ratexpand(%);

Decoding a generating function:

decode_gfun(f,x,N) := makelist(coeff(taylor(f,x,0,N),x,n),n,0,N);

decode_gfun(x / (1 - 6*x + x^2),x,12); gives terms of A001109

Some generating functions converge to a power series in positive exponents of x near x=0, and converge to another power series in negative exponents of x as x gets arbitrarily large, i.e. approaches infinity. The series that converges as x goes to infinity is called a "Laurent series". It is generated with the same command as a Taylor series, but with "inf" in place of the third argument "0":

taylor(1/(1-x-x^2), x, inf, 10);

Here are the power series for the first generating function from Ramanujan's lost notebook, where he discusses sums of cubes (see this article):

makelist(coeff(taylor((1+53*x+9*x^2)/(1-82*x-82*x^2+x^3), x, 0, 10),x,n),n,0,10);

makelist(coeff(taylor((1+53*x+9*x^2)/(1-82*x-82*x^2+x^3), x, inf, 10),x,n),n,1,10);

Expanding the Chebyshev polynomials from their generating functions:

taylor((1-t*x)/(1-2*t*x+t^2),t,0,10);

taylor(1/(1-2*t*x+t^2),t,0,10);

Stuff I haven't annotated yet:

f(x) := x^2 + 1/2;

define(g(x), x^2 + 1/2);

f(x) := x * sin(a*x) + b*x^2;

diff(f(x),x);

diff(f(x), x, 2);

'diff(f(x),x);

ev(%, diff);

g(x) := 'diff(f(x),x);

g(x);

g(x), diff;

g(x) := diff(f(x),x);

g(x);

at(g(x), [a=1, b=2, x=3]);

for i:1 thru 16 step 1 do block(display(N(i)));

divisors(100); builtin function that returns an array

for i in divisors(100) do display(i); iterates over the array returned by divisors

From the Mandelbrot Set Glossary and Encyclopedia, by Robert Munafo, (c) 1987-2022. Mu-ency index

This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2016 Jun 11. s.27