MATH
21 B
Mathematics Math21b Spring 2007
Linear Algebra and Differential Equations
CAS
Course Head: Oliver Knill
Office: SciCtr 434



Listen to a few of the best tunes produced with the Mathematica assignment [.nb notebook] which was due the last day of class, which is May 4 for MWF sections and May 3 for TTh sections. You turned it in as a printout in class to your section leader. You can see the lab here [HTML] as a HTML preview. There were 7 problems at the end of the assignment. You need to do 5 complete answers to get full credit. The lab was designed as a light assignment. It can be done in a relatively short time, but don't wait until the last day. We have sample code for all the problems already in the notebook. Still, things which can go wrong always go wrong, especially in time pressure, so start early. If you have a question, ask Oliver.


It is useful to know what can be done with computer algebra systems "the four M's". Mathematica, Matlab or Maple and Maxima. The example snippets should become selfexplanatory during the course.

Mathematica

Harvard has a Mathematica site license. You can get it here and request a password, using the Harvard Site License Number L2482-2405.

A={{1,2,3},{4,5,5},{6,7,8}}
v={5,-2,3}
Inverse[A]
A.v
A.A.A
LinearSolve[A,v]
RowReduce[A]
QRDecomposition[{{1,0,0},{1,1,0},{1,1,1}}]
Fit[{{0,0},{0,1},{1,3}},{1,x,x^2},x]
CharacteristicPolynomial[A,x]
Tr[A]
Det[A]
Eigenvalues[A]
Eigensystem[A]

Matlab

Matlab is a CAS which is strong in linear algebra. Matlab is available as a student version. Here are some of the above commands in Matlab.

A = [1 2 3; 4 5 5; 6 7 8]
v = [5;-2;3]
inv(A)
A*v
A*A*A
Av
rref(A)
qr(A)
poly(A)
det(A)
trace(A)
eig(A)
[v,d]=eig(A)

Maple

Maple is a CAS comparable with Mathematica or Matlab. Here are the same commands in the Maple dialect.

with(linalg);
A:=[[1,2,3],[4,5,5],[6,7,8]];
v:=[5,-2,3];
inverse(A);
multiply(A,v); 
evalm(A*A*A);
linsolve(A,v);
rref(A);
v1:=[1,0,0]; v2:=[1,1,0]; v3:=[1,1,1];
GramSchmidt({v1,v2,v3});
charpoly(A,x);
trace(A); 
det(A); 
eigenvalues(A);
eigenvectors(A); 

Maxima

Maxima is an open source CAS originally developed by the DOE. While having less features than the commercial CAS, it is GPL'd and free software: you can see the code.
(echelon(A) is here an upper triangular matrix);
A: matrix([1,2,3],[4,5,5],[6,7,8]);
v: [5,-2,3];
invert(A);
A.v;
A.A.A;
linsolve([x+z=5,x+5*y=-2,x-z=0],[x,y,z]);
echelon(A);
load(eigen); gramschmidt(A); 
determinant(A); 
charpoly(A,x);
eigenvalues(A);
eigenvectors(A);
Please send questions and comments to math21b@fas.harvard.edu
Math21b | Oliver Knill | Spring 2007 | Department of Mathematics | Faculty of Art and Sciences | Harvard University