Numerical algorithms
Six numerical analysis projects, from the limits of machine numbers to the three-body problem, each method written by hand.
- 6
- projects
- SVD
- image compression
- RK4
- and three more solvers

Six projects, from the bits to the planets
Six numerical analysis projects for the IS104 course at ENSEIRB-MATMECA (semester 6, 2024–2025), done in teams, in Python with NumPy, each with its report in LaTeX. Every one starts from the mathematics, implements the method by hand, then measures it against NumPy or SciPy.
1 · The limits of the machine
Floats of very low precision are simulated, with four decimal digits and our own machine addition and multiplication, to measure their relative error: it stays around 10⁻ᵖ, and drops to zero when a value is exactly representable. Then ln 2 is summed from its alternating series, stopping as soon as a new term no longer changes the p-th decimal, and the report studies the CORDIC algorithms that calculators use to rebuild ln, exp or tan from a few stored values.
2 · Linear systems and the heat equation
The Cholesky factorisation, then an incomplete version that keeps the matrix sparse and serves as a preconditioner; the conjugate gradient written by hand and checked against SciPy. Then the heat on a square plate: discretised, the equation becomes a large sparse linear system, solved by the conjugate gradient.



Watch the conjugate gradient heat the plate
A 30 × 30 plate, heated in the middle and held at zero on its edges: 900 unknowns. Slide through the iterations of the conjugate gradient.
3 · Compressing an image with the SVD
The singular value decomposition built by hand: Householder reflections bring the matrix to a bidiagonal form, then QR iterations make it diagonal. An image is then kept with only its k largest singular values: a few numbers per row and per column instead of every pixel.
Compress an image yourself
One of this site's own fractals, 192 × 120 pixels. Keep the k largest singular values of each colour.
The decomposition is computed in advance with NumPy; the page rebuilds the image from k values as you slide.
4 · Newton-Raphson, Lagrange and Bairstow
Newton's method with a Jacobian for nonlinear systems, used to find the five Lagrange points of a two-body system, where gravity and the rotation of the frame balance out; and Bairstow's method to factorise polynomials, compared with Newton-Raphson on time and on the roots it finds.
5 · Splines and integration
Cubic splines through the points of a real NASA airfoil, upper and lower surfaces apart; then the length of curves by numerical integration, with rectangles, midpoints, trapezoids and Simpson, and step doubling until a target precision. They model a laminar airflow around the wing and the pressure it creates.



Bend a cubic spline
Drag the points: the curve through them is a natural cubic spline, smooth up to its second derivative.
6 · Differential equations
Euler, midpoint, Heun and fourth-order Runge-Kutta, written by hand and compared on equations with a known solution. Then the simple and double pendulum, its extreme sensitivity to the starting angles, and the restricted three-body problem, with an asteroid drifting around the L5 point.



Euler against Runge-Kutta
The same equation, whose exact solution is a circle, solved for three turns with four methods. Enlarge the step and watch Euler spiral away.
- Euler
- Midpoint
- Heun
- RK4
- exact
The double pendulum came back later, in real time and by hand: Chaos Lab
Figures of project 5 regenerated on 27 November 2026 by running the code of the repository.









