NU1–NU3 - Absolute, relative and propagated errors

NU1–NU3 - Absolute, relative and propagated errors

NU1 measures signed absolute and relative errors and follows them through arithmetic. NU2 distinguishes an exact change in a function from a small-error estimate or a guaranteed bound. NU3 investigates why mathematically equivalent orders of calculation can give different finite-precision answers.

Absolute error records a signed difference

Two input approximations are each 1%1\% too large. Must their quotient also be too large? Surprisingly, their errors can cancel exactly in the quotient. To see why, keep the direction of each error, rather than just its size.

You already know

A function value f(x)f(x) is an output, and f′(x)f'(x) is its local gradient. Evaluate fractions with full available precision. Rounding only the final display differs from rounding an intermediate value before it is reused.

A length whose exact value is 8 cm8\,\mathrm{cm} might be approximated by 8.04 cm8.04\,\mathrm{cm}. The discrepancy is 0.04 cm0.04\,\mathrm{cm}, but an equally large discrepancy below the truth has the opposite sign.

Absolute and relative error

Write the exact value as xx and its approximation as XX. In this course the absolute error is the signed quantity

e=X−xe=X-x

The relative error, for x≠0x\ne0, is

r=X−xxr=\frac{X-x}{x}

The magnitude of the absolute error is ∣e∣|e|. Absolute error has the original quantity's units; relative error has no units. A signed percentage error is 100r%100r\%.

These error definitions are not in the formula booklet: learn them.

“Absolute” here does not mean “take the modulus”. Some conventions use that word for the error magnitude, so say which convention you use. Keeping the sign helps when propagating actual errors.

Worked example 1: an overestimate

Question. An exact length is x=8 cmx=8\,\mathrm{cm}, approximated by X=8.04 cmX=8.04\,\mathrm{cm}. Find the absolute error, relative error and percentage error.

Plan. Subtract exact from approximate, then divide by the exact length.

e=8.04−8=0.04 cmapproximate minus exactr=0.048=0.005divide by the exact value100r%=0.5%percentage form\begin{aligned} e&=8.04-8=0.04\,\mathrm{cm}&&\text{approximate minus exact}\\ r&=\frac{0.04}{8}=0.005&&\text{divide by the exact value}\\ 100r\%&=0.5\%&&\text{percentage form} \end{aligned}

Why this step? Dividing by 8.048.04 would measure the discrepancy relative to the approximation, rather than use the defined relative error.

Answer. Absolute error 0.04 cm0.04\,\mathrm{cm}, relative error 0.0050.005, percentage error 0.5%0.5\%.

Check. The positive error agrees with an approximation above the exact positive length.

Change only the approximation from 8.048.04 to 7.96 cm7.96\,\mathrm{cm}. The error magnitude stays fixed, but its direction reverses.

Worked example 2: an underestimate

Question. Find the same errors when the exact length is 8 cm8\,\mathrm{cm} and its approximation is 7.96 cm7.96\,\mathrm{cm}.

Plan. Use the same subtraction order and the same exact denominator.

e=7.96−8=−0.04 cmsigned differencer=−0.048=−0.005relative to the truth100r%=−0.5%signed percentage\begin{aligned} e&=7.96-8=-0.04\,\mathrm{cm}&&\text{signed difference}\\ r&=\frac{-0.04}{8}=-0.005&&\text{relative to the truth}\\ 100r\%&=-0.5\%&&\text{signed percentage} \end{aligned}

Why this step? Taking an absolute value now would discard information needed to distinguish this underestimate from the previous overestimate.

Answer. Absolute error −0.04 cm-0.04\,\mathrm{cm}, relative error −0.005-0.005, percentage error −0.5%-0.5\%. The absolute-error magnitude is 0.04 cm0.04\,\mathrm{cm}.

Check. X=x(1+r)=8(0.995)=7.96X=x(1+r)=8(0.995)=7.96, recovering the approximation.

For a negative exact value, the sign of relative error can differ from the sign of absolute error because its denominator is negative. At exact value zero, relative error is undefined.

Watch out

Wrong: always divide by the approximation or always make the error positive. Right: use X−xX-x and divide by xx; use ∣X−x∣|X-x| only when the magnitude is required.

The next quantity is signed, making the denominator's sign matter.

Separate exact propagation from first-order rules

For known exact and approximate inputs, the safest exact calculation is to form the exact output and the approximate output, then subtract. Compact propagation formulas explain the relationship.

Let X=x+ex=x(1+rx)X=x+e_x=x(1+r_x) and Y=y+ey=y(1+ry)Y=y+e_y=y(1+r_y). A sum has error ex+eye_x+e_y; a difference has error ex−eye_x-e_y. If only bounds ∣ex∣≤a|e_x|\le a and ∣ey∣≤b|e_y|\le b are known, either output's absolute-error magnitude is at most a+ba+b.

Exact arithmetic error identities

For the sum and difference,

(X+Y)−(x+y)=ex+ey,(X−Y)−(x−y)=ex−ey(X+Y)-(x+y)=e_x+e_y,\qquad (X-Y)-(x-y)=e_x-e_y

For a product with xy≠0xy\ne0,

rproduct=rx+ry+rxryr_{\mathrm{product}}=r_x+r_y+r_xr_y

For a quotient with x≠0x\ne0, y≠0y\ne0 and Y≠0Y\ne0,

rquotient=rx−ry1+ryr_{\mathrm{quotient}}=\frac{r_x-r_y}{1+r_y}

These identities are exact.

Not in the formula booklet: learn it.

