You are on page 1of 49

KIE3005

Truncation Errors and the Taylor Series

• Understand how the Taylor series and its remainder are


employed to represent continuous functions.
• Know the relationship between finite divided differences
and derivatives.
• Be able to analyze how errors are propagated through
functional relationships.
• Be familiar with concepts of stability and condition.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

1
4.0 Introduction

• The omission of significant figures is called round


off error.
• Truncation errors are those that result from using
approximation in place of exact mathematical
procedure.
• Example (derivative of falling parachutist):
dv v v(ti 1 )  v(ti )
 
dt t ti 1  ti
Truncation error was
introduced due to the equation
only approximates the true
value of derivative. 2
4.1 The Taylor Series
• Taylor series provides a means to predict the value of
a function at one point in terms of the function value
and its derivatives at another point.
• Taylor series is based on the theorem that states any
smooth function can be approximated as a
polynomial.
• Non-elementary functions such as trigonometric,
exponential, and others are expressed in an
approximate fashion using Taylor series when their
values, derivatives, and integrals are computed.

3
• Lets build the Taylor series term by term. For
example the first term in the series is
f(xi+1) ≈ f(xi) (4.2) zero order approximation, only
true if xi+1 and xi are very close to
each other.
• If the function changes at all over the interval,
additional term needed to provide a better estimate.

f(xi+1) ≈ f(xi) + f′(xi) (xi+1-xi) (4.3) first order


approximation, in
form of a straight line
? ?
• The expression in the form of a straight line capable
of predicting an increase or decrease of a function
between xi and xi+1.

4
• To capture some of the curvature that the function
might exhibit, a second-order term is added:
f 
f ( xi 1 )  f ( xi )  f ( xi )( xi 1  xi )  ( xi 1  xi ) 2 (4.4)
2!

• Additional terms can also be included to develop the


complete Taylor Series (nth order approximation):
f  f (n)
f ( xi 1 )  f ( xi )  f ( xi )( xi 1  xi )  ( xi 1  xi ) 2    ( xi 1  xi ) n  Rn (4.5)
2! n!
f ( n 1) ( )
where Rn  ( xi 1  xi )( n 1) (4.6)
(n  1)!

The sign becomes “=” since the equation considers for all terms

5
Taylor Series can also be generalized as
f  2 f (3) 3 f ( n) n
f ( xi 1 )  f ( xi )  f ( xi )h  h  h  h  Rn (4.7)
2! 3! n!

h = xi+1-xi step size (defined first)

f ( n 1) ( ) ( n 1) Reminder for the nth-order


Rn  h (4.8)
(n  1)! approximation

Reminder term, Rn, accounts for all terms from (n+1)


to infinity.  is a value of x lies between xi and xi+1, it
is a value that provides an exact determination of error.
6
Example 4.1

Problem Statement. Use zero-through fourth-order Taylor series expansions to


approximate the function

𝑓 𝑥 = −0.1𝑥 4 − 0.15𝑥 3 − 0.5𝑥 2 − 0.25𝑥 + 1.2

From 𝑥𝑖 = 01 with h = 1. That is, predict the function’s value at 𝑥𝑖+1 = 1

7
Solution 4.1 Because we are dealing with a known function, we can compute values for 𝑓(𝑥)
between 0 and 1. The results (Fig. 4.1) indicate that the function starts at 𝑓 0 =
1.2 and then curves downward to 𝑓 1 = 0.2. Thus, the true value that we are
trying to predict is 0.2.

The Taylors series approximation with 𝑛 = 0 is [Eq. (4.2)] f(xi+1) ≈ f(xi)


𝑓(𝑥𝑖+1 ) ≃ 1.2

Thus, as in Fig. 4.1, the zero-order approximation is a constant. Using this


formulation results in truncation error [recall Eq. (3.2)] of

𝐸𝑡 = 0.2 − 1.2 = −1.0

at 𝑥 = 1.

For 𝑛 = 1, the first derivative must be determined and evaluated at 𝑥 = 0:

f(xi+1) ≈ f(xi) + f′(xi) (xi+1-xi)  𝑓 ′ (0) = −0.4 0.0 3 − 0.45 0.0 2 − 1.0 0.0 − 0.25 = −0.25
Therefore, the first-order approximation is [Eq. (4.3)]

