UI MATH 2850 - Using Maple for Some Matrix Operations

Unformatted text preview:

22M:28Spring 07J. SimonGift for M27 StudentsUsing Maple for (Some) Matrix OperationsI'll use the built-in package "linalg".There is a newer package "LinearAlgebra". You can find out about that by entering the command for help, "? LinearAlgebra".When you enter the command "with [some package]", you get a list of the built-in operations that come in that package.> with(linalg);Warning, the protected names norm and trace have been redefined and unprotected[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]> M:=matrix([[1,2,3], [4,5,6], [9,8,7]]);M := 1 2 34 5 69 8 7éêêêêëùúúúúûThe determinant and (if M is invertible) inverse of M are built-in operations.> det(M);0Oops. Since det(M) = 0, M is not invertible - there is no inverse matrix for M. If we put M in row-reduced echelon form, we can see that.> rref(M);1 0 -10 1 20 0 0éêêêêëùúúúúûLet's change M to get an invertible matrix. We will change the entry in row 3, column 2.> M[3,2]:=5;M3, 2 := 5> print(M);1 2 34 5 69 5 7éêêêêëùúúúúû> det(M);-18That's better. Now M is invertible.> inverse(M);-518-11816-139109-132518-131816éêêêêêêêêêêëùúúúúúúúúúúûNote that Maple calculated the inverse in as much time as it took me to hit the "enter" key.If we want decimals, use the extra command "evalf", which means "evaluate as floating-point numbers".> evalf(M);MSometimes Maple give back cryptic, annoying replies like this. I wanted the matrix of numbers, and Maple didn't feel like writing all that. So let's force it by the command "evalm", which means "evaluate as a matrix", and should result in a printout of the matrix.> evalm(evalf(inverse(M)));-0.2777777778 -0.05555555556 0.1666666667-1.444444444 1.111111111 -0.33333333331.388888889 -0.7222222222 0.1666666667éêêêêëùúúúúûHere is how to multiply matrices.Since M has 3 columns, we can multiply M by any matrix with 3 rows.> N:=matrix([[2,0], [-1,3], [1,4]]);N := 2 0-1 31 4éêêêêëùúúúúûTo indicate matrix multiplication, you don't just write M*N. If I try that, here is the reprimand.> evalm(M*N);Error, (in evalm/evaluate) use the &* operator for matrix/vector multiplication> evalm(M &* N);3 189 3920 43éêêêêëùúúúúûFinally, here is how you can use Maple to solve a system of linear equations.We use the command "solve". We use {...} notation to denote a set of equations. We need to tell the computer what are the variables. This is because the computer could also solve the system if we had some parameters instead of the numerical coefficients.> solve({2*x+3*y=4, 5*x-7*y=11}, {x,y});y = -229, x = 6129ìíîüýþIf the system is inconsistent, we get no reply; Maple just won't do it.> solve({2*x+3*y=4, 2*x+3*y=5}, {x,y});If the system has infinitely many solutions, we would get something like> solve({2*x+3*y=4, 4*x+6*y=8}, {x,y});x = 2 - 32 y, y = yìíîüýþThat is Maple's way of telling us that there are infinitely many solutions: let y be anything, and then take x=2 - (3/2)y.##########I hope you find this useful as a way to check your various calculations in linear


View Full Document

UI MATH 2850 - Using Maple for Some Matrix Operations

Download Using Maple for Some Matrix Operations
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Using Maple for Some Matrix Operations and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Using Maple for Some Matrix Operations 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?