You're not reading the latest revision of this page, which is here.

Matrix Variables

How to create matrix variables

1. tex like syntax

To make a simple matrix variable you can use

\begin{variables}
...
\matrix{A}{
 1 & 2 \\ %first row of 2x2 matrix
 3 & 4 % 2nd row of 2x2 matrix
}
...
\end{variables}

you can also use number or function variables for the cells

\begin{variables}
\randint{a}{-5}{5}
\randint{b}{-5}{5}
\function[normalize]{c}{a+b}
\function[normalize]{d}{a-b}
\matrix{B}{
 a & b \\ %first row of 2x2 matrix
 c & d % 2nd row of 2x2 matrix
}
...
\end{variables}

2. python like syntax

The python like syntax is created to make create more complex matrices.
It supports matrix functions such as addition, multiplication, inverse and so on.

2.1 creating a simple matrix

a matrix in the python like syntax is a collection of row vectors with same number of columns, separated by semicolon.

\begin{variables}
...
\matrix{C}{[ [1;2] ; [3;4] ]} % 2x2 Matrix
...
\end{variables}

you can also create row vector variables and use it in your matrix

\begin{variables}
...
\randint{a}{-5}{5}
\randint{b}{-5}{5}
\rowVector{row1}{[a;b]}
\matrix{C}{[ row1 ; [3;4] ]} % 2x2 Matrix
...
\end{variables}

2.1 Matrix Operations

\begin{variables}
...
\matrix{C}{[[1;2];[3;4]} % 2x2 Matrix
\matrix{D}{2*C} % Number multiplication
\matrix{E}{C*D} % Matrix multiplication
\matrix{F}{D+E-C} % addition and substraction
\matrix{G}{inv(C)} % inverse of matrix, will throw exception if matrix is not invertible
\matrix{H}{transpose(C)} % adjoint of matrix
\matrix{I}{adjoint(C)} % adjoint of matrix
...
\end{variables}