Tutorials › Calculus I › Unit and Sign Checks for Numerical IVPs

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

Unit and Sign Checks for Numerical IVPs

Use unit, sign, and initial-value checks to catch mistakes in numerical Euler steps before trusting the resulting table.

Advanced 10 min read

What You'll Learn

  • Check that a differential-equation slope has units of dependent-variable units per independent-variable unit.
  • Verify that multiplying a slope by a step size produces a change in the dependent variable.
  • Predict the sign of an Euler update from the slope and the direction of the step.
  • Check that the first numerical row matches the stated initial condition and its independent-variable location.
  • Distinguish a unit or sign error from an approximation that is merely inaccurate.

Why Audit an Euler Calculation?

An Euler table can contain plausible-looking numbers and still be wrong. A time step may have been used in minutes when the rate is given per hour; a negative slope may have been added as a positive change; or the first table entry may not be at the point specified by the initial condition.

Unit, sign, and initial-value checks are quick ways to detect these problems. They do not prove that an approximation is accurate, but they can show that a calculation is internally inconsistent before it is used for further conclusions.

The Checks to Make

For an initial-value problem \(y'=f(t,y)\), the forward Euler update from a point \((t_n,y_n)\) with step size \(h\) is

$$ t_{n+1}=t_n+h, \qquad y_{n+1}=y_n+h f(t_n,y_n). $$

Here the slope is evaluated at the current point \((t_n,y_n)\). If \(t\) has units \(U_t\) and \(y\) has units \(U_y\), then the slope \(f(t_n,y_n)\) must have units \(U_y/U_t\). The step size \(h\) has units \(U_t\), so their product has units \(U_y\), as a change in \(y\) must.

Unit check: In an Euler update, \(h f(t_n,y_n)\) must have the same units as \(y_n\). If it does not, check the units of the rate, the step size, and any unit conversions.

The sign check asks whether the update moves in the direction indicated by the slope. For a positive step \(h\), a positive slope gives a positive change \(h f(t_n,y_n)\), and a negative slope gives a negative change. If \(h\) is negative, as in backward integration, the change has the opposite sign to the slope. In all cases, the sign of the change is the sign of the product \(h f(t_n,y_n)\).

Finally, the initial condition must match the first row in both coordinates. If the problem states \(y(t_0)=y_0\), the table must begin with \(t_0\) and \(y_0\) paired together. The value \(y_0\) cannot be assigned to a different time merely because it is the first entry in a table.

Why the Unit and Sign Checks Work

The Euler formula estimates the change in \(y\) over one step by using the slope at the start of that step. The slope is a rate of change: it describes change in \(y\) per unit change in \(t\). Multiplying by a step in \(t\) therefore produces an estimated change in \(y\).

$$ \text{slope}\times\text{step} = \frac{\text{units of }y}{\text{units of }t} \times \text{units of }t = \text{units of }y. $$

The sign follows from the same update. The estimated change is \(\Delta y=h f(t_n,y_n)\). A positive \(\Delta y\) means the next Euler value is above the current value; a negative \(\Delta y\) means it is below. This is a check on the calculation, not a guarantee that the Euler value closely matches the exact solution.

Important distinction: Passing these checks means the calculation is dimensionally and directionally consistent with the stated update. It does not establish that the step is sufficiently small or that the numerical approximation is accurate.

Worked Examples

Worked Example: Checking a Cooling Step

A temperature \(T\), measured in degrees Celsius, satisfies \(T'=-k(T-20)\), where \(k=0.02\ \text{min}^{-1}\). At time \(t_0=0\ \text{min}\), the stated initial temperature is \(T_0=80^\circ\text{C}\). Use one forward Euler step of \(h=5\ \text{min}\).

First check the initial value: the starting row is \((t_0,T_0)=(0\ \text{min},80^\circ\text{C})\), which agrees with the stated condition. The temperature difference in the rate equation is

$$ T_0-20^\circ\text{C} = 80^\circ\text{C}-20^\circ\text{C} = 60^\circ\text{C}. $$

The slope at the starting point is

$$ f(t_0,T_0) = -(0.02\ \text{min}^{-1})(60^\circ\text{C}) = -1.2^\circ\text{C}/\text{min}. $$

The units are temperature per time, as required. The Euler change is

$$ h f(t_0,T_0) = (5\ \text{min})(-1.2^\circ\text{C}/\text{min}) = -6^\circ\text{C}. $$

The negative sign predicts a decrease. Therefore,

$$ t_1=0\ \text{min}+5\ \text{min}=5\ \text{min}, \qquad T_1=80^\circ\text{C}-6^\circ\text{C}=74^\circ\text{C}. $$

Check the update by recovering its change: \(T_1-T_0=74^\circ\text{C}-80^\circ\text{C}=-6^\circ\text{C}\). Dividing by the step gives \((-6^\circ\text{C})/(5\ \text{min})=-1.2^\circ\text{C}/\text{min}\), the starting slope used in the Euler step. The units, sign, and initial row are consistent.

Worked Example: Converting a Time Step Before Using It

An amount \(A\), measured in milligrams, has rate \(A'=12-0.5A\), with the constants interpreted so that \(12\) has units \(\text{mg}/\text{hour}\) and \(0.5\) has units \(\text{hour}^{-1}\). The initial condition is \(A(0\ \text{hour})=8\ \text{mg}\). Take one forward Euler step of 30 minutes.

The rate is given per hour, so first convert the step:

$$ h=30\ \text{min} \left(\frac{1\ \text{hour}}{60\ \text{min}}\right) =0.5\ \text{hour}. $$

At the initial value, the rate is

$$ f(0,8) = 12\ \text{mg}/\text{hour} - (0.5\ \text{hour}^{-1})(8\ \text{mg}) = 12\ \text{mg}/\text{hour} - 4\ \text{mg}/\text{hour} = 8\ \text{mg}/\text{hour}. $$

The rate is positive, so over this positive step the Euler change should be positive. Its value is

$$ h f(0,8) = (0.5\ \text{hour})(8\ \text{mg}/\text{hour}) = 4\ \text{mg}. $$

Thus the next time and amount are

$$ t_1=0\ \text{hour}+0.5\ \text{hour}=0.5\ \text{hour}, \qquad A_1=8\ \text{mg}+4\ \text{mg}=12\ \text{mg}. $$

Check: the change is \(12\ \text{mg}-8\ \text{mg}=4\ \text{mg}\), and \(4\ \text{mg}/0.5\ \text{hour}=8\ \text{mg}/\text{hour}\), matching the starting rate. The initial row also agrees with \(A(0)=8\ \text{mg}\).

If 30 were inserted directly as though it were a step measured in hours, the computed change would be \(30\ \text{hour}\times 8\ \text{mg}/\text{hour}=240\ \text{mg}\), giving \(248\ \text{mg}\). The arithmetic follows that incorrect input, but the input represents 30 hours, not 30 minutes. Keeping the units attached to the step exposes the mistake.

Worked Example: Checking a Concentration Step and Its Starting Row

A concentration \(C\), measured in \(\text{mmol}/\text{L}\), satisfies

$$ \frac{dC}{dt} = -\left(0.1\ \frac{\text{L}}{\text{mmol}\cdot\text{min}}\right)C^2. $$

The given initial condition is \(C(3\ \text{min})=1.2\ \text{mmol}/\text{L}\). Use a forward Euler step of \(h=0.5\ \text{min}\) starting from that condition.

The first table entry must be \(t_0=3\ \text{min}\), \(C_0=1.2\ \text{mmol}/\text{L}\). The slope there is

$$ \begin{aligned} f(t_0,C_0) &= -\left(0.1\ \frac{\text{L}}{\text{mmol}\cdot\text{min}}\right) \left(1.2\ \frac{\text{mmol}}{\text{L}}\right)^2\\ &= -\left(0.1\ \frac{\text{L}}{\text{mmol}\cdot\text{min}}\right) \left(1.44\ \frac{\text{mmol}^2}{\text{L}^2}\right)\\ &= -0.144\ \frac{\text{mmol}}{\text{L}\cdot\text{min}}. \end{aligned} $$

The units reduce to concentration per minute, and the negative sign predicts a decrease for a positive time step. The change is

$$ h f(t_0,C_0) = (0.5\ \text{min}) \left(-0.144\ \frac{\text{mmol}}{\text{L}\cdot\text{min}}\right) = -0.072\ \text{mmol}/\text{L}. $$

The Euler update gives

$$ t_1=3\ \text{min}+0.5\ \text{min}=3.5\ \text{min}, \qquad C_1=1.2\ \text{mmol}/\text{L}-0.072\ \text{mmol}/\text{L} =1.128\ \text{mmol}/\text{L}. $$

To check the calculation, \(C_1-C_0=1.128-1.2=-0.072\ \text{mmol}/\text{L}\); dividing by \(0.5\ \text{min}\) recovers \(-0.144\ \text{mmol}/(\text{L}\cdot\text{min})\). If a table instead labels \(1.2\ \text{mmol}/\text{L}\) as the value at \(t=0\), it violates the stated initial condition even if the later arithmetic is performed consistently.

A Practical Audit Sequence

When checking a numerical IVP table, work through the following in order. These checks are especially useful when values have been copied into a spreadsheet or transferred between calculations.

1
Match the initial condition.
Confirm that the first time and state values are exactly the stated pair \(t_0\) and \(y_0\).
2
Check the rate units.
Confirm that \(f(t_n,y_n)\) is expressed in units of \(y\) per unit of \(t\).
3
Put the step in matching units.
Convert \(h\) if necessary before multiplying it by the rate.
4
Predict the sign.
Use the signs of \(h\) and \(f(t_n,y_n)\) to determine whether the next state should increase or decrease.
5
Recompute the increment.
Calculate \(h f(t_n,y_n)\), check its units, and confirm that adding it gives the displayed next value.

Common Pitfalls and Limits of These Checks

A common sign error is to calculate a negative increment and then add its absolute value. For example, if \(y_n=10\) and the Euler increment is \(-2\), the incorrect calculation \(10+|-2|=12\) moves upward. The update requires the signed increment: \(10+(-2)=8\). Checking the sign before addition reveals that the predicted change must be downward.

A different error is to treat a correct sign as proof that a step is reasonable. A negative concentration or temperature prediction may be physically implausible, but units and sign alone do not establish whether a step is small enough to avoid it. Conversely, an unusual result is a reason to recheck the setup and the step, not by itself proof of an arithmetic error.

The checks also depend on using the slope at the correct Euler point. For a forward Euler step from \((t_n,y_n)\), use \(f(t_n,y_n)\), not the slope at the unknown next point. A table can have correct-looking units and signs but still be inconsistent if it uses the wrong evaluation point or the wrong initial row.

Takeaway: A trustworthy Euler update has a correctly placed initial value, a rate and step expressed in compatible units, and an increment whose sign agrees with the product \(h f(t_n,y_n)\). These are necessary consistency checks, not an accuracy certificate.

Check Your Understanding

For each question, state what you would check before accepting the numerical result.

  1. A rate is given in \(\text{m}/\text{s}\), but the step is entered as 200 milliseconds. What conversion should be made before forming the Euler increment?
  2. If \(h>0\) and \(f(t_n,y_n)<0\), what sign must \(y_{n+1}-y_n\) have?
  3. An IVP states \(y(4)=7\), but the first table row pairs \(y_0=7\) with \(t_0=0\). What is inconsistent?
  4. A rate has units \(\text{mg}/\text{hour}\), and \(h\) has units of hours. What units should \(h f(t_n,y_n)\) have?
  5. Why does passing unit and sign checks not prove that an Euler approximation is accurate?

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