Chapters
Matrices
A matrix is a rectangular grid of numbers. That plain idea turns out to be one of the most useful tools in mathematics: a single matrix can pack up a whole system of equations, describe how a shape is rotated or stretched, or hold a table of measurements ready to be transformed all at once. This chapter first builds intuition for what a matrix is and what the common operations mean, then shows exactly how to compute them on the Castiel Engineer Matrix surface.
If matrices are new to you, read the concept sections in order. If you only want the keys, jump to Working with matrices in Castiel.
What a matrix is
A matrix is numbers arranged in rows and columns inside a pair of tall brackets. This one has two rows and two columns:
[ 4 7 ]
[ 2 6 ]The size (or dimensions) of a matrix is written rows × columns, read "rows by columns." The matrix above is 2×2. A matrix with 3 rows and 4 columns is 3×4. The number of rows need not equal the number of columns; when it does — the same count of rows and columns — the matrix is square. Square matrices are special, because several operations (the determinant, the inverse, eigenvalues) are only defined for them.
Each number in the grid is an element, located by its row and then its column. In the matrix above, the element in row 2, column 1 is 2.
Where matrices are used. Two settings dominate:
- Systems of equations. A set of linear equations such as
4x + 7y = 1and2x + 6y = 0can be written as a single matrix equationA·x = b, whereAholds the coefficients. Solving the system becomes a matrix operation, and the tools below (the inverse, row-reduction, rank) are exactly what solve or diagnose it. - Transformations. In geometry and graphics, a square matrix describes a transformation of space — a rotation, a scaling, a shear. Multiplying a point by the matrix moves it. Chaining transformations becomes multiplying matrices.
The determinant
The determinant is a single number squeezed out of a square matrix. Geometrically it measures how much the transformation the matrix represents scales area (in 2×2) or volume (in 3×3): a determinant of 3 triples areas, a determinant of 1 preserves them, a negative determinant also flips orientation.
For a 2×2 matrix the determinant is a short cross-multiplication:
[ a b ]
det of [ c d ] = a·d − b·cSo for our example, det = 4·6 − 7·2 = 24 − 14 = 10.
Why a zero determinant matters. When the determinant is 0, the transformation collapses space onto a lower dimension — it squashes area down to nothing. In equation terms, a zero determinant means the system does not have a single clean solution: the rows are redundant or contradictory. A matrix with a zero determinant is called singular, and — crucially — a singular matrix has no inverse.
The inverse
The inverse of a square matrix A, written A⁻¹, is the matrix that undoes it: multiply A by A⁻¹ and you get the identity matrix (1s down the diagonal, 0s elsewhere), which is the "do nothing" matrix, the matrix equivalent of the number 1. If a matrix rotates space, its inverse rotates back; if a matrix scales up, its inverse scales down.
The inverse is what solves a system of equations in one step: if A·x = b, then x = A⁻¹·b.
When the inverse exists. Only square matrices can have an inverse, and only when the determinant is not zero. A singular matrix (determinant 0) has no inverse — there is no way to undo a transformation that has already thrown information away. Asking Castiel for the inverse of a singular matrix returns a message rather than a matrix.
For a 2×2 matrix there is a neat formula: swap the diagonal, negate the other two, and divide every element by the determinant:
[ a b ] 1 [ d −b ]
inverse [ c d ] = ───────────── [ −c a ]
a·d − b·cRow-reduction and rank
Row-reduction is the systematic bookkeeping behind solving equations by hand: you add multiples of one row to another, and scale rows, until the matrix is as simple as possible. The tidiest end state is the reduced row echelon form (RREF) — a canonical form with a leading 1 in each used row, and 0s everywhere above and below those leading 1s. Reading a system's RREF off directly tells you the solution, or tells you there isn't a unique one.
The rank of a matrix is the number of genuinely independent rows (equivalently, independent columns) — the count of leading 1s left standing after row-reduction. Rank is a measure of how much real information the matrix carries:
- A 3×3 matrix of rank 3 is "full rank": its rows are all independent, its determinant is non-zero, and it has an inverse.
- A rank lower than the size means some rows are redundant — the matrix is singular, and the system it represents is either short of information or over-determined.
Rank and RREF are defined for any shape of matrix, square or not, which is why Castiel offers them even when the other operations are unavailable.
Eigenvalues
For a square matrix, most directions get knocked askew when you multiply a vector by it. But some special directions are only stretched or squashed, never rotated off their line. Those directions are the matrix's eigenvectors, and the factor by which each is stretched is its eigenvalue. An eigenvalue of 2 means "vectors along this special direction come out twice as long"; an eigenvalue of 1 means that direction is left untouched.
Eigenvalues reveal the deep behaviour of a transformation — its stable axes, its growth or decay rates — and appear across physics, statistics, and engineering (vibration modes, stability analysis, principal components). A real matrix can have eigenvalues that are complex numbers (of the form a + bi); this happens naturally when the transformation includes a rotation, and Castiel reports those in complex form.
LU decomposition
Some operations are easier on a triangular matrix (one with zeros on one side of the diagonal) than on a full one. LU decomposition splits a square matrix A into a lower-triangular matrix L and an upper-triangular matrix U whose product rebuilds A, together with a permutation matrix P that records any row swaps made along the way (so that P·A = L·U). It is the workhorse behind fast, repeated equation-solving and behind the determinant itself. You do not need to follow the algorithm to use it — think of LU as "the matrix, factored into two simpler triangular pieces."
Working with matrices in Castiel
The Matrix surface lives in Engineer mode. Switch to Engineer on the top mode bar, then choose the Matrix tile on the left apps rail (between Calculate/CAS above and Vector/Units below).

