Linear Algebra
The file LinearAlgebra.mth defines functions that supplement the built-in linear algebra capabilities of Derive. The function definitions in the file are automatically loaded when any of its functions are first used. The file LinearAlgebra.dfw includes the definitions in the mth file along with comments and examples.
Row Reduction Primitives
The five functions in this section can be used to reduce a matrix to row echelon form, one step at a time using Gaussian or Gauss-Jordan elimination. This is useful for educational purposes, or because you may be able to make a better choice of pivots than the built-in function for finding the Row Echelon FormRow_Echelon_Form of a matrix.
SCALE_ELEMENT(v, i, s) simplifies to a copy of vector v with the ith element multiplied by the expression s. Note that if v is a matrix, the ith row is multiplied by s. For example,
SCALE_ELEMENT([1, 2, 3; 4, 5, 6; 7, 8, 9], 1, 4)
simplifies to
⎡ 4 8 12 ⎤
⎢ ⎥
⎢ 4 5 6 ⎥
⎢ ⎥
⎣ 7 8 9 ⎦
SWAP_ELEMENTS(v, i, j) simplifies to a copy of vector v with ith and jth elements interchanged. Note that if v is a matrix, the ith and jth rows are interchanged. For example,
SWAP_ELEMENTS([1, 2, 3; 4, 5, 6; 7, 8, 9], 1, 3)
simplifies to
⎡ 7 8 9 ⎤
⎢ ⎥
⎢ 4 5 6 ⎥
⎢ ⎥
⎣ 1 2 3 ⎦
SUBTRACT_ELEMENTS(v, i, j, s) simplifies to a copy of vector v in which the ith element is replaced with the ith element minus s times the jth element. s defaults to 1. For example,
SUBTRACT_ELEMENTS([1, 2, 3; 4, 5, 6; 7, 8, 9], 2, 1, 4)
simplifies to
⎡ 1 2 3 ⎤
⎢ ⎥
⎢ 0 -3 -6 ⎥
⎢ ⎥
⎣ 7 8 9 ⎦
FORCE0(A, i, j, p) simplifies to a copy of matrix A in which element Aij is forced to zero by subtracting an appropriate multiple of pivot row p from row i. FORCE0 combines scaling and subtraction to force an element of a matrix to zero in a single step. For example,
FORCE0([1, 2, 3; 4, 5, 6; 7, 8, 9], 2, 1, 1)
simplifies to
⎡ 1 2 3 ⎤
⎢ ⎥
⎢ 0 -3 -6 ⎥
⎢ ⎥
⎣ 7 8 9 ⎦
PIVOT(A, i, j) simplifies to a copy of matrix A in which the elements in the jth column below the ith row are forced to zero by subtracting appropriate multiples of the ith row from the rows below it. For example,
PIVOT([1, 2, 3; 4, 5, 6; 7, 8, 9], 1, 1)
simplifies to
⎡ 1 2 3 ⎤
⎢ ⎥
⎢ 0 -3 -6 ⎥
⎢ ⎥
⎣ 0 -6 -12 ⎦
Inverses and Adjoints by Cofactor Expansion
The three functions in this section can be used to compute determinants and inverses from first principles.
MINOR(A, i, j) simplifies to a copy of matrix A in which the ith row and the jth column are omitted. For example,
MINOR([1, 2, 3; 4, 5, 6; 7, 8, 9], 2, 2)
simplifies to
⎡ 1 3 ⎤
⎢ ⎥
⎣ 7 9 ⎦
COFACTOR(A, i, j) simplifies to the numerator of the row j column i element of the inverse of square matrix A. The corresponding element of the inverse is this numerator divided by the determinant of A.
Element growth is severe when computing inverses of matrices having nonnumeric elements. COFACTOR allows you to compute the matrix inverse one element at a time. Alternatively, a matrix inverse can be computed one column at a time by simplifying expressions of the form ROW_REDUCE(A, v), where v is a column of the identity matrix for dimension A.
COFACTOR can also be used to compute the determinant of a square matrix A, if simplifying DET(A) exhausts memory. If A is an n by n matrix, the determinant of A is the sum of expressions of the form A1i·COFACTOR(A, 1, i), where i goes from 1 to n. The determinant can also be computed by similarly expanding about any row or column of the matrix.
ADJOINT(A) simplifies to the adjoint or adjugate of square matrix A. The adjoint of A is the transpose of the matrix of cofactors of A. For example,
ADJOINT([2, x; 1, 3])
simplifies to
⎡ 3 -x ⎤
⎢ ⎥
⎣ -1 2 ⎦
Eigenvalues and Eigenvectors
The three functions in this section are for computing the null space and eigenvectors of matrices.
NULL_SPACE(M) simplifies to a basis for the null space of the matrix M. The null space is the set of vectors x satisfying the matrix equation M·x=0. The null space will be empty if M is invertible, and will be nonempty if M is rank-deficient. NULL_SPACE simplifies to a matrix in which each column is one basis vector for the null space. The result is in a form sometimes called the rational basis as distinct from the ortho-normal basis. Note that the product M·NULL_SPACE(M) should always simplify to the zero or empty matrix. For example,
NULL_SPACE([1, 2, 3; 1, 2, 3; 1, 2, 3])
simplifies to
⎡ 2 3 ⎤
⎢ ⎥
⎢ -1 0 ⎥
⎢ ⎥
⎣ 0 -1 ⎦
EXACT_EIGENVECTOR(A, µ) simplifies to the eigenvectors of matrix A corresponding to the exact eigenvalue µ. If µ is an exact eigenvalue of the square matrix A, the corresponding eigenvectors (characteristic vectors) are the nonzero vectors x that satisfies the singular homogeneous system (A - µ·I) x = 0. Equivalently, the eigenvectors form the null space of the matrix (A - µ·I). If the eigenvalue has multiplicity m, then generally there are m eigenvectors; otherwise the matrix is called defective. The built-in function EIGENVALUES can be used to compute the exact eigenvalues of a matrix (see EigenvaluesEigenvalues). For example,
EIGENVALUES([1, 2; 1, 1])
simplifies to [SQRT(2) + 1, 1 – SQRT(2)], and
EXACT_EIGENVECTOR([1, 2; 1, 1], SQRT(2) + 1)
simplifies to [- SQRT(2); -1].
If µ is only an approximate eigenvalue, the matrix A - µ·I is nonsingular. In that case EXACT_EIGENVECTOR returns the zero vector since that is the only solution of (A - µ·I)·x = 0. Exact irrational eigenvalues may also produce the zero vector if Derive is unable to determine that certain complicated irrational expressions are equivalent to 0. Moreover, nonnumeric or irrational eigenvalues are likely to exhaust memory or yield extremely bulky eigenvector expressions. For these reasons, EXACT_EIGENVECTOR is effectively limited to a maximum of 4 by 4 matrices. APPROX_EIGENVECTOR is usually a better choice for numerical matrices larger than 3 by 3.
APPROX_EIGENVECTOR(A, µ) approximates to an eigenvector of numerical matrix A corresponding to the eigenvalue that µ approximates. µ must be a number that is not an exact eigenvalue. The result is normalized to unit magnitude, making it unique to within a factor of plus or minus one for eigenvalues of multiplicity one. Multiply the result by a parameter such as @1 if you want a more general eigenvector. To assess the accuracy of a result vector x, compare it to A · x / µ to see how closely they agree. APPROX_EIGENVECTOR uses inverse iteration to approximate eigenvectors.
Other Utility File LibraryG5BS2R
Created with the Personal Edition of HelpNDoc: Qt Help documentation made easy