Linear Algebra with Maple

    |\^/|     Maple V Release 5 (University of Nevada, Reno)
._|\|   |/|_. Copyright (c) 1981-1997 by Waterloo Maple Inc. All rights
 \  MAPLE  /  reserved. Maple and Maple V are registered trademarks of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.
Enter with(linalg) in order to access the linear algebra functions in Maple.
> with(linalg);
Warning, new definition for norm
Warning, new definition for trace
[BlockDiagonal, GramSchmidt, JordanBlock, LUdecomp, QRdecomp, Wronskian, addcol,
    addrow, adj, adjoint, angle, augment, backsub, band, basis, bezout,
    blockmatrix, charmat, charpoly, cholesky, col, coldim, colspace, colspan,
    companion, concat, cond, copyinto, crossprod, curl, definite, delcols,
    delrows, det, diag, diverge, dotprod, eigenvals, eigenvalues, eigenvectors,
    eigenvects, entermatrix, equal, exponential, extend, ffgausselim, fibonacci,
    forwardsub, frobenius, gausselim, gaussjord, geneqns, genmatrix, grad,
    hadamard, hermite, hessian, hilbert, htranspose, ihermite, indexfunc,
    innerprod, intbasis, inverse, ismith, issimilar, iszero, jacobian, jordan,
    kernel, laplacian, leastsqrs, linsolve, matadd, matrix, minor, minpoly,
    mulcol, mulrow, multiply, norm, normalize, nullspace, orthog, permanent,
    pivot, potential, randmatrix, randvector, rank, ratform, row, rowdim,
    rowspace, rowspan, rref, scalarmul, singularvals, smith, stackmatrix,
    submatrix, subvector, sumbasis, swapcol, swaprow, sylvester, toeplitz,
    trace, transpose, vandermonde, vecpotent, vectdim, vector, wronskian]

> A:=matrix([[1.0,3.0,2.0],[3.0,4.0,5.0],[2.0,4.0,7.0]]);

                                 [1.0    3.0    2.0]
                            A := [3.0    4.0    5.0]
                                 [2.0    4.0    7.0]
Enter the matrix using decimals so that Maple will calculate using decimal numbers rather than complicated roots.
> AI:=inverse(A);
                   [-.4705882353    .7647058824     -.4117647059 ]
             AI := [.6470588235     -.1764705882    -.05882352941]
                   [-.2352941176    -.1176470588     .2941176471 ]

> multiply(A,AI);
                  [                      -9             -9  ]
                  [1.000000001      .2 10          .1 10    ]
                  [                                         ]
                  [     0         1.000000000         0     ]
                  [                                         ]
                  [                      -9                 ]
                  [     0           .6 10        1.000000001]
A matrix times its inverse should be the identity matrix. Since we are dealing with decimals then the above is only approximately the identity matrix.
> V:=eigenvects(A);

V := [-.9376332906, 1, {[-.731934904, .5267586674, -.0810272829]}],
    [11.33860445, 1, {[-.4195624769, -.8156369199, -.9453898592]}],
    [1.599028852, 1, {[-.5046157621, -.4450937319, .5165008996]}]
Note that the result returned is a sequence of lists of the form [ei, mi, {v[1,i],... v[ni,i]}], where the ei are the eigenvalues, mi their algebraic multiplicities, {v[1,i], ..., v[ni,i]} is a set of basis vectors for the eigenspace corresponding to ei, and 1 <= ni <= mi is the dimension of the eigenspace.
> xi:=V[1][3][1];
                 xi := [-.731934904, .5267586674, -.0810272829]
> lambda:=V[1][1];
                             lambda := -.9376332906
> multiply(A,xi);
                    [.6862865322, -.4939064565, .0759738817]
> evalm(lambda*xi);
                   [.6862865325, -.4939064627, .07597387789]
The matrix A times the eigenvector xi is the approximately the same as the eigenvalue lambda times the eigenvector.
> P:=matrix([seq(V[i][3][1],i=1..3)]);

                   [-.731934904     .5267586674     -.0810272829]
              P := [-.4195624769    -.8156369199    -.9453898592]
                   [-.5046157621    -.4450937319    .5165008996 ]
Here P is a matrix with an eigenvector for each row.
> Q:=transpose(P);
                   [-.731934904     -.4195624769    -.5046157621]
              Q := [.5267586674     -.8156369199    -.4450937319]
                   [-.0810272829    -.9453898592    .5165008996 ]

> QI:=inverse(Q);
                    [-.8420643017    .6937630197     -.2248386169]
              QI := [-.2360065894    -.4189326797    -.5915903631]
                    [-.5640811448    -.6579678270    .8180013003 ]
To transform the matrix A into a diagonal matrix with the eigenvalues on the diagonal multiply A by Q on the right and the inverse of Q on the left.
> multiply(QI,multiply(A,Q));

                  [                        -7             -8 ]
                  [-.9376332867     -.12 10        -.20 10   ]
                  [                                          ]
                  [         -8                            -8 ]
                  [ -.476 10       11.33860444     -.47 10   ]
                  [                                          ]
                  [        -9             -8                 ]
                  [ -.78 10          .3 10        1.599028851]

> quit;
bytes used=938988, alloc=786288, time=1.50

Last updated: Wed Apr 18 21:03:57 PDT 2001