Foundations to Frontier
Tests
A. Mathematical Foundations › A2 Linear Algebra › Matrices

Special Matrices: Diagonal, Triangular, Symmetric, Orthogonal, Permutation, Sparse, Block

Matrices with structure are faster, more stable and easier to understand. Recognising the structure is half of numerical linear algebra, and half of robotics and ML engineering.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Matrices with personalities

Some matrices are special, and their shape tells you what they do:

  • A diagonal matrix stretches each direction on its own: “make it 2× wider and 3× taller”.
  • A symmetric matrix looks the same in a mirror along its diagonal, like a distance table between cities (Delhi→Mumbai = Mumbai→Delhi).
  • An orthogonal matrix only turns or flips things, so it never stretches or squashes. Turning a photo is one.
  • A permutation matrix just reorders, like shuffling a deck of cards.
  • A sparse matrix is almost all zeros, like a friendship table where each person knows only a few others.

Try the “Rotate” and “Reflect” presets: the square never changes size. Then try “Stretch x”: only one direction changes.

Linear map visualiser: a matrix warps the grid
A = [[1.0, 1.0], [0.0, 1.0]]
det A = 1.00 (area scale) · rank = 2
Ae₁Ae₂
The first column of A is where e₁ = (1, 0) lands; the second column is where e₂ = (0, 1) lands. The orange square is the image of the unit square: its area is |det A|.
📝 Quick check (Level 0)
0/3 answered
  1. 1. A distance table between cities is…
  2. 2. Which kind of matrix never changes lengths?
  3. 3. In how many orders can you arrange 3 cards?

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Diagonal

D=diag⁡(d1,…,dn),Dx=(d1x1,…,dnxn)D = \operatorname{diag}(d_1,\dots,d_n), \qquad D\mathbf x = (d_1x_1,\dots,d_nx_n)

Multiplying diagonals multiplies their entries, and D−1=diag⁡(1/d1,… )D^{-1} = \operatorname{diag}(1/d_1,\dots), as long as no di=0d_i = 0.

Triangular

Upper triangular means all zeros below the diagonal, and lower triangular means all zeros above it. The determinant is the product of the diagonal: det⁡(257031004)=2⋅3⋅4=24\det\begin{pmatrix}2&5&7\\0&3&1\\0&0&4\end{pmatrix} = 2\cdot3\cdot4 = 24. Triangular systems are easy to solve from one end (back-substitution).

Symmetric

A=A⊤A = A^\top, so aij=ajia_{ij} = a_{ji}. For example (1223)\begin{pmatrix}1&2\\2&3\end{pmatrix}. Covariance matrices, distance matrices, graph Laplacians and Hessians are all symmetric.

Orthogonal

Q⊤Q=IQ^\top Q = I, so Q−1=Q⊤Q^{-1} = Q^\top. The columns are unit vectors that are perpendicular to each other. Rotations and reflections are orthogonal. They keep lengths and angles: ∥Qx∥=∥x∥\lVert Q\mathbf x\rVert = \lVert\mathbf x\rVert.

Permutation

An identity matrix with its rows reordered. Multiplying by it reorders the entries of a vector: (0110)(ab)=(ba)\begin{pmatrix}0&1\\1&0\end{pmatrix}\begin{pmatrix}a\\b\end{pmatrix} = \begin{pmatrix}b\\a\end{pmatrix}.

📝 Quick check (Level 1)
0/3 answered
  1. 1. diag(2, 3) · diag(4, 5) = ?
  2. 2. det of a triangular matrix with diagonal 1, 5, 2?
  3. 3. For orthogonal Q, Q⁻¹ = ?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Why structure matters: cost

Structure Storage Solve Ax=bA\mathbf x=\mathbf b Notes
General dense n2n^2 O(n3)O(n^3) Gaussian elimination
Diagonal nn O(n)O(n) divide entrywise
Triangular n2/2n^2/2 O(n2)O(n^2) back-substitution
Orthogonal n2n^2 O(n2)O(n^2) x=Q⊤b\mathbf x = Q^\top\mathbf b, perfectly conditioned
Banded / tridiagonal O(n)O(n) O(n)O(n) splines, 1-D physics, time series
Sparse (nnz\text{nnz} nonzeros) O(nnz)O(\text{nnz}) depends graphs, meshes, SLAM, recommender data

