Maxima

Maxima is a system for the manipulation of symbolic and numerical expressions, including differentiation, integration, Taylor series, Laplace transforms, ordinary differential equations, systems of linear equations, polynomials, and sets, lists, vectors, matrices, and tensors.

Maxima is a descendant of Macsyma, the legendary computer algebra system developed in the late 1960s at the Massachusetts Institute of Technology.

Maxima may be freely downloaded from http://maxima.sourceforge.net/

Maxima can be run as a stand-alone program.

(Note that the Sage software package also includes Maxima. )

Here are some examples using Maxima.

* * *

Partial fraction expansion example

partfrac ( 1/((x+a)*(x+b)),x);

Evaluate

1/((b-a)*(x+a))-1/((b-a)*(x+b))

* * *

Laplace transform example

laplace(exp(-a*t)*cos(b*t),t,s);
assume(b > 0);

Evaluate

(s+a)/(s^2+2*a*s+b^2+a^2)

* * *

Inverse Laplace transform example

ilt((s+a)/(s^2+2*a*s+b^2+a^2),s,t);

Evaluate

%e^(-a*t)*cos(b*t)

* * *

Integration of a function with variable coefficients.

integrate(a*(sin(b*x))^2, x);

Evaluate

(a*(b*x-sin(2*b*x)/2))/(2*b)

* * *

Evaluation of a double integral.

a(r,s):=(1+r)*(1+s);
integrate(integrate(a(r,s)^2,r,-1,1),s,-1,1);

Evaluate

64/9

* * *

In some cases, Maxima will ask whether an expression is positive, negative, or zero.  Here is an example:

Note that the “positive” reply is enter on the same line as the equation after the question is asked.

* * *

Matrix Multiplication

Q:matrix([a,b],[c,d]);
R:matrix([e,f],[g,h]);
S:Q.R;

Evaluate

matrix([b*g+a*e,b*h+a*f],[d*g+c*e,d*h+c*f])

* * *
Define a function in terms of the derivative of another function:

f(x) := 2*x^4;
define (g(x), diff (f(x), x) – 8);

Evaluate

g(x):=8*x^3-8

* * *

Tom Irvine

Sage Notebook, Partial Fraction Decomposition

Sage Notebook is a free web-based, open-source, mathematical worksheet development environment. It is an alternative to Magma, Maple, Mathematica, and MATLAB. It can perform symbolic algebraic and calculus operations.

* * *

Here is an example of an algebraic computation in Sage….

Partial fraction decomposition with variable coefficients:

f(a,b,x)=1/((x+a)*(x+b))
f.partial_fraction(x)

Evaluate

(a, b, x) |–> 1/((b + x)*(a – b)) – 1/((a + x)*(a – b))

* * *

Here is an example for an inverse Laplace transform:

var(‘a b s t’)
assume(b>0)
inverse_laplace((s+a)/((s+a)^2+b^2),s,t)

Evaluate

e^(-a*t)*cos(b*t)

* * *

Here is an example for the solution of a second-order ODE for the free vibration response of a single-degree-of-freedom system.

damp,omegan,t = var(‘damp omegan t’)
x=function(‘x’,t)
assume(damp-1 0)
desolve(diff(x,t,2)+2*damp*omegan*diff(x,t,1)+omegan^2*x==0,x,ivar=t,contrib_ode=True)

Evaluate

(k1*sin(1/2*sqrt(-4*damp^2*omegan^2 + 4*omegan^2)*t) +
k2*cos(1/2*sqrt(-4*damp^2*omegan^2 + 4*omegan^2)*t))*e^(-damp*omegan*t)

Note that:

k1 and k2 are coefficients which must be determined from the initial conditions.

omegan is the undamped natural frequency (radians/time).

1/2*sqrt(-4*damp^2*omegan^2 + 4*omegan^2) is the damped natural frequency.

* * *

Indefinite intergal example:

x, a, b = var(‘x a b’)
integral(a*(sin(b*x))^2, x)

Evaluate

1/4*(2*b*x – sin(2*b*x))*a/b

* * *

Definite intergal with variable coefficients example:

x,a,b = var(‘x,a,b’)
integral(a*(sin(b*x))^2, x, 0, pi)

Evaluate

1/4*(2*pi*b – sin(2*pi*b))*a/b

* * *
Tom Irvine