Numerical analysis for biologists

A self-paced course on how computers actually compute: what happens inside solve(), optim(), uniroot(), integrate(), ode() and their Python counterparts in scipy, why they sometimes give wrong answers without complaining, and how to tell. Every method is paired with a biological problem that needs it.

Who this is for

You are a biologist who already:

  • programs in R or Python (scripts, functions, loops, plotting),
  • has taken a first course in calculus (derivatives, integrals, Taylor series in one variable), and
  • has taken a first course in linear algebra (matrices, solving \(A\mathbf{x} = \mathbf{b}\), eigenvalues).

We recap what we need from calculus and linear algebra as we go, with numbers next to every formula.

What you will be able to do

  • Explain why 0.1 + 0.2 == 0.3 is FALSE, and why that matters for a likelihood.
  • Choose and tune a method to solve equations, fit models, integrate, interpolate and simulate dynamical systems, and judge whether the answer can be trusted.
  • Reason about error and cost: how fast a method converges, and what it costs as your data grows from 10 genes to 20 000.
  • Do the small case by hand and the large case in code.

How the course works

There is no fixed schedule. Work through the sidebar from top to bottom, at your own pace. Each unit has:

  • a lecture (slides, and a video when it is recorded),
  • a short quiz to check the key ideas,
  • an exercise with by-hand problems, code, and often an interactive demo.

The course is taught in R, and the slides use R. If you prefer Python or Rust, the exercises show every code example, hint and solution in those languages too: click the Python or Rust tab once and the page switches throughout.

Before you start

  • Install R and the packages used in the course (and Python or Rust, if you prefer them).

Topics

Part 1 is ready; the other parts are being written. The planned parts are:

  1. Numbers on a computer — floating point, rounding, error, conditioning, stability.
  2. Solving nonlinear equations — bisection, fixed points, Newton’s method.
  3. Linear systems — elimination and LU, conditioning, sparse and structured matrices.
  4. Least squares — QR, the SVD, rank deficiency and regularisation.
  5. Eigenvalue problems — power iteration, the QR algorithm, large sparse problems.
  6. Interpolation and approximation — polynomials, splines, Fourier and the FFT.
  7. Numerical differentiation and integration — finite differences, quadrature, Monte Carlo.
  8. Differential equations — Euler to Runge–Kutta, stiffness, stochastic simulation.
  9. Stochastic differential equations — Brownian motion, Euler–Maruyama, the Itô correction, Fokker–Planck.
  10. Optimisation and model fitting — from gradient descent to fitting an ODE model to data.
  11. Diffusion and heat — finite-difference models of concentration and temperature in microfluidic chips, from 1D diffusion to flow, iterative solvers for large grids, reaction and pattern formation.
  12. Finite elements and flow — beyond rectangular grids: hat functions, the weak form, meshes and flow solvers.