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 ->VEC3An Mx3 — MX3ID is the shortcut for the 3×3 identity:
MX3IDFor an arbitrary matrix, push 9 doubles in row-major order, then ->MX3.
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:
Rewrite it as :
Push (nine numbers, row-major, ->MX3), then (three numbers, ->VEC3), then CRAMER:
1 2 3 2 -1 1 3 1 -2 ->MX3
14 3 -1 ->VEC3
CRAMERThe solution is — check by substituting back into any of the three equations.
Under the hood, CRAMER computes once, then for each column swaps in and takes the ratio . Readable in the source if you’re curious; the point is you don’t write that loop yourself.