Math foundations · topic A4 · 25 hours
Numerical methods & differential equations
Simulation, integrators, dynamics solvers — all face numerical stability. Pick the wrong step size and the simulation «blows up», and it looks exactly like an algorithm bug.
What to learn
- The stability difference between explicit and implicit integrators; why semi-implicit Euler is the common choice in rigid-body simulation
- Stiff equations and step size: when you must shrink the step or switch integrators
- Floating-point precision and accumulated error: why position drifts after a long integration
- How to think about solving sparse linear systems (the matrices of robot dynamics are mostly sparse)
The lesson · plain words
The real world is continuous: the motor spins at every instant. The computer is discrete: it computes once per millisecond and «pretends nothing moved» in between. Numerical computation studies exactly this pretending — when it is good enough, and when it blows up.
You may have seen the blow-up: turn up a simulator's step size and the robot gains energy out of thin air and shakes violently — the physics is not wrong; discretization got the energy wrong. This page explains why, plus the three field rules of engineering.
Euler's method: chasing a curve with line segments
The simplest numerical integration is Euler's method: next state = now + slope × step size. You chase a curved line with a chain of straight segments. A hand calculation: simulate x′ = −x (exponential decay); with dt = 0.5 each step keeps half, so after 10 steps 0.001 remains; the true value is e⁻⁵ ≈ 0.0067 — every Euler step «over-decays» a little, and the error is proportional to dt.
The upgraded scheme is called Runge–Kutta (RK4): compute several slopes per step and take a weighted average, dropping the error to the order of dt⁵. At the same dt, the accuracy differs by several orders of magnitude — this is why «method beats brute force».
Interactive figure · drag it and see
The step-size dilemma
Small dt: accurate, but compute explodes (the cost grows as 1/dt); large dt: saves compute, but the integrator starts «generating electricity» on its own — in contact-rich or stiff systems, energy is no longer conserved and the robot buzzes itself into the air.
A simulator's default 1 kHz step is not a guess: the fastest dynamics in the scene (set by contact stiffness) must be resolved far more finely than dt, or the physics is simply wrong. When you tune the timestep in Isaac/MuJoCo, you are finding the sweet spot between «compute cost» and «physically correct».
Taylor expansion: the ancestor of every approximation
The «derivative = tangent line» you learned in high school is actually the first term of the Taylor expansion. Expand to second order and the curve's bending is taken care of too. The most famous robotics application: at every step, MPC expands the nonlinear dynamics at the current point into linear A and B matrices — first-order Taylor, exactly.
The animation below: click the buttons to change the order and watch the polynomial glue itself onto the sin curve layer by layer. Approximation is not guesswork; it comes with a contractual error guarantee.
Interactive figure · drag it and see
Two field rules of numerical hygiene
① Never solve linear systems with determinants or Cramer's rule — use LU/QR factorization; precision and speed differ by orders of magnitude (library functions already do this for you, do not hand-write it). ② Beware subtracting two nearly equal large numbers — significant digits evaporate instantly («the big swallows the small»); computing a relative rotation between two nearly identical poses is the easiest place to step on this.
Three questions — do you really get it?
1. Euler's method with the step size dt halved — the error becomes roughly?
- AOne half
- BOne quarter
- CUnchanged
Show answer
A. Euler's error is O(dt), proportional to the step — halve it and it halves. RK4 is O(dt⁵); halving dt drops its error 32-fold.
2. The simulator step size set too large — the classic symptom?
- AEnergy appears out of nowhere and the shaking diverges
- BIt slows down
- CNo effect
Show answer
A. Discretization error shows up as non-conserved energy in stiff, contact-coupled systems — the robot «generates its own electricity» and shakes violently.
3. Where do the A and B matrices in MPC come from?
- AThey are measured
- BA first-order Taylor expansion of the nonlinear dynamics at the current point
- CLearned by a neural network
Show answer
B. Linearization = taking the Jacobian = the first-order Taylor term. The expansion point changes every step, hence «recursion».
Keep going deeper
Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.
How it fails in the field
- Running the simulation at a 1 ms step while claiming it reflects the behavior of a 2 kHz current loop
- When results diverge you suspect the algorithm first, when halving the step size would have fixed it
You have learned enough when
The Chinese edition carries the full topic page for Numerical methods & differential equations, including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/A4/.