Numerical methods
Calculus as an algorithm: finding roots, interpolating, differentiating and integrating with finite arithmetic — and knowing how wrong the answer can be.
10 topics
Closed-form answers are the exception. Most equations of engineering, physics and machine learning are solved by iterating a simple step until the answer stops changing:
x₀ → f(x₀), f'(x₀) → x₁ → f(x₁), f'(x₁) → x₂ → … → solution
Three questions decide whether that works: does the iteration converge, how fast, and how much do rounding errors and badly conditioned problems spoil the result?
Topics
Absolute and relative error
Absolute error and relative error . Relative error counts correct significant digits, and it is what floating point controls: every operation is exact up to a relative error of at most in double precision.
Conditioning
How much a problem amplifies relative errors in its data, independently of the algorithm. Its condition number says you can lose about digits however cleverly you compute.
Numerical stability
Whether an algorithm keeps rounding errors under control. Two mathematically equal formulas can behave very differently: subtracting nearly equal numbers (catastrophic cancellation) or iterating an unstable recurrence destroys accuracy.
Order of convergence
How fast the error shrinks: linear (, a fixed number of digits per step), quadratic (, digits double each step). Bisection is linear; Newton is quadratic.
Bisection method
Keep an interval where changes sign and halve it each step. Slow (one bit per step) but impossible to break: Bolzano's theorem guarantees a root inside. It is binary search on a continuous function.
Newton's method
To solve , replace by its tangent line at the current guess and jump to where the tangent hits zero: . Near a simple root the number of correct digits doubles every step.
Fixed-point iteration
Rewrite the equation as and iterate . If is a contraction (), Banach's theorem guarantees a unique fixed point and linear convergence with ratio .
Interpolation
Building a function that passes through given data points. Linear interpolation (lerp) is everywhere in
graphics and animation; polynomials of high degree oscillate wildly (Runge's phenomenon), so practice uses
piecewise polynomials: splines.
Numerical differentiation
Estimating derivatives from function values: has error . Too large an gives truncation error, too small an rounding error; the best for central differences in double precision is around .
Numerical integration (quadrature)
Approximating by a weighted sum of samples. Trapezoid (), Simpson () and Gaussian quadrature are excellent in one or a few dimensions; in high dimensions Monte Carlo takes over.
Where this area leads in computing
λ Scientific computing and algorithms ★★★★★
- Floating point (IEEE 754)★★★★★←Absolute and relative error, Numerical stability, Newton's method
- Scientific computing★★★★★←Absolute and relative error, Conditioning, Order of convergence, Bisection method, Newton's method, Fixed-point iteration, Numerical integration (quadrature)
- Algorithm analysis and complexity★★★★★←Bisection method
ℒ AI and machine learning ★★★★★
- Second-order (Hessian-based) optimization★★★★★←Newton's method
- Loss function★★★★★←Numerical stability
- Gradient descent★★★★★←Order of convergence
- Loss landscape★★★★★←Conditioning
- Reinforcement learning★★★★★←Fixed-point iteration
- Automatic differentiation★★★★★←Numerical differentiation
- Bayesian inference★★★★★←Numerical integration (quadrature)