Tutorials › Calculus I › Comparing Euler Polygons with Exact Solution Curves

Euler's Method and Numerical Solutions · Tutorial 1434 of 1495

Comparing Euler Polygons with Exact Solution Curves

Compare an Euler polygon with its exact solution curve at matching times, including along the straight segments between grid points.

Advanced 9 min read

What You'll Learn

  • Define signed and absolute discrepancies between an Euler polygon and an exact solution.
  • Write the Euler polygon on each grid interval, including for a nonuniform grid.
  • Compare numerical and exact values at matching grid points and interior times.
  • Interpret whether the Euler polygon lies above or below the exact curve.
  • Recognize that discrepancy need not increase steadily across an interval.
  • Avoid comparing values evaluated at different times.

Why Compare an Euler Polygon with an Exact Curve?

Euler’s method produces approximate values at selected times. Joining those values by straight line segments gives an Euler polygon, a continuous piecewise-linear approximation to the solution of an initial-value problem. When an exact solution is known, placing the polygon beside its solution curve lets us inspect how well the approximation represents the solution across an interval.

A fair comparison uses the same time for both values. At a grid point, compare the Euler value with the exact solution there. Between grid points, compare the point on the relevant line segment with the exact solution at that interior time. The sign of the difference says which graph is higher; its absolute value gives the size of the vertical discrepancy.

Definitions for a Point-by-Point Comparison