When both relative errors are small, ignoring their products gives rproduct≈rx+ryr_{\mathrm{product}}\approx r_x+r_y and rquotient≈rx−ryr_{\mathrm{quotient}}\approx r_x-r_y. These first-order approximations are not guaranteed error bounds and are not supplied in the booklet. An exact calculation still matters when leading terms cancel.

Worked example 3: equal relative errors

Question. Exact values x=10x=10, y=2y=2 are approximated by X=10.1X=10.1, Y=2.02Y=2.02. Find the signed absolute errors in the sum, difference, product and quotient. Compare the product and quotient relative errors with first-order estimates.

Plan. Compute both outputs for each operation, then use rx=ry=0.01r_x=r_y=0.01.

OperationExact outputApproximate output
Sum121212.1212.12
Difference888.088.08
Product202020.40220.402
Quotient5555
esum=12.12−12=0.12subtract outputsedifference=8.08−8=0.08subtract outputseproduct=20.402−20=0.402exact product errorequotient=5−5=0exact cancellationrproduct=0.40220=0.0201includes rxryrquotient=0equal scale factors cancel\begin{aligned} e_{\mathrm{sum}}&=12.12-12=0.12&&\text{subtract outputs}\\ e_{\mathrm{difference}}&=8.08-8=0.08&&\text{subtract outputs}\\ e_{\mathrm{product}}&=20.402-20=0.402&&\text{exact product error}\\ e_{\mathrm{quotient}}&=5-5=0&&\text{exact cancellation}\\ r_{\mathrm{product}}&=\frac{0.402}{20}=0.0201&&\text{includes }r_xr_y\\ r_{\mathrm{quotient}}&=0&&\text{equal scale factors cancel} \end{aligned}

Why this step? The quotient is 10(1.01)/[2(1.01)]10(1.01)/[2(1.01)], so its common error factor cancels exactly, not merely approximately.

Answer. The absolute errors are 0.120.12, 0.080.08, 0.4020.402 and 00. The first-order relative estimates are 0.020.02 for the product and 00 for the quotient, compared with exact values 0.02010.0201 and 00.

Check. The sum/difference bound from input magnitudes is 0.1+0.02=0.120.1+0.02=0.12. Both calculated errors satisfy it.

Change only the second approximation to Y=1.98Y=1.98, making its relative error −0.01-0.01. The signs now favour cancellation in the product rather than in the quotient.

Worked example 4: opposite relative errors

Question. Repeat the calculations for x=10x=10, y=2y=2, X=10.1X=10.1, Y=1.98Y=1.98.

Plan. Form the new outputs, with rx=0.01r_x=0.01 and ry=−0.01r_y=-0.01.

esum=12.08−12=0.08sum erroredifference=8.12−8=0.12difference erroreproduct=19.998−20=−0.002product errorrproduct=−0.002/20=−0.0001exact relative errorXY=10.11.98=50599exact quotientequotient=50599−5=1099subtract exact outputrquotient=10/995=299relative error\begin{aligned} e_{\mathrm{sum}}&=12.08-12=0.08&&\text{sum error}\\ e_{\mathrm{difference}}&=8.12-8=0.12&&\text{difference error}\\ e_{\mathrm{product}}&=19.998-20=-0.002&&\text{product error}\\ r_{\mathrm{product}}&=-0.002/20=-0.0001&&\text{exact relative error}\\ \frac XY&=\frac{10.1}{1.98}=\frac{505}{99}&&\text{exact quotient}\\ e_{\mathrm{quotient}}&=\frac{505}{99}-5=\frac{10}{99}&&\text{subtract exact output}\\ r_{\mathrm{quotient}}&=\frac{10/99}{5}=\frac2{99}&&\text{relative error} \end{aligned}

Why this step? The first-order product estimate is zero, but the omitted cross-term is (0.01)(−0.01)=−0.0001(0.01)(-0.01)=-0.0001. Zero first-order error does not mean zero actual error.

Answer. Absolute errors: 0.080.08, 0.120.12, −0.002-0.002, 10/9910/99. The exact product relative error is −0.0001-0.0001, compared with first-order estimate 00; the quotient's exact relative error is 2/992/99, approximately 0.0202020.020202, compared with estimate 0.020.02.

Check. The difference error now reaches the same 0.120.12 bound. Also (0.01−(−0.01))/(1−0.01)=2/99(0.01-(-0.01))/(1-0.01)=2/99, matching the exact quotient calculation.

A small absolute error in a difference can still be large relative to a very small exact difference. The next lesson examines that loss of relative precision more closely.

Watch out

Wrong: promote rx+ryr_x+r_y or rx−ryr_x-r_y from an approximation to an exact identity. Right: retain the product term or quotient denominator when exact errors are requested.

Change the relative-error magnitudes while retaining opposite signs.

A tangent estimate is different from a guarantee

Replacing xx by X=x+eX=x+e changes a function's output by f(X)−f(x)f(X)-f(x). A tangent line estimates that change, but curvature means the estimate need not equal the actual error.

Function error: exact, estimated and bounded

If f(X)f(X) approximates f(x)f(x), its exact signed error is

ef=f(X)−f(x)e_f=f(X)-f(x)

For a small input error e=X−xe=X-x, a first-order estimate is

ef≈f′(x)ee_f\approx f'(x)e

If ∣f′(t)∣≤M|f'(t)|\le M throughout the interval between xx and XX, a rigorous bound is

∣ef∣≤M∣e∣|e_f|\le M|e|

The bound requires a derivative bound over the whole interval, not just at its starting point.

Not in the formula booklet: learn it.

Continue this lesson.

You’re previewing NovaLearn without an account. Create a free account to read the rest.

Create free account