Vector and Matrix Functions
The file VectorMatrixFunctions.mth defines functions that automate some of the operations commonly performed on vectors and matrices. The function definitions in the file are automatically loaded when any of its functions are first used.
In Derive, an n by m matrix is stored internally as a vector of n elements, each of which is an m element vector. Therefore, it is possible to write functions that apply operations to the rows of a matrix. Moreover, by transposing a matrix, applying a function that operates on the rows of the resulting matrix, and finally transposing the result, makes it possible to apply operations to the columns of a matrix.
i_ simplifies to the vector [1, 0, 0].
j_ simplifies to the vector [0, 1, 0].
k_ simplifies to the vector [0, 0, 1].
These three assigned variables represent the unit vectors i, j, and k for the rectangular (Cartesian) coordinate system. The underscore in their names is meant to suggest a vector and to distinguish them from the user variables i, j, and k. Any Cartesian coordinate vector can be entered as a linear combination of unit vectors. For example,
a·i_ + 3·j_ - k_
simplifies to
[a, 3, -1]
OUTER(v, w) simplifies to the outer product of vectors v and w. For example,
OUTER([a, b], [2, 3, 4])
simplifies to
⎡ 2·a 3·a 4·a ⎤
⎢ ⎥
⎣ 2·b 3·b 4·b ⎦
KRONECKER(i, j) simplifies to 1 if integer i equals integer j, otherwise it simplifies to 0. The Kronecker delta function of i and j is often written as delta sub i, j . KRONECKER is a useful utility function for implementing various vector and matrix operations.
The next several functions perform various operations on vectors and matrices:
APPEND_COLUMNS(A, B, ...) appends the columns of its arguments, which all must be matrices having the same number of rows. It can be given any number of matrices or a vector of matrices. For example,
APPEND_COLUMNS([a, b; c, d], [e; f], [g; h])
and
APPEND_COLUMNS([[a, b; c, d], [e; f], [g; h]])
both simplify to
⎡ a b e f ⎤
⎢ ⎥
⎣ c d g h ⎦
PARTITION(v, n, d) simplifies to a partition of vector v into vectors of length n with an offset delta of d. d defaults to n. For example,
PARTITION([1, 2, 3, 4, 5], 3, 2)
simplifies to
⎡ 1 2 3 ⎤
⎢ ⎥
⎣ 3 4 5 ⎦
REMOVE_ELEMENTS(v, v_) removes any occurrences of the elements in v_ from the vector v. For example,
REMOVE_ELEMENTS([a, b, b, c, d, d, d, d, e, e], [b, d, e])
simplifies to
[a, c]
v_ need not necessarily be a vector. To remove one element, say d in the previous example, then simplifying
REMOVE_ELEMENTS([a, b, b, c, d, d, d, d, e, e], d)
yields the vector
[a, b, b, c, e, e]
MATPROD(A, B, i, j) simplifies to the element on the ith row and jth column of the dot product of matrices A and B. The elements of the product of two matrices with nonnumeric elements are often much bulkier than the elements of the original matrices. MATPROD allows you to compute a matrix product one element at a time. Alternatively, a matrix product can be computed one row at a time by simplifying expressions of the form A SUB i · B, for i=1 to the dimension of A.
The file VectorMatrixFunctions.mth makes the following assignments for polar-cylindrical and spherical coordinate geometry matrices for use with the built-in vector calculus functions (see Differential Vector CalculusDifferential_Vector_Calculus and Integral Vector CalculusIntegral_Vector_Calculus):
⎡ r è z ⎤
cylindrical := ⎢ ⎥
⎣ 1 r 1 ⎦
and
⎡ r è Ö ⎤
spherical := ⎢ ⎥
⎣ 1 r·SIN(Ö) r ⎦
The file also defines functions for finding other coordinate geometry matrices in any orthogonal, curvilinear coordinate system. First, compute the Jacobian matrix of the transformation from curvilinear to rectangular (Cartesian) coordinates. Next, compute the covariant metric tensor from the Jacobian matrix. If this matrix is diagonal, the coordinates are orthogonal, and you can proceed to compute the geometry matrix from the curvilinear coordinates and this diagonal:
Assume the transformation from curvilinear to some rectangular (Cartesian) coordinates is given by
x = u(θ1, θ2, ..., θm)
where x is a vector of n rectangular coordinates, and u is a vector of n expressions depending on curvilinear coordinates θ1 through θm, with m ≤ n. (m < n corresponds to a hyper-surface imbedded in a higher-dimensional space.)
JACOBIAN(u, θ) simplifies to the Jacobian matrix of the above transformation, where θ = [θ1, θ2, ..., θm]. The Jacobian is the n by m matrix of partial derivatives of u, with dui/dθj located at row i and column j. For example, the transformation from parabolic to rectangular (Cartesian) coordinates is x = (w²-v²)/2 and y = w·v and
JACOBIAN([(w^2 - v^2)/2, w·v], [w, v])
simplifies to
⎡ w -v ⎤
⎢ ⎥
⎣ v w ⎦
COVARIANT_METRIC_TENSOR(A) simplifies to the covariant metric tensor of the Jacobian matrix A. Note that a coordinate system is orthogonal only if the elements off the main diagonal of the covariant metric tensor of its Jacobian matrix are 0. For example, the parabolic coordinate system is orthogonal since
COVARIANT_METRIC_TENSOR([w, -v; v, w])
simplifies to
⎡ 2 2 ⎤
⎢ v + w 0 ⎥
⎢ ⎥
⎢ 2 2 ⎥
⎣ 0 v + w ⎦
GEOMETRY_MATRIX(θ, G) simplifies to the geometry matrix for curvilinear coordinate vector θ having a covariant metric tensor G. For example,
GEOMETRY_MATRIX([u, v], [v^2 + w^2, 0; 0, v^2 + w^2])
simplifies to
⎡ u v ⎤
⎢ ⎥
⎢ 2 2 2 2 ⎥
⎣ √(v + w ) √(v + w ) ⎦
Note that the second row of the geometry matrix is just the square roots of the diagonal elements of the covariant tensor. In some cases, simplification of the square roots may lead to unwanted absolute values unless you use the Author > Variable Domain command8MNT4Y to appropriately restrict the domain of some coordinate variables. For example, with spherical coordinates r should be declared nonnegative and Φ should be declared between 0 and π.
RECTANGULAR_TO_POLAR(x, y) simplifies to a vector of the polar coordinates of the point (x,y) expressed in rectangular coordinates. For example,
RECTANGULAR_TO_POLAR(3, 4)
simplifies to
⎡ ð ⎛ 1 ⎞⎤
⎢5, ——— — 2·ATAN⎜———⎟⎥
⎣ 2 ⎝ 3 ⎠⎦
and approximates to [5, 0.9272952180].
POLAR_TO_RECTANGULAR(r, q) simplifies to a vector of the rectangular coordinates of the point (r,q) expressed in polar coordinates. For example,
POLAR_TO_RECTANGULAR(2, pi/3)
simplifies to [1, √3].
POLAR_SUM(p, q) simplifies to the vector sum of the points p and q each expressed in polar coordinates as a two-element vector. For example,
POLAR_SUM([1, pi/2], [2, pi/3])
simplifies to
[√(2·√3 + 5), ATAN(√3 + 1)]
and approximates to [2.909312911, 1.219916915].
Other Utility File LibraryG5BS2R
Created with the Personal Edition of HelpNDoc: Free EBook and documentation generator