Function reference · Linear algebra

rank

Returns the rank of a matrix: the number of linearly independent rows.

Notation

rank(matrix)

Write it in an expression: nerdamer('rank(matrix([1,2],[2,4]))'), or in the Playground.

nerdamer.rank

nerdamer.rank(...args: [M]): Expression

A method on the default import. Arguments can be strings, as in Notation.

Parameters

matrix
A matrix of any shape.

Returns

The rank, an integer.

Examples

The second row is twice the first, so the rank is 1.

rank(matrix([1,2],[2,4]))
// → 1
Open in Playground

A matrix doesn't have to be square.

rank(matrix([1,2,3],[4,5,6]))
// → 2
Open in Playground

Symbolic entries are treated as generic: this assumes a*d-b*c is not zero.

rank(matrix([a,b],[c,d]))
// → 2
Open in Playground

A vector such as [1,2] is an error; wrap it in matrix to get a one-row matrix.

rank(matrix([1,2]))
// → 1
Open in Playground

A zero matrix has rank 0.

rank(matrix([0,0],[0,0]))
// → 0
Open in Playground

JavaScript examples

nerdamer.rank('matrix([1,2],[2,4])').text()
// → 1

← Back to Function reference