Laying out the window. The heading at the top shows the word Matrix and the current size (2 x 2 in the screenshot). Below it, the MATRIX A block holds the editable grid — the numbers drawn inside a pair of tall brackets — with the dimension steppers to its right. Under the grid sits the row of operation buttons, and beneath those, the result cards that each operation produces.
Entering the matrix. Type directly into any cell to set its value. To change the size, use the steppers:
ROWS−/+removes or adds a row.COLS−/+removes or adds a column.
The grid runs from 1×1 up to 6×6. Changing either dimension resets the cells to 0 and clears any previous result, so you always start a resized matrix from a clean grid — re-enter your numbers after resizing.
Running an operation. Press one of the six operation buttons. Castiel reads the grid, computes the result on the real engine, and shows it as a card below the buttons: a scalar result (determinant, rank) appears as a large accent number; a matrix result (inverse, RREF, and each part of an LU) appears as its own bracketed grid; eigenvalues appear as a list.
Square-only operations. det, inverse, eigenvalues, and LU need a square matrix. When the grid is not square those four buttons are dimmed and cannot be pressed; hovering shows the note "Requires a square matrix." RREF and rank work on any shape and stay available. If an operation cannot be completed for another reason — for example the inverse of a singular matrix — a short status line explains why (such as "The matrix is singular (no inverse).").
The operations
Exactly six operations are offered, each acting on the single matrix A you have entered.
| Button | What it computes | Needs a square matrix? | Result shown as |
|---|---|---|---|
det |
The determinant — one number (see above). | Yes | A single value |
inverse |
The inverse matrix A⁻¹; reports singular if none exists. |
Yes | A bracketed matrix |
eigenvalues |
The list of eigenvalues (complex values shown as a + bi). |
Yes | A list of values |
RREF |
The reduced row echelon form. | No | A bracketed matrix |
rank |
The rank — the count of independent rows. | No | A single value |
LU |
The LU decomposition, returned as three matrices L, U, and P. |
Yes | Three bracketed matrices |
The Matrix surface is deliberately focused on analysing one matrix. It does not add, subtract, multiply, or transpose matrices, and it does not store named matrices for reuse — for those, and for vectors, see the Engineer matrices and vectors chapter.
Worked examples in Castiel
Example 1 — the determinant of a 2×2 (det). Use the matrix that the surface starts with:
[ 4 7 ]
[ 2 6 ]By hand, the determinant is 4·6 − 7·2 = 24 − 14 = 10. To confirm it in Castiel:
- Open Engineer → Matrix. The grid already holds
4 7 / 2 6at size2 x 2; if not, type those four values in. - Press
det. - A result card labelled det shows
10.
Because the determinant is 10, not 0, this matrix is non-singular — so it has an inverse, which the next example finds.
Example 2 — the inverse of a 2×2 (inverse). Keep the same matrix. By hand, the 2×2 inverse formula divides the "swap-and-negate" matrix by the determinant 10:
1 [ 6 −7 ] [ 0.6 −0.7 ]
──── [ −2 4 ] = [ −0.2 0.4 ]
10In Castiel:
-
With
4 7 / 2 6still in the grid, pressinverse. -
A result card labelled inverse shows the bracketed matrix
[ 0.6 −0.7 ] [ −0.2 0.4 ]matching the hand calculation exactly (this is the card visible in the screenshot above).
To see what happens when there is no inverse, change a cell so the rows become proportional — for instance make the matrix 4 7 / 8 14 (the second row is twice the first). Its determinant is 0, and pressing inverse now returns the status "The matrix is singular (no inverse)." rather than a matrix. That is the zero-determinant rule in action: a squashed transformation cannot be undone.
See also
- Engineer: matrices and vectors — the full Engineer matrix and vector toolset, including the Vector surface alongside this one.
- Vectors — the single-column relatives of matrices, and the geometry of directions and lengths.
- The equation solver — solving systems of equations directly, the everyday task matrices sit behind.