5.4.11 · D1Scientific Computing (Python)

Foundations — scipy.linalg — more stable than numpy.linalg, lu, qr, schur

1,729 words8 min readBack to topic

0. What is a vector? (the arrow)

Before matrices we need the thing they act on.

Figure — scipy.linalg — more stable than numpy.linalg, lu, qr, schur

Look at the figure: the arrow's tip lands at the point . The horizontal component () is how far right, the vertical component () is how far up. That's all a vector is — an instruction to move.

Why the topic needs it: everything scipy.linalg does is solve for, transform, or analyse these arrows. literally asks "which arrow , after the machine , becomes the arrow ?"


1. What is a matrix? (the machine)

The core operation is matrix times vector. Here is the rule, in plain words:

Figure — scipy.linalg — more stable than numpy.linalg, lu, qr, schur

In the figure the blue arrow is the input ; after the machine acts, it becomes the orange arrow rotated and stretched. That picture — "a machine that twists and stretches arrows" — is the mental model the whole parent note leans on.


2. The problem (the reason all this exists)

Why the topic needs it: LU factorization (the parent's first tool) exists entirely to solve this efficiently and safely.


3. Special shapes of machines

The whole factorization game is about breaking a messy into machines with easy shapes. Here are the shapes you must recognise on sight.


4. Transpose, inverse, and "orthogonal"

Figure — scipy.linalg — more stable than numpy.linalg, lu, qr, schur

The figure shows why means "columns are perpendicular unit arrows": entry of is the dot product of column with column . On the diagonal that's a column dotted with itself = its length² = ; off the diagonal it's two different columns dotted = because they are perpendicular. (Dot product is next.)


5. Length and the dot product (why "" appears)

Why the topic needs it: least squares means "make the leftover arrow as short as possible" — that's . And " preserves length" () is the single fact that makes QR-least-squares work.


6. Eigenvalues and eigenvectors (arrows that keep their direction)

Figure — scipy.linalg — more stable than numpy.linalg, lu, qr, schur

Most arrows get twisted (grey, they change direction). The teal arrow is an eigenvector: it comes out pointing the same way, only longer — stretched by . Finding these is what eig and Schur do.


7. Condition number (how nervous is this machine?)

Why the topic needs it: the parent's key stability argument is "normal equations square the condition number, " — a machine that was mildly nervous becomes wildly nervous. QR avoids that. See Condition Number.


8. Permutation matrix (bookkeeping for row swaps)

Why the topic needs it: LU with partial pivoting swaps rows to always divide by the largest available entry (never a tiny one). remembers which swaps happened, giving .


The prerequisite map

Vector = arrow

Matrix = machine

Solve Ax = b

Triangular and diagonal shapes

Dot product

Length and norm

Orthogonal Q

Least squares

LU factorization

Permutation P

QR factorization

Eigenvalues

Schur decomposition

Condition number

Why scipy is stable

Read it top-down: arrows and machines feed everything; dot product feeds length and orthogonality; those feed the three factorizations the parent teaches; condition number explains why they're the stable choice.



Equipment checklist

A vector in one sentence
A list of numbers pictured as an arrow from the origin.
What a matrix does to a vector
Mixes its components to produce a new (rotated/stretched) arrow.
What asks
Which input arrow does machine turn into the known output .
Why triangular matrices are "easy"
You solve one unknown at a time by back/forward substitution.
The test for an orthogonal matrix
— its transpose is its inverse; columns are perpendicular unit arrows.
What does to length
Preserves it: (only rotates/reflects).
What means
The length of the arrow, .
When is a dot product zero
When the two arrows are perpendicular.
Definition of an eigenvector
An arrow the matrix only stretches, never rotates: .
What the condition number measures
How much the matrix magnifies input errors (near 1 = safe).
What stores in
The row swaps (partial pivoting) done during elimination.