𝑓(𝑥 𝑖+1 ≃ 1.2 − 0.25ℎ

Which can be used to compute 𝑓 1 = 0.95. Consequently, the approximation


begins to capture the downward trajectory of the function in the form a sloping
straight line (Fig. 4.1). This result in a reduction of the truncation error to

𝐸𝑡 = 0.2 − 0.95 = −0.75


8
For 𝑛 = 2, the second derivative is evaluated 𝑥 = 0:

𝑓 ′ (0) = −1.2 0.0 2


− 0.9 0.0 − 1.0 = −1.0

Therefore, according to Eq. (4.4),

𝑓(𝑥𝑖+1 ) ≃ 1.2 − 0.25ℎ − 0.5ℎ2

and substituting ℎ = 1, 𝑓 1 = 0.45. The inclusion of the second derivative now


adds some downward curvature resulting in an improved estimate, as seen in Fig.
4.1. The truncation error is reduced further to 0.2 − 0.45 = −0.25

Additional terms would improve the approximation even more. In fact, the
inclusion of the third and the fourth derivatives result in exactly the same equation
we started with:

𝑓 𝑥 = 1.2 − 0.25ℎ − 0.5ℎ2 − 0.15ℎ3 − 0.1ℎ4

Where the remainder term is


𝑓 5 (𝜉 )
𝑅4 = ℎ5 = 0
5!

Because the fifth derivative of a fourth-order polynomial is zero. Consequently,


the Taylor series expansion to the fourth derivative yields an exact estimate at
𝑥𝑖+1 = 1:
2 3 4
𝑓 1 = 1.2 − 0.25 1 − 0.5 1 − 0.15 1 − 0.1 1 = 0.2

9
Figure 4.1 The approximation of at x = 1

10
• The nth order Taylor series expansion will be exact for
an nth order polynomial.

• For differentiable and continuous function, such as


exponentials and sinusoids, a finite number of terms
will not yield exact estimate.

• Each additional term can improve slightly the


approximation.

• The number of terms that required to make the


approximation ‘close enough’ to the exact value is
based on the remainder of the term of the expansion
(Eq. 4.8).
11
• The e is unknown exactly, but its lies somewhere
between xi+1 > e > xi .
• In order to determine e need to determine f n+1(x),
however to do this we need f '(x).
• If we knew f(x), wouldn’t be any need to perform the
Taylor series expansion.
• However, Eq. 4.8 is usually expressed as Rn=O(hn+1)
• Nomenclature O(hn+1) means that the truncation error
is of the order of truncation hn+1.
• Error is proportional to the step size h raised to the
(n+1)th power. Thus ;
• If the error is O(h), halving the step size will halve the error.
• If the error is O(h2), halving the step size will quarter the error.
• In general, truncation error decreased by the addition
of terms to the Taylor series.
12
Example 4.2
Use of Taylor Series Expansion to Approximate a Function with an infinite
Number of Derivatives

Problem Statement. Use Taylor series expansions with n = 0 to 6 to approximate


f(x) = cos x at xi+1 = π/3 on the basis of the value of f(x) and its derivatives at
xi = π/4. Note that this means that h = π/3 – π/4 = π/12.

13
Solution 4.2
The zero-order approximation is [Eq.(4.3)]
𝜋 𝜋
𝑓 ≅ cos = 0.707106781 ( f(xi+1) ≈ f(xi))
3 4

which represents a percent relative error of


0.5−0.707106781
𝜀𝑡 = 100% = −41.4%
0.5

For the first-order approximation, we add the first derivative term where

𝑓 ′ = − sin 𝑥: f(xi+1) ≈ f(xi) + f′(xi) (xi+1-xi)


𝜋 𝜋 𝜋 𝜋
𝑓 ≅ cos − sin = 0.521986659
3 4 4 12

which has 𝜀𝑡 = −4.40 percent.

For the second-order approximation, we add the second derivative term where
𝑓"(𝑥) = − cos 𝑥:

𝜋 𝜋 𝜋 𝜋 cos 𝜋/4 𝜋 2
𝑓 ≅ cos − sin − = 0.497754491
3 4 4 12 2 12
with 𝜀𝑡 = 0.449 percent. Thus, the inclusion of additional terms results in an
improved estimate.
14
Solution 4.2

The process can be continued and the results listed, as in Table 4.1.

TABLE 4.1 Taylor series approximation of f(x) = cos x at xi+1 =π/3 using a base point
of π/4. Values are shown for various orders (n) of approximation.

Order n 𝒇 𝒏 (𝑿) 𝒇(𝝅 𝟑) 𝜺𝒕

0 cos x 0.707106781 -41.4


1 -sin x 0.521986659 -4.4
2 -cos x 0.497754491 0.449
3 Sin x 0.499869147 2.62 x 10-2
4 cos x 0.500007551 -1.51 x 10-3
5 -sin x 0.500000304 -6.08 x 10-5
6 -cos x 0.499999988 2.44 x 10-6

15
4.1.1 The Remainder for the Taylor Series Expansion
• To demonstrate how Taylor series is used to estimate
numerical error, we must understand why  is included in Eq.
(4.8).
• Suppose we truncated the Taylor series expansion after the
zero order term, to yield f(xi+1) ≈ f(xi)
• Graphical depiction of zero order is shown in Fig. 4.2

Figure 4.2 Graphical depiction of a zero-order Taylor series prediction and


16
remainder
f  2 f (3) 3
R0  f ( xi )h  h  h 
2! 3!

R0  f ( xi )h



17
R0
f ' ( ) 
h

Zero order : R0  f ' ( )h (4.10)

f " ( ) 2
First order : R1  h (4.11)
2!

Figure 4.3 Graphical depiction of the derivative mean-value theorem

In this case, the value of  conforms to the x value corresponding


to the second derivative that makes Eq (4.11) exact.
18
4.1.2 Using the Taylor Series to Estimate Truncation Errors

• In the parachutist example, we were interested in


determining v(t).
• v(t) can be expended in a Taylor series as :
v "(ti )
v(ti 1 )  v(ti )  v '(ti )(ti 1  ti )  (ti 1  ti ) 2   Rn (4.12)
2!
• Truncate the series after the first derivative:
v(ti 1 )  v(ti )  v '(ti )(ti 1  ti )  R1 (4.13)

• Eq. (4.13) can be solved for


v(ti 1 )  v(ti ) R1
v' (ti )   (4.14)
ti 1  ti ti 1  ti

First-order Truncation
approximation error 19
• The first part is the same as in Eq. (1.11).
• Second part is the truncation error associated with
approximation of the derivative.
• Using Eq. (4.6) & (4.14) yields
R1 v' ' ( ) R1
 (ti 1  ti ) (4.15) or  O(ti 1  ti ) (4.16)
ti 1  ti 2! ti 1  ti

• Thus, the first part of Eq. (4.14) has a truncation error


of order ti+1 - ti.
• The error of the derivative approximation should be
proportional to the step size.

20
Example 4.3 The effect of nonlinearity and step size on the Taylor
Series Approximation
Problem statement. Figure 4.4 is a plot
of the function f(x)=xm , m = 1,2,3,4
over the range from x = 1 to 2.

Notice that for m=1 the function is


linear, and as m increases, more
curvature or nonlinearity is introduced
into the function.

Employ the first order Taylor series to


approximate this function for various
values of the exponent m and the step
size h. Figure 4.4 Plot of the function f(x) = xm
for m = 1, 2, 3, and 4.

21
Solution 4.3
Equation (E4.3.1) can be approximated by a first-order Taylor series expansion, as
in

𝑓 𝑥𝑖+1 = 𝑓 𝑥𝑖 + 𝑚𝑥𝑖𝑚 −1 ℎ (E4.3.2)

Which has a remainder


𝑓"(𝑥 𝑖 ) 𝑓 (3) (𝑥 𝑖 ) 𝑓 (4) (𝑥 𝑖 )
𝑅1 = ℎ2 + ℎ3 + ℎ4 + ⋯
2! 3! 4!

First, we can examine how the approximation performs as m increases-that is, as


the function becomes more nonlinear.

For m = 1, the actual value of the function at x = 2 is 2.

The Taylor series yields

𝑓 2 =1+1 1 =2

and

𝑅1 = 0

The remainder is zero because the second and higher derivates of a linear function
are zero. Thus, as expected, the first-order Taylor series expansion is perfect when
the under lying function is linear.
22
Solution 4.3

For m = 2, the actual value is f(2) =22 =4. The first-order Taylor series
approximation is

f(2) = 1+2(1)=3

and
2
𝑅1 = (1)2 + 0 + 0 + ⋯ = 1
2

Thus, because the function is a parabola, the straight-line approximation results in


a discrepancy. Note that the remainder is determined exactly.

For m = 3, the actual value is f(2) =23 =8. The Taylor series approximation is

f(2) = 1 + 3(1)2 (1) = 4

and
6 6
𝑅1 = (1)2 + (1)3 + 0 + 0 + ⋯ = 4
2 6

Again, there is a discrepancy that can be determined exactly from the Taylor series.

23
Solution 4.3

For m = 4, the actual value is f(2) = 24 =16. The Taylor series approximation is

f(2) = 1 + 4(1)3 (1) = 5

and
12 24 24
𝑅1 = (1)2 + (1)3 + (1)4 + 0 + 0 + ⋯ = 11
2 6 24

On the basis of these four cases, we observe that Ri increases as the function
becomes more nonlinear. Ri accounts exactly for the discrepancy. This is because
Eq. (E4.3.1) is a simple monomial with finite number of derivatives. This permits a
complete determination of the Taylor series remainder.

Next, we will examine Eq. (E4.3.2) for the case m = 4 and observe how Ri changes
as the step size h is varied. For m = 4, Eq. (E4.3.2) is

𝑓 𝑥 + ℎ = 𝑓 𝑥 + 4𝑥𝑖3 ℎ f(xi+1) ≈ f(xi) + f′(xi) (xi+1-xi)


If x =1,f (1) = 1 and this equation can be expressed as

𝑓 1 + ℎ = 1 + 4ℎ

With a remainder of

𝑅1 = 6ℎ2 + 4ℎ3 + ℎ4
24
Solution 4.3

TABLE 4.2 Comparison of the exact value of the function f(x)=x4 with the first-
order Taylor series approximation. Both the function and the
approximation are evaluated at x+h, where x= 1

First-Order
h True R1
Approximation

1 16 5 11
0.5 5.0625 3 2.0625
0.25 2.441406 2 0.441406
0.125 1.601807 1.5 0.101807
0.0625 1.274429 1.25 0.024429
0.03125 1.130982 1.125 0.005982
0.015625 1.063980 1.0625 0.001480

25
From the example 4.3, the following observation can be drawn:
• As h reduces, the discrepancy between true value and approximation
reduces as well.
• At a small value of h, the error becomes proportional to h2 as shown in Fig.
4.5 & Table 4.2.

Figure 4.5
Log-log plot of the Remainder R1 of the first-
order Taylor series approximation of the
function f(x)=x4 versus step size h. A line with a
slope of 2 is also shown to indicate that as h
decreases, the error becomes proportional to h2.

26
• The error of the first order Taylor series approximation
decreases as m approaches 1 and as h decreases.
• Taylor series becomes more accurate when the function we
are approximating becomes more like a straight line over the
interval of interest
• Two possible way can be done that are by reducing the size of
interval or straightening the function by reducing m.
• However, only the first option is possible since the latter
option depends on the problem and not all system can be
modeled as a linear function.

27
Week 4 Exercise 1

The Maclaurin series expansion for sin x is;

x3 x5 x7
sin x  x     
3! 5! 7!
Starting with the simplest version, sin x = 1, add terms one at
a time to estimate sin ( / 3). After each new term is added,
compute the true and approximate percent relative errors.
Use your pocket calculator to determine the true value
(considered 6 decimal point of true value). Add terms until
the absolute value of the approximate error estimate falls
below an error criterion confirming to two significant figures.

28
Week 4 Exercise 2

(a) Approximate the function f ( x)  3 x by a Taylor


polynomial of degree 2 using the base at x = 8.
(b) Use zero-through third order Taylor series expansion
to predict f(3) for

f ( x)  25 x 3  6 x 2  7 x  88

using a base point at x = 1. Compute the true percent


relative error for each approximation.

29
4.1.3 Numerical Differentiation
• Derivative can be approximate numerically using Taylor Series, this is called
Finite divided difference.
f ( xi 1 )  f ( xi )
f '( xi )   O ( xi 1  xi ) (4.17)
xi 1  xi
or
f i
f '( xi )   O (h) (4.18)
h
fi  first forward difference
h  step size Recall the Taylor series:
f ( xi )
f ( xi 1 )  f ( xi )  f ( xi )( xi 1  xi )  ( xi 1  xi ) 2
fi / h  first finite divided difference 2!
• Forward divided difference is one of the many that can be developed from
the Taylor series to approximate derivatives numerically
• More accurate approximation of the first derivative can be developed by
including higher-order terms

30
Backward Difference Approximation of the
First derivative
• Taylor series can be expended backward to calculate a previous value
on the basis of a present value, as in:
f " ( xi ) 2
f ( xi 1 )  f ( xi )  f ' ( xi )h  h  (4.19)
2!

• Truncating this equation after the first derivative and rearrange yields:

f ( xi )  f ( xi 1 ) f1
f ' ( xi )    O ( h) (4.20)
h h
O(h) is the error
f1 is first backward difference Recall the Taylor series:
f 
f ( xi 1 )  f ( xi )  f ( xi )( xi 1  xi )  ( xi 1  xi ) 2
2!

31
Centered Difference Approximation of the First Derivative

• A third way to approximate the first derivative is to subtract


Eq. (4.19) from the forward Taylor series expansion :
f "( xi ) 2
f ( xi 1 )  f ( xi )  f '( xi )h  h  (4.21)
2!
to yield
2 f (3) ( xi ) 3
f ( xi 1 )  f ( xi 1 )  2 f '( xi )h  h 
3!
which can be solved for
f ( xi 1 )  f ( xi 1 )
f '( xi )   O (h 2 ) (4.22)
2h

Centered difference:
• Truncation error is of the order h2
• Thus, centered difference approximation is more accurate

32
Figure 4.6 Graphical depiction of (a) forward (b) backward and (c) centered
finite-divided-difference approximations of the first derivative

33
Example 4.4: Finite-Divided-Difference Approximations of
Derivatives
Problem Statement. Use forward and backward difference approximations of O(h) and a centered
difference approximation of O(h2) to estimate the first derivative of

f(x) = -0.1 x4 – 0.15x3 – 0.5x2 – 0.25x + 1.2

at x = 0.5 using a step size h = 0.5. Repeat the computation using h = 0.25. Note that the derivative can
be calculated direcly as

f’(x) = -0.4 x3 – 0.45 x2 – 1.0 x – 0.25

and can be used to compute the true value as f’(0.5) = -0.9125

Solution. For h = 0.5, the function can be employed to determine

xi-1 = 0 f(xi-1) = 1.2 f ( xi 1 )  f ( xi )


f ' ( xi ) 
xi = 0.5 f(xi) = 0.925 xi 1  xi
xi+1 = 1.0 f(xi+1) = 0.2

These values can be used to compute the forward divided difference [Eq. (4.17)],

0.2−0.925
f’(0.5) ≅ = -1.45 𝜀𝑡 = 58.9%
0.5

34
The backward divided difference [Eq. (4.20)],
f ( xi )  f ( xi 1 )
f’(0.5)≅
0.925−1.2
= -0.55 𝜀𝑡 = 39.7%
f ' ( xi ) 
0.5 h
and the centered divided difference [Eq. (4.22)],
f ( xi 1 )  f ( xi 1 )
f’(0.5)≅
0.2−1.2
= -1.0 𝜀𝑡 = 9.6 %
f ' ( xi ) 
1.0 2h
for h = 0.25,

xi-1 = 0.25 f(xi-1) = 1.10351563

xi = 0.5 f(xi) = 0.925

xi+1 = 0.75 f(xi+1) = 0.63632813

which can be used to compute the forward divided difference,

0.63632813 −0.925
f’(0.5)≅ = -1.155 𝜀𝑡 = 26.5%
0.25

the backward divided difference,

0.925−1.10351563
f’(0.5)≅ = -0.714 𝜀𝑡 = 21.7% Observations:
0.25
-Centered difference more accurate
and the centered divided difference, -Halving the step size approximately
halves the errors of the backward and
0.63632813 −1.10351563 forward and quarters the centered
f’(0.5)≅ = -0.934 𝜀𝑡 = 2.4%
0.5

35
Finite Difference Approximations of Higher Derivatives
Finite Difference Approximation of Higher Derivatives. Besides first derivatives, the Taylor series
expansion can be used to derive numerical estimates of higher derivatives. To do this, we write a
forward Taylor series expansion for f(xi+2) in terms of f(xi):

𝑓 ′′ (𝑥 𝑖 )
f (xi + 2) = f(xi) + f ’(xi)(2h) + 2ℎ2 + . . . (4.23)
2!
4.21
Equation (4.2.1) can be multiplied by 2 and subtracted from Eq. (4.23) to give

f (xi+2) – 2f(xi+1) = -f(xi) + f ’’(xi)h2 + . . .

which can be solve for

𝑓 𝑥 𝑖+2 − 2𝑓 𝑥 𝑖+1 + 𝑓 𝑥 𝑖 (4.24)


f ’’(xi) = +O ℎ
ℎ2

36
This relationship is called the second forward finite divided difference. Similar manipulations can be
employed to derive a backward version

𝑓 𝑥 𝑖 − 2𝑓 𝑥 𝑖−1 + 𝑓 𝑥 𝑖−2
f ’’(xi) = +O ℎ
ℎ2

and a centered version

𝑓 𝑥 𝑖+1 − 2𝑓 𝑥 𝑖 + 𝑓 𝑥 𝑖−1
f ’’(xi) = + O ℎ2
ℎ2

As was the case with the first-derivative approximations, the centered case is more accurate. Notice also
that the centered version can be alternatively expressed as

𝑓 𝑥 𝑖+1 −𝑓 𝑥 𝑖 𝑓 𝑥 𝑖 −𝑓 𝑥 𝑖−1

ℎ ℎ
f ’’(xi)≅

37
4.2 Error Propagation
To study how errors in number can propagate through mathematical functions.
Example: what is estimation error if we multiple two numbers that has an error ?

4.2.1 Function of a single Variable

• Suppose that we have a function f(x) that is dependent on a single


independent variable x.~ x is an approximation of x and we would like to
~
estimate the effect of discrepancy between x and x on the value of the
function: f ( ~x )  f ( x)  f ( ~
x)
• The problem of evaluating f ( x) is that f(x) is unknown because x is
unknown.
• To overcome this difficulty, if~ x is close to x and f (x~) is continuous and
differentiable, a Taylor series can be employed as:
f ( ~
x)
f ( x)  f ( x )  f ( x )( x  x ) 
~ ~ ~ (x  ~
x ) 2  ...
2
dropping the second and higher order terms
x )  f ( ~
f ( x)  f ( ~ x )( x  ~ x )  f ( ~
x ) or f ( ~ x ) ~
x (4.25)

Estimate error of the function Estimate error x

38
Figure 4.7 Graphical depiction of first –order error propagation

39
Example 4.5

Error Propagation in a Function of a Single Variable

Problem Statement. Given a value of with an error


estimate the resulting error in the function,

Solution. Using Eq. (4.25),

Because f(2.5) = 15.625, we predict that

f(2.5) = 15.625±0.1875

or that the true value lies between 15.4375 and 15.8125. In fact, if x were actually
2.49, the function could be evaluated as 15.4382, and if x were 2.51, it would be
15.8132. For this case, the first-order error analysis provides a fairly close estimate
of the true error.

40
4.2.2 Function of more than one Variable
For a function of two independent variable u and v, Taylor series can be
written as:
𝜕𝑓 𝜕𝑓
𝑓 𝑢𝑖+1 𝑣𝑖+1 = 𝑓 𝑢𝑖 , 𝑣𝑖 + 𝑣𝑖+1 − 𝑢𝑖 + 𝑣𝑖+1 − 𝑣𝑖
𝜕𝑢 𝜕𝑣

1 𝜕2𝑓 𝜕2𝑓 𝜕2𝑓


+ 𝑢𝑖+1 − 𝑢𝑖 2 + 2 𝑢𝑖+1 − 𝑢𝑖 𝑣𝑖+1 − 𝑣𝑖 + 𝑣𝑖+1 − 𝑣𝑖 2
+… (4.26)
2! 𝜕𝑢 2 𝜕𝑢𝜕𝑣 𝜕𝑣 2

Where all partial derivatives are evaluated at the base point i. If all second order
and higher terms are dropped, (4.26) can be solved for

Where ∆𝑢 and ∆𝑣 = estimates of the error in u and v, respectively.

For n independent variables 𝑥1 , 𝑥2 , … , 𝑥𝑛 having errors

∆𝑥1 , ∆ 𝑥2 , … , ∆𝑥𝑛 , the following general relationship holds:

f ∆𝑥~ +
∆𝑓 f ∆𝑥~ + ⋯ +
𝜕𝑓 f ∆𝑥
𝜕𝑓 (4.27)
f ( ~
∆𝑓(𝑥 x11,,𝑥~ ,...,. , 𝑥~
x22, … x𝑛n )≅ 𝜕𝑥 x11  x22  ...  ~
xn𝑛
x1
1 𝜕x2
2
𝜕𝑥
xn
𝑛

41
Example 4.6

Problem Statement. The deflection y of the top of a sailboat mast is

𝐹𝐿4
𝑦=
8𝐸𝐼
Where F = a uniform side loading (lb/ft), L = height (ft), E = the modulus of
elasticity (lb/ft2), and I = the moment of inertia (ft4). Estimate the error in y given
the following data:

𝐹 = 50lb/ft ∆𝐹 = 2lb/ft

𝐿 = 30 ft ∆𝐿 = 0.1 ft

𝐸 = 1.5 x 108 lb/ft2 ∆𝐸 = 0.01 x 108 lb/ft2

𝐼 = 0.06 ft4 𝐼 = 0.0006 ft4

42
Solution. Employing Eq. (4.27) gives
𝜕𝑦 𝜕𝑦 𝜕𝑦 𝜕𝑦
∆𝑦 𝐹 , 𝐿, 𝐸 , 𝐼 = ∆𝐹 + ∆𝐿 + ∆𝐸 + ∆𝐼
𝜕𝐹 𝜕𝐿 𝜕𝐸 𝜕𝐼
Or

𝐿4 𝐹 𝐿3 𝐹 𝐿4 𝐹 𝐿4
∆𝑦 𝐹 , 𝐿, 𝐸 , 𝐼 = ∆𝐹 + ∆𝐿 + ∆𝐸 + ∆𝐼
8𝐸 𝐼 2𝐸 𝐼 8𝐸 2 𝐼 8𝐸 𝐼 2

Substituting the appropriate values gives

∆𝑦 = 0.0225 + 0.0075 + 0.0035 + 0.005625 = 0.039375

Therefore, y = 0.5625 ± 0.039375. In the other word, y is between 0.523125 and 0.601875 ft.
The validity of these estimates can be verified by substituting the extreme values for variables
into the equation to generate an exact minimum of

48(29.9)4
𝑦𝑚𝑖𝑛 = = 0.52407
8 1.51𝑥108 0.0606

And

52(30.1)4
𝑦𝑚𝑎𝑥 = = 0.60285
8 1.49𝑥108 0.0594

Thus, the first-order estimates are reasonably close to the exact values.

43
TABLE 4.3 Estimated error bounds associated with common mathematical
operations using inexact numbers .

Operation Estimated Error

Addition
Subtraction
Multiplication

Division

44
4.2.3 Stability and Condition
The condition of a mathematical problem relates to its sensitivity to changes in its
input values. We say that a computation is numerically unstable if the uncertainty
of the input values is grossly magnified by the numerical method.

These ideas can be studied using a first-order Taylor series

This relationship can be employed to estimate the relative error of f(x) as in

The relative error of x is given by

A condition number can be defined as the ration of these relative errors


~
x f ' (~
x)
Condition number  (4.28)
f (~ x)

A condition number provides a measure of the extern to which an


uncertainty in x is magnified by f(x).
1 – function’s relative error identical to the relative error in x.
>1 – relative error is amplified
<1 – relative error is attenuated
45
Example 4.7
Problem Statement. Compute and interpret the condition number for

Solution. The condition number is computed as

Thus, the function is ill-conditioned. , the situation is even


worse:

For this case, the major cause of ill conditioning appears to be derivative. This makes
sense because in the vicinity of , the tangent approaches both positive and negative
infinity.

46
4.3 Total Numerical Error
• Total numerical error = truncation error + round-off error
• Round-off error will increase due to subtractive
cancellation or due to increase in the number of
computation.
• To minimize round-off error is by increasing the
significant figure of computer.
• To reduce truncation error is by reducing the step size.
• However, by decreasing the step size, the round-off error
increases due to the subtractive cancellation and
increase in computation.
• The strategy is to find appropriate step size as shown in
Figure 4.8
47
Figure 4.8 A graphical depiction of the trade-off between round-off
and truncation error that sometimes comes into play in the course
of a numerical method. The point of diminishing returns is shown
where round-off error begins to negate the benefits of step-size
reduction.

48
Try to solve this problems

49

You might also like