Numerical solutions and error
Chapter 10 - Follow the local rule in finite steps
Many useful differential equations have no elementary closed-form solution. Numerical methods turn the rate rule into a sequence of approximations.
Euler's method uses the current slope for one short step:
It is the tangent-line approximation repeated.
Lab: shrink the step
For each equation, compare (h=1), (0.5), (0.25), and (0.1). Smaller steps usually reduce error, but they require more work. "Numerical" does not mean "unreliable"; it means error must be estimated and controlled.
Worked example: show every step
- Start. \((t_0,y_0)=(0,1)\). The slope is \(f(0,1)=-1\).
- Step to \(t=0.5\). \(y_1=1+0.5(-1)=0.5\).
- Recompute the slope. At \((0.5,0.5)\), \(f=0.5-0.5=0\). Do not reuse the old slope.
- Step to \(t=1\). \(y_2=0.5+0.5(0)=0.5\).
- Recompute again. At \((1,0.5)\), \(f=0.5\). Thus \(y_3=0.5+0.5(0.5)=0.75\) at \(t=1.5\).
- Behavior check. The state first falls because \(t-y<0\), pauses near the line \(y=t\), then rises after \(t-y>0\). The discrete values reproduce that qualitative change.
A table is part of the reasoning
| (n) | (t_n) | (y_n) | slope (f(t_n,y_n)) | next (y) |
|---|---|---|---|---|
| 0 | 0.0 | 1.000 | -1.000 | 0.500 |
| 1 | 0.5 | 0.500 | 0.000 | 0.500 |
| 2 | 1.0 | 0.500 | 0.500 | 0.750 |
The table prevents a common error: evaluating the new slope at a mixture of old and new coordinates.
Local and global error
Euler replaces a curved segment by a tangent step. If the exact solution has bounded second derivative, one step's local truncation error is proportional to (h^2). Over about (1/h) steps across a fixed time interval, these errors accumulate into global error proportional to (h).
Practical consequence: halving (h) should roughly halve Euler's global error once the steps are small enough for the asymptotic pattern to appear.
Error estimate. Euler with \(h=0.2\) has error about 0.08 at a fixed final time. What error would first-order behavior predict for \(h=0.1\)?
Better slopes: midpoint and Runge-Kutta
Euler uses the slope at the start of a step. A midpoint method samples a slope near the middle. Classical fourth-order Runge-Kutta blends four slope samples. The central design idea is the same: spend more rate evaluations to approximate the curve across each step more accurately.
You do not need to memorize RK4 here. You should be able to ask:
- where does the method sample slopes?
- what order of global error does it claim?
- does halving the step produce the expected convergence?
- does the numerical curve respect known equilibria, signs, and bounds?
Numerical stability is not physical stability
For (y'=-10y), the true solution decays. Euler gives
If (h=0.3), the multiplier is (-2): the approximation alternates and grows even though the true system decays. The step is too large for Euler's stability region.
A plotting tool can connect inaccurate points smoothly. Test convergence by rerunning with a smaller step, and compare the result with qualitative facts from the differential equation.
Fade the computation
Use Euler with (h=0.25) for (y'=y(1-y)), (y(0)=0.2).
- (y_1=0.2+0.25[0.2(0.8)]=\underline{\hspace{4em}}).
- Evaluate the next slope at ((t_1,y_1)=(0.25,\underline{\hspace{3em}})).
- Compute (y_2) and confirm that the approximation stays between 0 and 1.
Check two steps
\(y_1=0.24\). Then the slope is \(0.24(0.76)=0.1824\), so \(y_2=0.24+0.25(0.1824)=0.2856\). Both points respect the phase-line prediction of growth toward 1.
Practice
- Practice - Euler table
10.1 Use Euler with \(h=0.2\) to approximate \(y(0.6)\) for \(y'=y-t\), \(y(0)=1\). Show a slope table.
- Practice - convergence
10.2 For \(y'=y\), \(y(0)=1\), derive Euler's approximation \(y_n=(1+h)^n\). Compare \(h=1,1/2,1/4\) at \(t=1\) with \(e\).
- Integrated - qualitative check
10.3 Design a test that would catch a numerical solution of \(P'=P(1-P/10)\), \(P(0)=2\), crossing above 10.
- Challenge - step stability
10.4 For \(y'=-ay\) with \(a>0\), find all \(h>0\) for which Euler approximations decay in magnitude. Which subset decays without alternating sign?
Retrieve the whole loop
Choose one equation from any earlier chapter and state:
- its structural fingerprint;
- a qualitative prediction;
- an analytic method, if available;
- a numerical fallback; and
- two independent checks.