Why Use a Nonuniform Grid?
A forward Euler calculation does not have to use equally spaced times. A problem may call for larger steps in one part of an interval and smaller steps in another, or the available time points may already be unevenly spaced. The essential bookkeeping is to record the current time and the current approximate solution together, then use the length of the next step in the update.
For a uniform grid, one step length is reused throughout the calculation. On a nonuniform grid, each step has its own length. This changes the arithmetic at each iteration, but not the basic Euler procedure: evaluate the slope at the current point, multiply by the step length, and add that increment to the current solution value.
Definition and Update Rule
Consider the initial-value problem \(y'=f(t,y)\), with \(y(t_0)=y_0\). A nonuniform grid is a sequence of time values \(t_0,t_1,\ldots,t_N\) whose consecutive differences need not be equal. Define the step length from \(t_n\) to \(t_{n+1}\) by \(h_n=t_{n+1}-t_n\). For a forward calculation in increasing time, each \(h_n\) is positive.
The subscript on \(h_n\) matters: the step from \(t_n\) to \(t_{n+1}\) uses \(h_n\), not a step length from another part of the grid. The slope also belongs to the current point \((t_n,y_n)\). The next time and solution value are computed together, so that each row of a calculation corresponds to one point on the grid.
If the grid is given as a list of times, calculate each step length by subtracting consecutive times. For example, if the times are \(0\), \(0.2\), and \(0.5\), then the two step lengths are \(0.2-0=0.2\) and \(0.5-0.2=0.3\). The second step does not use \(0.5\), the total elapsed time; it uses the interval from the current time \(0.2\) to the next time \(0.5\).
Why the Update Uses the Current Step Length
At a current point \((t_n,y_n)\), the differential equation supplies the slope \(f(t_n,y_n)\). Over a short interval of length \(h_n\), forward Euler estimates the change in the solution by the current slope times the interval length. The estimated change is therefore \(h_n f(t_n,y_n)\), which is added to \(y_n\).
This also explains why the time must be updated by the same interval length: that is the time interval over which the slope is being used. In particular, if a time-dependent slope is \(f(t,y)\), the slope for the step beginning at \(t_n\) is evaluated using \(t_n\), not \(t_{n+1}\). The method uses the current point to estimate the change across the next interval.
A Reliable Calculation Layout
A table helps prevent the time index, solution index, and step length from drifting out of alignment. In each row, first identify the current time and solution, then evaluate the slope, then apply that row's step length to calculate the next values.
Start with the current grid time \(t_n\) and approximation \(y_n\).
Evaluate \(f(t_n,y_n)\), using the current time and current approximation.
Calculate \(t_{n+1}=t_n+h_n\) and \(y_{n+1}=y_n+h_n f(t_n,y_n)\).
Use \((t_{n+1},y_{n+1})\) as the current pair for the next row, with its own step length \(h_{n+1}\).
Worked Examples
Worked Example: Increasing Step Lengths with a Time-Dependent Slope
Approximate the solution of \(y'=t+y\), \(y(0)=1\), using step lengths \(h_0=0.2\), \(h_1=0.3\), and \(h_2=0.5\). Find the approximation at the last grid time.
Initially, \(t_0=0\) and \(y_0=1\). The first slope is \(f(t_0,y_0)=t_0+y_0=0+1=1\). Thus $$ t_1=0+0.2=0.2,\qquad y_1=1+0.2(1)=1.2. $$
For the second step, use the current pair \((t_1,y_1)=(0.2,1.2)\). Its slope is \(f(t_1,y_1)=0.2+1.2=1.4\). The step length is \(h_1=0.3\), so $$ t_2=0.2+0.3=0.5,\qquad y_2=1.2+0.3(1.4)=1.2+0.42=1.62. $$
For the third step, the current pair is \((0.5,1.62)\), giving slope \(f(t_2,y_2)=0.5+1.62=2.12\). With \(h_2=0.5\), $$ t_3=0.5+0.5=1,\qquad y_3=1.62+0.5(2.12)=1.62+1.06=2.68. $$
The grid times are \(0\), \(0.2\), \(0.5\), and \(1\), and the corresponding approximations are \(1\), \(1.2\), \(1.62\), and \(2.68\). Check the updates: the three solution increments are \(0.2(1)=0.2\), \(0.3(1.4)=0.42\), and \(0.5(2.12)=1.06\). Adding them successively gives \(1.2\), \(1.62\), and \(2.68\), as calculated.
Worked Example: Nonuniform Steps for a Decay Equation
Apply forward Euler to \(y'=-2y\), \(y(0)=10\), using \(h_0=0.1\), \(h_1=0.2\), and \(h_2=0.1\). Track the time and approximate solution at every step.
At the initial point, \(t_0=0\), \(y_0=10\), and the slope is \(-2(10)=-20\). Therefore $$ t_1=0+0.1=0.1,\qquad y_1=10+0.1(-20)=10-2=8. $$
At the next point, \(t_1=0.1\), \(y_1=8\), so the slope is \(-2(8)=-16\). Use the next step length, \(h_1=0.2\): $$ t_2=0.1+0.2=0.3,\qquad y_2=8+0.2(-16)=8-3.2=4.8. $$
At \((t_2,y_2)=(0.3,4.8)\), the slope is \(-2(4.8)=-9.6\). With \(h_2=0.1\), $$ t_3=0.3+0.1=0.4,\qquad y_3=4.8+0.1(-9.6)=4.8-0.96=3.84. $$
The final approximation is \(y_3=3.84\) at \(t_3=0.4\). As a check, each new value equals the preceding value plus its computed increment: \(10-2=8\), \(8-3.2=4.8\), and \(4.8-0.96=3.84\). The time checks are \(0+0.1=0.1\), \(0.1+0.2=0.3\), and \(0.3+0.1=0.4\).
Worked Example: Recovering Step Lengths from Listed Times
Use forward Euler for \(y'=t-y\), starting from \(y(1)=2\), on the grid \(t_0=1\), \(t_1=1.25\), \(t_2=1.75\), \(t_3=2\). Find the approximation at \(t=2\).
First calculate the differences between consecutive times: $$ h_0=1.25-1=0.25,\qquad h_1=1.75-1.25=0.5,\qquad h_2=2-1.75=0.25. $$ The initial values are \(t_0=1\) and \(y_0=2\). The initial slope is \(f(1,2)=1-2=-1\). Hence $$ y_1=2+0.25(-1)=1.75. $$
At \(t_1=1.25\), the current approximation is \(y_1=1.75\). The slope is \(f(1.25,1.75)=1.25-1.75=-0.5\). Using \(h_1=0.5\), $$ y_2=1.75+0.5(-0.5)=1.75-0.25=1.5. $$
At \(t_2=1.75\), the slope is \(f(1.75,1.5)=1.75-1.5=0.25\). With \(h_2=0.25\), $$ y_3=1.5+0.25(0.25)=1.5+0.0625=1.5625. $$
The approximation at \(t=2\) is \(1.5625\). Check that the grid differences match the stated times: \(1+0.25=1.25\), \(1.25+0.5=1.75\), and \(1.75+0.25=2\). Check the solution updates using their slopes: \(2-0.25=1.75\), \(1.75-0.25=1.5\), and \(1.5+0.0625=1.5625\).
Common Mistake: Reusing One Step Length
A common error is to use the first step length for every iteration, even when the grid is nonuniform. Consider the grid in the third example. Its step lengths are \(0.25\), \(0.5\), and \(0.25\). At the second iteration, the current values are \(t_1=1.25\) and \(y_1=1.75\), and the slope is \(-0.5\).
The incorrect calculation reuses \(0.25\) and gives \(y_2=1.75+0.25(-0.5)=1.625\). But the actual next interval has length \(1.75-1.25=0.5\), so the correct update is \(y_2=1.75+0.5(-0.5)=1.5\). The incorrect value does not correspond to the listed next time \(t_2=1.75\); it uses only half of that interval's length.
What the Grid Records
A nonuniform Euler calculation is a sequence of paired values \((t_n,y_n)\). The index \(n\) identifies both the current time and its associated approximation. The step length \(h_n\) belongs to the transition from that pair to the next one, not to the point alone. Keeping these roles distinct makes it easier to audit a calculation and to locate an error.
| Quantity | Role in the step from \(n\) to \(n+1\) |
|---|---|
| \(t_n\) | Current time at which the slope is evaluated |
| \(y_n\) | Current approximate solution |
| \(f(t_n,y_n)\) | Slope supplied by the differential equation at the current pair |
| \(h_n\) | Length of the interval from \(t_n\) to \(t_{n+1}\) |
| \(t_{n+1},y_{n+1}\) | Next time and next approximate solution |
For a time-dependent equation, checking the slope evaluation is especially useful: the time argument must agree with the current row. For any equation, checking the increment is useful: it must equal the current slope multiplied by the step length in that row. These checks do not certify that an approximation is close to the exact solution; they verify that the Euler updates and grid bookkeeping have been carried out as specified.
Check Your Understanding
For each question, keep the time points, step lengths, and solution values aligned.
- If \(t_0=2\), \(t_1=2.3\), and \(t_2=2.8\), what are \(h_0\) and \(h_1\)?
- For \(y'=t+y\), at \((t_n,y_n)=(1,2)\) with \(h_n=0.4\), what slope is used and what is the next Euler value?
- In the nonuniform update, which step length is used to calculate \(y_{n+1}\), and at which point is the slope evaluated?
- What bookkeeping error occurs if a calculation uses the same step length at every iteration despite unequal grid spacing?
- For the grid \(0,0.2,0.7\), state the two step lengths and the final grid time.