Symmetric and skew-symmetric parts

Every square matrix splits uniquely as A=S+KA = S + K, with S=12(A+A⊤)S = \tfrac12(A + A^\top) symmetric and K=12(A−A⊤)K = \tfrac12(A - A^\top) skew-symmetric (K⊤=−KK^\top = -K). Quadratic forms only see the symmetric part: x⊤Ax=x⊤Sx\mathbf x^\top A\mathbf x = \mathbf x^\top S\mathbf x. That’s why we always assume Hessians and covariances are symmetric. In robotics, skew-symmetric matrices represent cross products and angular velocity: ω×v=[ω]×v\boldsymbol\omega\times\mathbf v = [\boldsymbol\omega]_\times\mathbf v (R2).

Sparse matrices

When most entries are zero, store only the non-zeros. The CSR (compressed sparse row) format keeps three arrays: the values, their column indices, and where each row starts. Graph adjacency matrices and Laplacians, finite-element stiffness matrices, the information matrices of SLAM, and user–item ratings in recommender systems are all sparse. They often have millions of rows and only a handful of non-zeros per row.

Block matrices

Many systems have natural blocks:

(ABCD)\begin{pmatrix}A&B\\C&D\end{pmatrix}

for example, the position and velocity parts of a robot state, or the observed and hidden parts of a Gaussian. Block-diagonal matrices act independently on each block, so their determinant and inverse work block by block.

🐍 Exercise 1: classify a matrix
Return the set of properties a matrix has: diagonal, upper/lower triangular, symmetric, skew-symmetric, orthogonal, permutation.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Cost of solving a triangular n × n system?
  2. 2. x⊤Ax depends on…
  3. 3. Nonzeros in a 100 × 100 tridiagonal matrix?

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

Triangular matrices form a closed world

Theorem

Products of upper-triangular matrices are upper triangular. If invertible, their inverses are upper triangular too, and det⁡U=∏iuii\det U = \prod_i u_{ii}.

Proof sketch. (UV)ij=∑kuikvkj(UV)_{ij} = \sum_k u_{ik}v_{kj}. For i>ji > j, every term has k<ik < i (so uik=0u_{ik} = 0) or k>jk > j (so vkj=0v_{kj} = 0). For the determinant, expand along the first column repeatedly: only the diagonal survives. The inverse follows from back-substitution applied to each column of II. ∎ This closure is why the LU factorization (A2.3) works.

Orthogonal matrices form a group

Theorem

If Q1,Q2Q_1, Q_2 are orthogonal, so are Q1Q2Q_1Q_2 and Q1−1=Q1⊤Q_1^{-1} = Q_1^\top. Every orthogonal QQ has det⁡Q=±1\det Q = \pm1 and preserves dot products.

Proof. (Q1Q2)⊤(Q1Q2)=Q2⊤Q1⊤Q1Q2=Q2⊤Q2=I(Q_1Q_2)^\top(Q_1Q_2) = Q_2^\top Q_1^\top Q_1Q_2 = Q_2^\top Q_2 = I. Next, (det⁡Q)2=det⁡Q⊤det⁡Q=det⁡I=1(\det Q)^2 = \det Q^\top\det Q = \det I = 1. Finally, (Qu)⋅(Qv)=u⊤Q⊤Qv=u⋅v(Q\mathbf u)\cdot(Q\mathbf v) = \mathbf u^\top Q^\top Q\mathbf v = \mathbf u\cdot\mathbf v. ∎

The orthogonal matrices with det⁡=+1\det = +1 are the rotations, the group SO(n)SO(n). In 3D, every robot orientation is an element of SO(3)SO(3), with 3 degrees of freedom (R2).

Permutations

