Kinematics and differential equations: Euler's method
IB Math AI · Calculus
The kinematic chain
Differentiating takes displacement to velocity and velocity to acceleration; integrating goes back the other way.
$$s(t)\ \xrightarrow{\ \frac{d}{dt}\ }\ v(t)\ \xrightarrow{\ \frac{d}{dt}\ }\ a(t)$$Two questions that sound alike have different answers. Displacement over $[a,b]$ is $\displaystyle\int_{a}^{b}v\,dt$, a signed quantity. Distance travelled is $\displaystyle\int_{a}^{b}|v|\,dt$, which requires splitting the interval at every $t$ where $v=0$.
Differential equations by separation
$\dfrac{dy}{dx}=ky$ has solution $y=Ae^{kx}$: growth if $k>0$, decay if $k<0$. Newton's law of cooling, $\dfrac{dT}{dt}=-k(T-T_{r})$, has solution $T=T_{r}+Ae^{-kt}$, so the temperature approaches room temperature but never reaches it.
Euler's method
$$y_{n+1}=y_{n}+h\,f(x_{n},y_{n}),\qquad x_{n+1}=x_{n}+h$$Each step follows the tangent line at the current point instead of the true curve. For a solution that is concave up, every tangent lies below the curve, so Euler underestimates, and the errors accumulate. Halving the step roughly halves the final error — the method is first order, so it is far less accurate than the trapezoidal rule.
Euler is worth its place because it works on equations that have no closed-form solution at all, and because it can be run on a spreadsheet.
Worked example: displacement and distance: two questions, two answers
An object moves in a straight line with velocity $v(t)=3t^{2}-12t+9$ m/s, $0\le t\le 4$.
Find the displacement and the distance traveled in the first $4$ seconds, and state at which times the object changes direction.
Solution
Step 1: find all the times of direction change. Do this step first, even when the problem has not asked for it yet.
$$3t^{2}-12t+9=3(t^{2}-4t+3)=3(t-1)(t-3)=0\;\Longrightarrow\;t=1,\ t=3$$Sign check: $v(0)=9>0$, $v(2)=-3<0$, $v(4)=9>0$. The object moves forward on $[0,1]$, backward on $[1,3]$, then forward again on $[3,4]$.
Step 2: displacement. The antiderivative is $s(t)=t^{3}-6t^{2}+9t$:
$$\int_{0}^{4}v\,dt=s(4)-s(0)=(64-96+36)-0=4\ \text{m}$$Step 3: distance. Split at $t=1$ and $t=3$ and add the magnitudes:
$$|s(1)-s(0)|=|4-0|=4,\quad |s(3)-s(1)|=|0-4|=4,\quad |s(4)-s(3)|=|4-0|=4$$$$\text{distance}=4+4+4=12\ \text{m}$$Why this trap is more dangerous than usual in this particular problem: the three parts are exactly equal at $4$ m, so anyone who computes only $\int_{0}^{4}v\,dt=4$ and writes “distance $=4$ m” gets a number that is correct, but correct for a different question. No magnitude check detects it; only reading the problem carefully does.
A note on $t=2$. There $v=-3$ m/s reaches its minimum and the acceleration $a(2)=6(2)-12=0$. The object does not stop at $t=2$; it is moving backward fastest. Zero acceleration means the velocity is momentarily constant, not that the object is at rest; this is where the two concepts often get mixed up.
Worked example: Euler's method and its error
Given $\dfrac{dy}{dx}=x+y$ with $y(0)=1$. Use Euler's method with $h=0.2$ to estimate $y(1)$. The exact solution is $y=2e^{x}-x-1$; compare and explain the direction of the error.
Solution
Step 1: build the table. The iteration formula is $y_{n+1}=y_{n}+0.2(x_{n}+y_{n})$.
| $x_n$ | $0$ | $0.2$ | $0.4$ | $0.6$ | $0.8$ | $1.0$ |
|---|---|---|---|---|---|---|
| $y_n$ | $1$ | $1.2$ | $1.48$ | $1.856$ | $2.3472$ | $2.9766$ |
The first step as a model: $y_{1}=1+0.2(0+1)=1.2$; the second step $y_{2}=1.2+0.2(0.2+1.2)=1.48$.
$$y(1)\approx 2.977$$Step 2: compare with the exact solution.
$$y(1)=2e^{1}-1-1=2(2.71828)-2=3.437$$$$\text{error}=3.437-2.977=0.460,\qquad \frac{0.460}{3.437}=13.4\%$$Step 3: explain the direction of the error. The estimate is an underestimate, and there is a clear geometric reason. The solution $y=2e^{x}-x-1$ has second derivative $2e^{x}>0$ for all $x$, that is, the curve is concave up; and every tangent to a concave-up curve lies below the curve. Euler's method follows the tangent at each step so it keeps falling behind, and the shortfall accumulates over five steps.
Step 4: the role of $h$. With $h=0.1$ (ten steps), Euler gives $y(1)\approx 3.187$ and the error drops to $0.249$, approximately halving when $h$ is halved. That is the sign of a first-order method. For comparison: the trapezoidal rule is second order, so halving $h$ reduces the error by a factor of four.
A practical remark: an error of $13\%$ is very large for a problem with a closed-form solution. The value of Euler's method lies not in accuracy but in the fact that it works on equations that cannot be solved by formula, and can be set up in a spreadsheet in a few minutes.