Skip to content

Matrix functions

The functions that work on vectors and matrices, one entry each. For writing a matrix, indexing it and the bars |M|, see Matrices; the table functions, which read a matrix as a table, are on Table functions, and everything else on Built-in functions.

column(M, j)

One column of a matrix, counting from 1.

Parameter Meaning
M A matrix with rows and columns. A table block’s name works too. See Tables.
j The column number, from 1.

The column, as an matrix.

Message When
Only two dimensional matrix is supported M is a plain list rather than a matrix with rows and columns
Index out of range j is below 1 or past the last column
Index must be an integer j isn’t a whole number
cross(a, b)

The cross product of two three-dimensional vectors.

Parameter Meaning
a A vector of exactly three elements.
b A vector of exactly three elements.

The vector .

Message When
Vectors with length 3 expected Either vector doesn’t have three elements
Too few arguments in function cross / Too many arguments in function cross Not exactly two arguments
det(M)

The determinant of a square matrix. The bars |M| around a square matrix mean the same thing.

Parameter Meaning
M A square matrix.

A number.

Message When
Matrix must be square M isn’t square, or is a plain list
Too few arguments in function det / Too many arguments in function det Not exactly one argument
dot(a, b)

The dot product of two vectors of the same length. Units multiply through.

Parameter Meaning
a A vector: a plain list or a column matrix.
b A vector of the same length.

A number, or a quantity whose units are the product of the two vectors’ units.

Message When
Vectors must have equal length The two vectors differ in length
Too few arguments in function dot / Too many arguments in function dot Not exactly two arguments
inv(M)

The inverse of a square matrix. Of a plain number, its reciprocal.

Parameter Meaning
M A square, non-singular matrix, or a number.

The inverse matrix, or for a number.

Message When
Cannot calculate inverse, determinant is zero M is singular
Matrix must be square M isn’t square
Too few arguments in function inv / Too many arguments in function inv Not exactly one argument
norm(v)
norm(v, p)
norm(M)

The length of a vector, the everyday case, including a vector of quantities, as long as they share a unit. Of a matrix, the Frobenius norm; of a number, its magnitude. The bars |v| around a vector mean the same thing, and also accept a column written as a matrix, which norm itself does not.

Parameter Meaning
v A vector written as a plain list, of numbers or of quantities with one unit.
p Optional. The kind of norm: 2 (default, Euclidean), 1 (sum of magnitudes), Infinity (largest magnitude), or 'fro'.
M A matrix with rows and columns.

The length, in the unit of the first element; a number for plain values.

Message When
The length of a vector needs every element in the same unit Some elements carry a unit and others don’t, or the units differ in kind
Invalid matrix dimensions A column vector written as an matrix. Use the bars, or a plain list
Too few arguments in function norm / Too many arguments in function norm No argument, or more than two
row(M, i)

One row of a matrix, counting from 1.

Parameter Meaning
M A matrix with rows and columns. A table block’s name works too. See Tables.
i The row number, from 1.

The row, as a matrix.

Message When
Only two dimensional matrix is supported M is a plain list rather than a matrix with rows and columns
Index out of range i is below 1 or past the last row
Index must be an integer i isn’t a whole number
transpose(M)

Swaps a matrix’s rows and columns. The toolbar’s is the same function. A plain list has no second dimension, so it comes back unchanged; write a column as a matrix to transpose it into a row.

Parameter Meaning
M A matrix.

The transposed matrix.

Message When
Too few arguments in function transpose / Too many arguments in function transpose Not exactly one argument