Numerical Analysis 3

Spring 2005

Questions

Error Analysis

Definitions

In the following let \(TraditionalForm\`p\&^\) be an approximation to p.

The absolute error in the approximation is |\(TraditionalForm\`p\&^\)-p|

The relative error is ((|\(p\&^\)-p|)/(|p|)) provided p≠0

The number \(TraditionalForm\`p\&^\)  approximates p to d significant digits if d is the largest nonnegative integer for which ((|\(p\&^\)-p|)/(|p|))< ((10^(1 - d))/2)

Examples of these definitions are given in your textbook.

0.000507 < (10^-3)/2

Truncation Errors

Truncation errors are the result of replacing a mathematical expression by something that approximates it.  The first term in the Taylor Series expansion of Sin[x] about 0 is x.  But there is an error in approximating Sin[0.011] by 0.011 as is shown in the following.

Sin[0.011] - 0.011

However, if you were to use the 2 term Taylor series expanded around zero to approximate Sin[x], the error would be smaller.  First, the command to produce the first couple of terms of the Taylor Series for Sin[x] expanded about 0.

Series[Exp[x], {x, 0, 3}]

Series[Sin[x], {x, 0, 3}]

To use the Taylor Series in further computations, you may need to get rid of the O(([x])^4) term.  The next command does this.

Normal[Series[Sin[x], {x, 0, 3}]]

Now consider the error is Sin[0.011] when you replace it by the two term Taylor Series.

Sin[0.011] - Normal[Series[Sin[x], {x, 0, 3}]] /. 
      x -> 0.011

Still a small error but much smaller than using only the x term in the Taylor Series Expansion.

The following two tables show first the Taylor Series for Sin[x] with 1 through 7 terms, and then the errors in approximating Sin[0.011] be each of these polynomials.

TableForm[
      ttt = Table[
          Normal[Series[Sin[x], {x, 0, k}]], {k, 1, 13, 2}]]

TableForm[Sin[0.011] - (ttt /. x -> 0.011)]

If you consider the errors in the approximations at a number farther from zero, say 0.25, the errors are larger.

TableForm[Sin[0.25] - (ttt /. x -> 0.25)]

Rounding and Chopping

You are all familiar with rounding of numbers.  Mathematica has a command to round to the nearest integer.

Round[1.2346]

This round command can be used to round to the nearest thousandth by multiplying by 1000, rounding the result, and then dividing by 1000.

N[Round[1.2346 1000]/1000]

Chopping cuts a number off after a certain number of digits.  To chop a number to three digits beyond the decimal in Mathematica, multiply the number by 1000, take the integer part of the resulting number and divide by 1000.

N[IntegerPart[1.2346 1000]/1000]

Loss of Significance

Loss of significance occurs when numbers are close to one another and are subtracted.  Suppose, for example that p=1.112345 and q=1.112346.  Both numbers have 7 decimal digits of precision.

p=1.112345

q = 1.112346

p - q

The difference, p-q, has fewer decimal digits of precision than either p or q--so precision is lost.

Order of Convergence

s1 = Series[(Sqrt[x]), {x, 1, 5}]

s2 = Series[Cos[x], {x, 1, 3}]

s1 + s2

s1 s2