Skip to content
BIASED

Iterative methods: power iteration and conjugate gradient

Block 1 of 8~2 min

Only matrix–vector products

The topic Conditioning and numerical stability ended with good solvers: LU, Cholesky and QR are backward stable and lose only the digits the problem itself demands. All of them factor the matrix. For a dense n×nn \times n matrix that costs about 23n3\tfrac23 n^3 operations and n2n^2 stored numbers of 88 bytes each in float64. At n=106n = 10^6 the operations and the bytes are

23n3≈6.7⋅1017,8n2=8⋅1012.\tfrac23 n^3 \approx 6.7 \cdot 10^{17}, \qquad 8 n^2 = 8 \cdot 10^{12}.

That is 88 TB just to store the matrix.

Many large matrices are sparse. Take an image of N×NN \times N pixels with one unknown per pixel. The grid Laplacian couples each unknown to its four neighbours: its row has 44 on the diagonal and −1-1 for each neighbour. It is symmetric positive definite and is behind smoothing and diffusion on images and meshes. At N=1000N = 1000 it has n=106n = 10^6 rows but only five nonzeros per row. One product with a vector costs about 10710^7 operations, and the matrix fits in 6464 MB. A factorization would fill in many of the zeros and lose this advantage.

Some matrices in ML are never stored at all. The Hessian of a network with 10710^7 parameters has 101410^{14} entries. Automatic differentiation still computes a Hessian–vector product ∇2L(θ) v\nabla^2 L(\theta)\, v for the cost of about two gradients. The kernel matrix of a Gaussian process can be multiplied by a vector block by block, without ever being written down.

So this topic looks for methods that touch AA only through the map v↦Avv \mapsto Av. Two classic ones answer the two big questions of linear algebra. Power iteration finds the top eigenvector. The conjugate gradient method (CG) solves Ax=bAx = b when AA is symmetric positive definite.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • Power iteration: dominant eigenvalueoptional

    Run power iteration; match |λ| to np.linalg.eigvalsh/eig.

    ~20 min · easier on a computer · The matching course topic has been read.

    Self-check in the notebook — not part of mastery or the certificate.