Matrices and matrix commands
The square-bracket symbols  [ ]  denote matrices. Elements in a row are separated by a comma. Rows in a matrix are separated by a semi-colon. For example,
zeroMat23 = GetZeroMatrix( 2, 3 ) -> zeroMat23 = [0, 0, 0; 0, 0, 0] identity33 = GetIdentityMatrix( 3, 3 ) -> identity33 = [1, 0, 0; 0, 1, 0; 0, 0, 1]
A matrix can be defined by its elements, e.g.,
M = [1, 2; 3, sin(t)] % 2 x 2 matrix
Subsequently, other matrices may be defined in terms of  M,  e.g., with addition, scalar multiplication or division, matrix multiplication, etc.
add = M + M -> add = [2, 4; 6, 2*sin(t)] mult5 = 5 * M -> mult5 = [5, 10; 15, 5*sin(t)] multM = M * M -> multM = [7, 2 + 2*sin(t); 3 + 3*sin(t), 6 + sin(t)^2] divide = M / 2 -> divide = [0.5, 1; 1.5, 0.5*sin(t)]
Try matrix commands such as, transpose, determinant, trace, derivative, inverse.
transpose = GetTranspose( M ) -> transpose = [1, 3; 2, sin(t)] det = GetDeterminant( M ) -> det = -6 + sin(t) trace = GetTrace( M ) -> trace = 1 + sin(t) derivative = Dt( M ) -> derivative = [0, 0; 0, cos(t)] inv = GetInverse( M ) -> inv[1,1] = sin(t)/(-6+sin(t)) -> inv[1,2] = -2/(-6+sin(t)) -> inv[2,1] = -3/(-6+sin(t)) -> inv[2,2] = 1/(-6+sin(t))
To calculate symbolic eigenvalues for small matrices or numerical eigenvalues and eigenvectors for larger matrices, use the command GetEigen.
eigValues = GetEigen( M ) -> eigValues[1] = 0.5 + 0.5*sin(t) - 0.5*sqrt(24+(1+sin(t))^2-4*sin(t)) -> eigValues[2] = 0.5 + 0.5*sin(t) + 0.5*sqrt(24+(1+sin(t))^2-4*sin(t))
There are various ways to extract elements, rows, columns, and to form matrices.
element12 = M[ 1, 2 ] % Element in 1st row, 2nd column. -> element12 = 2 element12 = GetElement( M, 1, 2 ) -> element12 = 2 row2 = GetRow( M, 2 ) % Extract row 2 of M. -> row2 = [3, sin(t)] col2 = GetCol( M, 2 ) % Extract column 2 of M. -> col2 = [2; sin(t)] extractRows = GetRow( M, 2, 1 ) % Extract rows 2 and 1 of M. -> extractRows = [3, sin(t); 1, 2] colTwice = GetColumns( M, 2, 2 ) % Extract column 2 of M twice. -> colTwice = [2, 2; sin(t), sin(t)] MM = [ M, M ] % 2 x 4 matrix. -> MM = [1, 2, 1, 2; 3, sin(t), 3, sin(t)] Metc = [ M, 7*M, GetIdentityMatrix(2,2) ] -> Metc = [1, 2, 7, 14, 1, 0; 3, sin(t), 21, 7*sin(t), 0, 1] extract = Metc[ 1:2, 3:6 ] % Extract rows 1-2 and columns 3-6. -> extract = [7, 14, 1, 0; 21, 7*sin(t), 0, 1]
To save commands (for subsequent re-use) or commands/responses, type
Save MGMatrixExample.txt % Save commands. Save MGMatrixExample.html % Save commands and responses.
Exit the program by typing Quit.
MotionGenesis™ also solves sets of linear equations (symbolically or numerically) and numerically solves sets of nonlinear equations.