Consider an initial-value problem \(y'=f(t,y)\), \(y(t_0)=y_0\), and a grid \(t_0<t_1<\cdots<t_N\). Write \(h_n=t_{n+1}-t_n\) for the length of the \(n\)-th step. Forward Euler computes approximations \(y_n\) by

$$ y_{n+1}=y_n+h_n f(t_n,y_n). $$

Suppose the exact solution \(y(t)\) is known on the interval being considered. The Euler polygon \(P(t)\) is the continuous function that has value \(y_n\) at \(t_n\) and is linear from \(y_n\) to \(y_{n+1}\) on each grid interval.

Definition: At a grid point \(t_n\), the signed nodal discrepancy is \(e_n=y_n-y(t_n)\). Its absolute size is \(|e_n|\). At any time \(t\) on the interval, the signed discrepancy between the polygon and the exact solution is \(E(t)=P(t)-y(t)\), and the absolute discrepancy is \(|E(t)|\). A negative signed discrepancy means the polygon is below the exact curve; a positive one means it is above.

The distinction between signed and absolute discrepancy matters. For instance, \(E(t)=-0.2\) means the polygon is \(0.2\) units below the curve, while \(|E(t)|=0.2\) reports only the vertical distance. If the solution has physical units, these discrepancies have the same units as \(y\).

What the Polygon Does Between Grid Points

On the interval from \(t_n\) to \(t_{n+1}\), the polygon is the line joining \((t_n,y_n)\) and \((t_{n+1},y_{n+1})\). Its value is therefore

$$ P(t)=y_n+\frac{t-t_n}{h_n}(y_{n+1}-y_n), \qquad t_n\le t\le t_{n+1}. $$

Here \(h_n>0\), and the formula works for a uniform or nonuniform grid. Substituting the Euler update gives an equivalent expression that makes the segment’s slope explicit:

$$ \begin{aligned} P(t) &=y_n+\frac{t-t_n}{h_n}\bigl(h_n f(t_n,y_n)\bigr)\\ &=y_n+(t-t_n)f(t_n,y_n). \end{aligned} $$

This identity explains why the polygon segment has the slope used at the start of that Euler step. It also shows exactly how to find a polygon value at an interior time: use the starting approximation and the step’s slope, not a new Euler update at the interior time.

Key comparison rule: To compare at time \(t\), evaluate both functions there: use \(P(t)\) for the Euler polygon and \(y(t)\) for the exact solution. At a node \(t_n\), this reduces to comparing \(y_n\) and \(y(t_n)\).

Worked Examples

Worked Example: Growth with \(y'=y\)

Compare forward Euler with the exact solution of \(y'=y,\ y(0)=1\), using step size \(h=0.5\) on \([0,1]\). The exact solution is \(y(t)=e^t\), since its derivative is \(e^t\) and \(y(0)=e^0=1\).

At \(t_0=0\), the Euler value is \(y_0=1\). The slope for the first step is \(f(0,1)=1\), so

$$ y_1=1+0.5(1)=1.5. $$

At \(t_1=0.5\), the slope is \(f(0.5,1.5)=1.5\). Thus

$$ y_2=1.5+0.5(1.5)=2.25. $$

Now compare at the matching grid times. At \(t=0.5\), the exact value is \(e^{0.5}\approx1.648721\), so

$$ e_1=1.5-e^{0.5}\approx -0.148721. $$

At \(t=1\), the exact value is \(e\approx2.718282\), giving

$$ e_2=2.25-e\approx -0.468282. $$

At the interior time \(t=0.75\), the polygon is halfway along its second segment:

$$ P(0.75)=1.5+(0.75-0.5)(1.5)=1.875. $$

The exact value is \(e^{0.75}\approx2.117000\), so \(E(0.75)\approx1.875-2.117000=-0.242000\). In all three comparisons the polygon is below the exact curve. The values are checked against the Euler update and the exact solution at precisely the same times.

Worked Example: Decay and a Decreasing Nodal Discrepancy

Use forward Euler with \(h=1\) for \(y'=-y,\ y(0)=1\), on \([0,2]\). The exact solution is \(y(t)=e^{-t}\), because its derivative is \(-e^{-t}\) and its initial value is \(1\).

At \(t_0=0\), the slope is \(-1\), so \(y_1=1+1(-1)=0\). At \(t_1=1\), the slope is \(-y_1=0\), so \(y_2=0+1(0)=0\). The Euler values are therefore \(1,0,0\) at times \(0,1,2\).

At \(t=1\), the signed nodal discrepancy is

$$ e_1=0-e^{-1}\approx-0.367879. $$

At \(t=2\), it is

$$ e_2=0-e^{-2}\approx-0.135335. $$

The polygon is below the exact curve at both nodes, but the absolute nodal discrepancy decreases from about \(0.367879\) to \(0.135335\). Thus, even across one fixed interval, nodal discrepancy need not grow at every step.

For an interior check, on \([0,1]\) the polygon is \(P(t)=1-t\). At \(t=0.5\), \(P(0.5)=1-0.5=0.5\), whereas \(y(0.5)=e^{-0.5}\approx0.606531\). Hence \(E(0.5)\approx-0.106531\). On \([1,2]\) the polygon is \(P(t)=0\); at \(t=1.5\), its discrepancy is \(0-e^{-1.5}\approx-0.223130\). The interior comparison is made from the appropriate segment in each case.

Worked Example: Comparing at an Interior Time

Consider \(y'=t,\ y(0)=0\), with step size \(h=1\) on \([0,2]\). Integrating the slope gives the exact solution \(y(t)=t^2/2\), which satisfies \(y'(t)=t\) and \(y(0)=0\).

Starting with \(y_0=0\), the first Euler slope is \(f(0,0)=0\), so \(y_1=0+1(0)=0\). The next slope is \(f(1,0)=1\), so \(y_2=0+1(1)=1\). The Euler polygon is constant at \(0\) on \([0,1]\), then joins \((1,0)\) to \((2,1)\) on the second interval.

At \(t=1\), the Euler value is \(0\) and the exact value is \(1^2/2=0.5\), so \(e_1=-0.5\). At \(t=2\), the Euler value is \(1\) and the exact value is \(2^2/2=2\), so \(e_2=-1\).

At \(t=1.5\), use the segment beginning at \((1,0)\), whose slope is \(1\):

$$ P(1.5)=0+(1.5-1)(1)=0.5. $$

The exact value there is \(y(1.5)=(1.5)^2/2=2.25/2=1.125\). Thus \(E(1.5)=0.5-1.125=-0.625\). The polygon lies below the exact curve at this interior time as well. Substituting into the segment formula and the exact solution verifies both values.

A Common Mistake: Comparing Different Times

A discrepancy is meaningful only when the two compared values belong to the same time. For example, in the growth example, one might incorrectly compare the Euler value \(y_1=1.5\) at \(t=0.5\) with the exact value \(e^1\approx2.718282\) at \(t=1\). That gives \(1.5-2.718282\approx-1.218282\), but it is not an error at either time: it subtracts values from different times.

The correction is to evaluate the exact solution at \(t=0.5\): \(e^{0.5}\approx1.648721\). The matching-time discrepancy is \(1.5-1.648721\approx-0.148721\). A related mistake is to call a negative signed discrepancy a negative distance. Distance is nonnegative; the sign instead records which graph is higher.

What the Comparison Can—and Cannot—Show

Plotting both graphs and calculating discrepancies at selected times helps describe the approximation on a fixed interval. The signed values indicate whether the polygon is above or below the curve at those times; absolute values allow comparisons of vertical separation. Interior evaluations are useful because matching grid-point values alone do not describe every point along the straight segments.

These comparisons describe what happens for the chosen equation, initial value, grid, and interval. They do not by themselves prove that the polygon stays on one side of the curve between sampled times, nor that the discrepancy changes monotonically throughout the interval. A visual impression is useful, but it is not a general error bound. The later analysis of Euler error addresses questions of local and accumulated error more systematically.

Takeaway: Compare \(P(t)\) with \(y(t)\) at matching times. Keep the signed discrepancy \(P(t)-y(t)\) distinct from its absolute size, and do not assume the discrepancy must steadily increase or decrease.

Check Your Understanding

Use the definitions and segment formula to answer the following questions.

  1. If \(P(t)-y(t)=0.3\) at a particular time, which graph is higher, and what is the absolute discrepancy?
  2. On a nonuniform grid interval \([t_n,t_{n+1}]\), what formula gives the Euler polygon value at an interior time \(t\)?
  3. Why must an Euler value and an exact value be evaluated at the same time before their difference is called a discrepancy?
  4. Can the absolute nodal discrepancy decrease from one grid point to the next? Explain using the decay example.
  5. In the growth example, what is the Euler polygon’s value at \(t=0.75\), and how does it compare with the exact value there?

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon