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.

+4 m −4 m +4 m t = 1 t = 3 t = 4 v t độ dời = 4 + (−4) + 4 = 4 m quãng đường = 4 + 4 + 4 = 12 m v(t) = 3t² − 12t + 9
The two questions “how far did it travel” and “how far is it from the start” give two different answers, and this figure is the one place where you can see why. The velocity is positive on $0\lt t<1$ and $3\lt t<4$ (blue regions), negative on $1\lt t<3$ (red region): the object runs forward, comes back, then runs forward again. The integral $\int_0^4 v\,dt$ adds signed area so the red region is subtracted: $4-4+4=4$ m, which is the displacement. The distance traveled adds magnitudes: $\int_0^4|v|\,dt=4+4+4=12$ m. The three numbers $4$, $-4$, $4$ being equal here comes from the symmetry of $v$ about $t=2$, and that very symmetry makes the problem easy to fall into the trap: anyone who computes only $\int_0^4 v\,dt$ and answers “distance $=4$ m” gets a number that is correct for a different question. A safe procedure: solve $v=0$ first to find all the times the direction changes, split the interval there, and only then integrate over each piece. Note also: at $t=1$ and $t=3$ the object stops and reverses; at $t=2$, where $v=-3$ reaches its minimum, the object is moving backward fastest and is not stopped at all.

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.

Common mistake

First trap, met in almost every paper: answering the displacement when the question asks for the distance. Guard against it with a mechanical habit: solve $v=0$ first, always. If $v$ does not change sign it costs ten seconds; if it does, it saves the whole question. Second trap: thinking zero acceleration means the object is at rest. Zero acceleration says only that the velocity is not changing; the object may be moving very fast. Conversely, $v=0$ with nonzero acceleration is when the object truly stops and then reverses. Third trap: stopping Euler's method at the wrong step. Going from $x=0$ to $x=1$ with $h=0.2$ takes exactly $5$ steps; the table has $6$ rows but only $5$ iterations. This is the same kind of off-by-one as counting trapezoid strips. Fourth trap: substituting a new value midway through a step. In $y_{n+1}=y_{n}+h(x_{n}+y_{n})$, both $x_n$ and $y_n$ are the old values; using $x_{n+1}$ on the right-hand side means you have switched to a different method. Fifth trap: concluding that the object cools to exactly room temperature. The solution $T=T_{r}+Ae^{-kt}$ approaches $T_{r}$ but never equals it; the question “how long until it has completely cooled” has no finite answer, and the answer that earns marks must say so.

Key takeaway

Kinematics comes down to one question: does the velocity change sign on the interval being considered: if so, displacement differs from distance; if not, the two answers coincide. Differential equations come down to one choice: solve by formula if you can, otherwise run Euler and state clearly whether the result is an underestimate or an overestimate based on the concavity of the solution. In both places, the marks lie in the comment, not in the number.

← Integration and numerical methods: area and the trapezoidal rule · All IB Math AI lessons · Practice IB Math AI questions (free, instant scoring)