Arrays
rows(A)
Section titled “rows(A)”The number of rows of A (0 for a number).
rows([1, 2, 3; 4, 5, 6]) = 2cols(A)
Section titled “cols(A)”The number of columns of A.
cols([1, 2, 3; 4, 5, 6]) = 3length(v)
Section titled “length(v)”The number of elements of the vector v.
length([4; 5; 6; 7]) = 4last(v)
Section titled “last(v)”The index of the last element of v, counting from ORIGIN.
last([4; 5; 6; 7]) = 3matrix(m, n, f)
Section titled “matrix(m, n, f)”An m×n matrix whose element (i, j) is f(i, j), i and j counting from 0.
f(i, j) := i + 10*jmatrix(2, 3, f) = [0, 10, 20; 1, 11, 21]identity(n)
Section titled “identity(n)”The n×n identity matrix.
identity(3) = [1, 0, 0; 0, 1, 0; 0, 0, 1]augment(A, B, …)
Section titled “augment(A, B, …)”The matrices side by side; they need the same number of rows.
augment([1; 2], [3; 4]) = [1, 3; 2, 4]stack(A, B, …)
Section titled “stack(A, B, …)”The matrices one above the other; they need the same number of columns.
stack([1, 2], [3, 4]) = [1, 2; 3, 4]submatrix(A, ir, jr, ic, jc)
Section titled “submatrix(A, ir, jr, ic, jc)”The part of A from row ir to jr and column ic to jc, counting from ORIGIN.
M := [1, 2, 3; 4, 5, 6; 7, 8, 9]submatrix(M, 1, 2, 0, 1) = [4, 5; 7, 8]The trace of the square matrix M, the sum of its diagonal.
tr([1, 2; 3, 4]) = 5reverse(v)
Section titled “reverse(v)”The elements of v in reverse order (the rows of a matrix).
reverse([1; 2; 3]) = [3; 2; 1]sort(v)
Section titled “sort(v)”The elements of v in ascending order.
sort([3; 1; 2]) = [1; 2; 3]csort(A, j)
Section titled “csort(A, j)”The rows of A sorted by column j.
csort([3, 30; 1, 10; 2, 20], 0) = [1, 10; 2, 20; 3, 30]rsort(A, i)
Section titled “rsort(A, i)”The columns of A sorted by row i.
rsort([3, 1, 2; 30, 10, 20], 0) = [1, 2, 3; 10, 20, 30]linspace(a, b, n)
Section titled “linspace(a, b, n)”n values evenly spaced from a to b, as a column.
linspace(0 m, 1 m, 5) = [0; 0.25; 0.5; 0.75; 1]*mlogspace(a, b, n)
Section titled “logspace(a, b, n)”n values from a to b, evenly spaced on a log scale.
logspace(1, 1000, 4) = [1; 10; 100; 1000]cross(u, v)
Section titled “cross(u, v)”The cross product of the three-element vectors u and v.
cross([1; 0; 0], [0; 1; 0]) = [0; 0; 1]eigenvals(M)
Section titled “eigenvals(M)”The eigenvalues of the square matrix M, as a column.
eigenvals([2, 0; 0, 3]) = [2; 3]eigenvecs(M)
Section titled “eigenvecs(M)”The eigenvectors of M, one per column, in the order of eigenvals(M), each of length 1.
eigenvecs([2, 1; 1, 2]) = [0.707, 0.707; -0.707, 0.707]eigenvec(M, λ)
Section titled “eigenvec(M, λ)”The eigenvector of M for the eigenvalue λ, of length 1.
eigenvec([2, 1; 1, 2], 3) = [0.707; 0.707]match(z, A[, mode])
Section titled “match(z, A[, mode])”The positions in A of the value z, or with mode “near”, “lt”, “gt”, “leq” or “geq” of the nearest value, the one just below or just above.
match(5, [2; 5; 7]) = [1]match(6, [2; 5; 7], "lt") = [1]vlookup(z, A, j)
Section titled “vlookup(z, A, j)”The elements of column j of A in the rows whose first element is z.
vlookup(2, [1, 10; 2, 20; 3, 30], 1) = [20]hlookup(z, A, i)
Section titled “hlookup(z, A, i)”The elements of row i of A in the columns whose first element is z.
hlookup(2, [1, 2, 3; 10, 20, 30], 1) = [20]lookup(z, A, B)
Section titled “lookup(z, A, B)”The elements of B in the places where A holds z.
lookup(2, [1; 2; 3], [10; 20; 30]) = [20]cells(table, "B2:C9")
Section titled “cells(table, "B2:C9")”A range of a named table’s grid, written as in a spreadsheet, the header being row 1.
IsArray(x)
Section titled “IsArray(x)”1 if x is an array, 0 if not.
IsArray([1; 2]) = 1IsScalar(x)
Section titled “IsScalar(x)”1 if x is a number, 0 if not.
IsScalar(3 m) = 1