Guide · 08

Linear algebra

RP42 carries Vec3 (3-element vectors) and Mx3 (3×3 matrices) as native stack types, with a complete enough toolkit to solve a 3-variable system without leaving the calculator.

Constructing

A Vec3:

1.0 2.0 3.0 ->VEC3
1: [1.0, 2.0, 3.0]

An Mx3 — MX3ID is the shortcut for the 3×3 identity:

MX3ID

For an arbitrary matrix, push 9 doubles in row-major order, then ->MX3.

Mx3 detail sheet
Tap an Mx3 card to open a 3×3 grid view, with determinant, trace, and inverse one tap away.

Vector ops

DOT, CROSS, NORM, LENGTH, NORMALIZE, +, -, scalar * and / all do what you’d expect.

Matrix ops

+ and - between two Mx3. * between an Mx3 and an Mx3 is matrix-matrix multiply; between an Mx3 and a Vec3, matrix-vector. INV is the inverse, TRANSPOSE the transpose, DET the determinant, TRACE the trace.

Row / column accessors

GETROW, GETCOL, SETROW, SETCOL — read or write any 1-indexed row or column of an Mx3 as a Vec3.

M_on_stack 2 GETCOL   ( → second column as Vec3 )

Cramer’s rule

Given a 3-variable linear system:

x+2y+3z=142x−y+z=33x+y−2z=−1\begin{aligned} x + 2y + 3z &= 14 \\ 2x - y + z &= 3 \\ 3x + y - 2z &= -1 \end{aligned}

Rewrite it as Ax=bAx = b:

[1232−1131−2][xyz]=[143−1]\begin{bmatrix} 1 & 2 & 3 \\ 2 & -1 & 1 \\ 3 & 1 & -2 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \end{bmatrix} = \begin{bmatrix} 14 \\ 3 \\ -1 \end{bmatrix}

Push AA (nine numbers, row-major, ->MX3), then bb (three numbers, ->VEC3), then CRAMER:

1 2 3  2 -1 1  3 1 -2  ->MX3
14 3 -1  ->VEC3
CRAMER
1: [1, 2, 3]

The solution is (1,2,3)(1, 2, 3) — check by substituting back into any of the three equations.

Under the hood, CRAMER computes det⁡(A)\det(A) once, then for each column swaps in bb and takes the ratio xi=det⁡(Ai)/det⁡(A)x_i = \det(A_i) / \det(A). Readable in the source if you’re curious; the point is you don’t write that loop yourself.

Contact

Send us a message — we'll reply by email.