Linear Algebra with Maple  - MTH 362 Fall 2000

> restart;                     # Start with clean slate 
> with(linalg):                # this loads the linear algebra package
> A:=matrix([[1,2],[3,4]]);    # Define a matrix named "A"
> B:=matrix([[2,-3],[1,4]]);   # Define a matrix named "B"
> C := A+B;                    # Add the matrices A and B, call it "C"
> evalm(C);                    # To see the entries of C type this 
> evalm(2*A - 5*B);            # multiplication by a scalar and subtraction
> D:=2*A + 7*B;                # The symbol D is reserved in maple.
> E:=transpose(C);             # Transpose of a matrix
> inverse(C);                  # inverse of a matrix
> A&*B;                        # multiplication of matrices in maple 
                               #      requires &* instead of *
> evalm(%);                    # Here is the answer
> v := vector([1 , -3]);       # vectors are column vectors written 
                               #      horizontally to save space
> A&*v;                        # A matrix times a vector
> evalm(%);                    # Recall that the answer is a column vector
> evalm(v&*A);                 # Maple considers a vector multiplying on 
                               # the left as a row vector
> a:=vector([1,0,2]);
> b:=vector([-2,1,2]);
> innerprod(a,b);              # the inner product of the vectors a and b
> evalf(angle(a,b));           # The angle between a and b (in radians)
> norm(a,2);                   # The magnitude of the vector a 
> U := matrix([[1,1,2],[0,4,3],[-1,-2,-3]]): 
> augment(U,a);                # The matrix U augmented with the vector a
> det(U);                      # The determinant of U
> trace(U);                    # The trace of U
> rank(U);                     # The rank of U
> inverse(U);                  # The inverse of U 
> delrows(U,3..3);             # Delete row 3 from U
> rowspace(U);                 # A basis for the row space of U
> x:=linsolve(U,a);            # Solve the system U x = a
> evalm(U&*x-a);               # Check the answer to previous problem
> U1 := augment(U,a);          # Augmented matrix
> U2:=gausselim(U1);           # Gaussian elimination 
                               #     - reduction to upper triangular form
> x1:=backsub(U2);             # Solve upper triangular system 
                               #       by back substitution
> evalm(A);                    # Recall the matrix A
> eigenvals(A);                # eigenvalues of A
> eigenvects(A);               # eigenvectors of A
> eigenvects([[1,1],[0,1]]);   # An eigenvalue that repeats, 
                               #      and only one associated eigenvector
> eigenvects([[2,1],[-1,2]]);  # complex eigenvalues and eigenvectors