Matrices
A maths block can hold a vector or a matrix as readily as a number: type one with the toolbar, name it, and the rest of the calcsheet can index it, multiply by it, and pass it to functions. Vectors and matrices are available on every plan.
Writing a matrix
Section titled “Writing a matrix”The maths toolbar has a Matrices group. Its first two buttons start a matrix:
- [∷] inserts a 2 × 2 matrix with empty cells.
- [⋮] inserts a two-row vector.
Fill the cells by typing, with Tab moving to the next cell. To change the shape, put the caret inside the matrix and use +row, +col, −row and −col, which add or remove a row or column next to the caret.
A matrix is a value like any other, so you name it the usual way:
A literal matrix definition like this shows no = … evaluation by default, just as a literal number doesn’t. A computed one, such as , does.
You can also write a vector as a bracketed list, [1, 2, 3], which is the same thing as a column.
Vectors are columns
Section titled “Vectors are columns”A matrix with one cell per row (what [⋮] gives you) is a vector: a plain list of values, shown as a column. A matrix with one row is different: it stays a matrix. This matters for indexing, below.
Reading an element
Section titled “Reading an element”Elements are read with square brackets, counting from 1, like SMath:
Type the name, then an opening square bracket, or use the vᵢ and Mᵢⱼ buttons, which add the bracket after the name you’ve just typed and leave the caret on the index. The index can be any expression: with and , is .
A subscript is a name, not an index
Section titled “A subscript is a name, not an index”This is the one rule worth remembering. Typing a subscript (, , ) gives you a variable called that, never an element. That is deliberate: Eurocode names like are everyday subscripts, and they must stay names.
So if you write meaning the second element of , you get Undefined symbol v_2, and the message tells you how to write the element: v[2]. Rather than retyping, right-click the block and choose Read v_2 as element of matrix v. It respells every such subscript in the block as a bracket index in one go. The item only appears when the base really is a matrix and the subscript could be an index; a word subscript like is simply a name you haven’t defined yet.
Arithmetic
Section titled “Arithmetic”The ordinary operators do what they do on paper:
| Written | Does | With and above |
|---|---|---|
| Matrix product | ||
| Dot product of two vectors | ||
| , | Scales every element | , |
| , | Element by element | , |
| Matrix power, | ||
| Inverse, the M⁻¹ button | ||
| Transpose, the Mᵀ button |
Sizes have to agree: multiplying a by a , or adding vectors of different lengths, is reported as a dimension mismatch rather than guessed at.
Most scalar functions don’t apply to a matrix element by element (sqrt(M) tells you so), but abs does, and the statistics functions (sum, mean, max and the rest) take a matrix and work over every element.
The bars
Section titled “The bars”Vertical bars read as they do in a formula, and the |M| button writes them:
| Around | Means | Example |
|---|---|---|
| A square matrix | The determinant, sign and all | |
| A vector | Its length | |
| A number | Its absolute value |
A matrix that is neither square nor a vector has no bars reading, and says so.
Matrix functions
Section titled “Matrix functions”The remaining buttons in the group, a×b, a·b, ‖v‖, [i⋯] and [⋮j], write cross, dot, norm, row and column. With det, inv and transpose, those are the eight matrix functions; each has a full entry on the Matrix functions reference page.
One gotcha: a row or column pulled out with row or column is still two-dimensional (a or matrix, not a vector) – index it with two numbers, r[1, 2].
Units work inside a matrix exactly as they do in a scalar, and carry through the arithmetic:
The length of a vector needs every element in one kind of unit: has no length, and the block says so plainly.
How a matrix is shown
Section titled “How a matrix is shown”A matrix result is set out as a matrix, a vector as a column and a matrix row by row, with every element rounded to the block’s decimal places.
When every element shares a unit, that unit is factored out and shown once after the matrix, and it becomes the block’s result unit: a column of and shows as , never as a mix of millimetres and metres, and typing cm in the result-unit field converts the whole column. When the elements’ units differ in kind, each keeps its own and there is no unit field.
A comparison of two vectors gives a vector of true/false values, and as an assertion passes only when every element matches.
Elsewhere in the app
Section titled “Elsewhere in the app”- The Navigate sidebar lists every matrix-valued definition under Matrices & Tables, so you can jump to one.
- A table block is a matrix. Its name holds the whole grid, header row and key column included, indexed exactly as above: is the first key. See Tables.
- Functions take matrices. A function you define, , can be called with a matrix or a vector, literal or named.
See also
Section titled “See also”- Matrix functions:
column,cross,det,dot,inv,norm,rowandtransposeat a glance - Tables: a grid of values read by key or by interpolation