There are n!n! permutation matrices of size nn. Each is orthogonal with determinant ±1\pm1, the sign of the permutation. A swap of two rows has sign −1-1.

Block determinants and the Schur complement

Theorem

If AA is invertible, det⁡(ABCD)=det⁡A⋅det⁡(D−CA−1B)\det\begin{pmatrix}A&B\\C&D\end{pmatrix} = \det A\cdot\det(D - CA^{-1}B).

The matrix S=D−CA−1BS = D - CA^{-1}B is the Schur complement. It appears when you condition a Gaussian on observed variables (A4.2), in the Kalman filter update (T1), and when eliminating landmarks in SLAM to get a smaller “reduced camera system” (T3).

Exercise 3.1: Check the Schur formula with 1×1 blocks A = 2, B = 1, C = 1, D = 3

det⁡(2113)=5\det\begin{pmatrix}2&1\\1&3\end{pmatrix} = 5, and 2⋅(3−1⋅12⋅1)=2⋅2.5=52\cdot(3 - 1\cdot\tfrac12\cdot1) = 2\cdot2.5 = 5. ✅

📝 Quick check (Level 3)
0/3 answered
  1. 1. det Q₁ = 1 and det Q₂ = −1 (both orthogonal). det(Q₁Q₂) = ?
  2. 2. Block-diagonal matrix with blocks of determinant 2 and 3. Its determinant?
  3. 3. How many degrees of freedom does SO(3) have?

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Sparsity is what makes large problems solvable

A dense matrix with a million rows needs 101210^{12} entries, about 8 TB in float64. Real problems are almost always sparse:

  • SLAM and bundle adjustment. Each measurement links only a few poses or landmarks, so the information matrix is sparse. Factor-graph solvers such as iSAM2 (Kaess et al., 2012) and GTSAM exploit this to map large environments in real time (T3).
  • Finite elements and physics simulation. Each mesh node interacts only with its neighbours (A8, J).
  • Graph neural networks. Message passing is a sparse matrix product with the adjacency matrix (E14).
  • Recommender systems. User–item matrices have far less than 1% of their entries observed (D13).

The order in which a sparse system is factored determines how many new non-zeros (“fill-in”) appear. Finding good orderings, such as COLAMD and nested dissection, is a classic research topic and directly controls SLAM speed.

🐍 Exercise 2 (research): a sparse graph Laplacian in CSR form
Build the Laplacian of a k × k grid graph directly in CSR format, implement a CSR matrix–vector product, and compare the memory with dense storage.

Structure in modern ML

  • Orthogonal weights. Orthogonal initialization (Saxe et al., 2014) and orthogonality constraints keep signal norms stable through deep and recurrent networks (E0).
  • Structured matrices for efficiency. Low-rank (LoRA), block-diagonal (grouped convolutions and multi-head attention), Toeplitz (convolutions), and butterfly and Monarch matrices (Dao et al., 2022) cut parameters and FLOPs while keeping expressiveness.
  • Permutation symmetry. Hidden units in a layer can be permuted without changing the function. This affects model merging and the geometry of loss landscapes (B4).

References

  1. H. Markowitz (1957). “The elimination form of the inverse and its application to linear programming.” Management Science, 3(3). (Sparse ordering.)
  2. I. Schur (1917). “Über Potenzreihen, die im Innern des Einheitskreises beschränkt sind.” Journal für die reine und angewandte Mathematik, 147. (Schur complement.)
  3. T. Davis (2006). Direct Methods for Sparse Linear Systems. SIAM.
  4. M. Kaess, H. Johannsson, R. Roberts, V. Ila, J. Leonard, F. Dellaert (2012). “iSAM2: Incremental smoothing and mapping using the Bayes tree.” International Journal of Robotics Research, 31(2).
  5. A. Saxe, J. McClelland, S. Ganguli (2014). “Exact solutions to the nonlinear dynamics of learning in deep linear neural networks.” ICLR.
  6. T. Dao et al. (2022). “Monarch: Expressive structured matrices for efficient and accurate training.” ICML.