CHAPTER 2a APPROXIMATION OF ERROR · Significant Figures (SF) •Significant figures /digits are...

Preview:

Citation preview

CHAPTER 2a APPROXIMATION OF

ERROR Presenter: Dr. Zalilah Sharer

© 2018 School of Chemical and Energy Engineering

Universiti Teknologi Malaysia

16 September 2018

• Whenever we employ a number in a computation, we must have assurance that it can be used with confidence.

• Example: Fig. 3.1 (pg 53) shows a speedometer and odometer from an automobile, which indicates the speed between 48 km/h to 49 km/h. At one decimal place, the speed becomes 48.8 km/h or 48.9 km/h. Up to nth estimations, the speed is uncertain.

Significant Figures (SF) • Significant figures /digits are those number can be used

with confidence, which correspond to the number of certain digits plus one estimated digit i.e. the speed has 3 SF i.e. 48.5 km/h.

• Belows are examples of 3 significant figures 0.0123 0.00123 0.000123

• Zeros are not always significant figures because they may necessary to locate a decimal point e.g: 45700

• 3,4 or 5 significant figures depend whether zeros are known with confidence.

• Using scientific notation:

4.57 x 104 - 3 SF

4.570 x104 - 4 SF

4.5700 x 104 - 5 SF

• Generally;

Non zero digit are always significant e.g. 486912 (6SF)

Any zero between two significant numbers are significant e.g. 708 (3SF)

Final zero or trailing zero in a decimal portion only significant e.g. 0.008980 (4SF)

Accuracy and Precision

The concepts of accuracy and precision : a) inaccurate and imprecise b) accurate and imprecise c) inaccurate and precise d) accurate and precise.

(a) (b)

(c) (d)

Error

NM should be sufficiently accurate or unbiased to meet the requirements of a particular engineering problem.

We will use the term error to represent both the inaccuracy & imprecision.

Errors Definition

Numerical error arise from the use of approximation to represent exact

mathematical operations and quantities

Truncation Error - approximation of mathematical procedures

Round-off error - approximation of exact numbers

The relation between exact, or true and the approximate is given as

True value = Approximation + error

True error = true value - approximation

Et = true error = exact value of the error

• One way to account for the magnitudes of the quantities being evaluated is to normalized the error to the true value by true fractional relative error:

• True percent relative error, t :

True Fractional Relative Error = Error/True value

Example 1

Lengths of a bridge and a rivet are 9999 cm and 9 cm respectively. If the true values are 10,000 cm and 10 cm respectively;

Compute: (a) true error and

(b) true percent relative error for each case.

Solution

Error for measuring the bridge :

Et = 10,000 – 9999 = 1 cm

and for the rivet;

Et = 10 – 9 = 1 cm

Percent Relative Error :

bridge:

rivet:

%01.010010,000

1

t

t 1

10100 10%

Approximation of Errors

In actual situation the true value is rarely available Typically the case when we investigate the theoretical behaviour of technique

of simple system approximate error

approximation

The challenge of numerical method is to find the approximation error

Solving this by using iterative approach by using the previous value as basis

present approximation− previous approximation

present approximation

x 100%

The iteration is stop until |εa| < εs (the pre-specified tolerance) Tolerance to at least n significant figures is given as εs = (0.5 X 10 2-n)%

εa =

εa = x 100%

Example 2 Exponential function can be computed using (Maclaurin series expansion) As more terms are added in sequence, approximation values become a better and better estimate of true value of ex. Given, true value e 0.5 = 1.648721 , x = 0.5

• Starting with e x = 1, add term one at a time to estimate e 0.5

• Compute true (t) and approximate percent errors (a) • Add term until a s with s conforming to three significant

figures (n = 3).

2 3

1 .....!2 3!

nx x x xe xn

Solution

1. Compute error criterion that ensures a result is correct to at least 3 SF by using eq 3.7

s = (0.5 x 102-3)% = 0.05%

Add terms to the series until a falls below this level

2. Start compute with e x = 1, then compute t and a

3.39%100

648721.1

1648721.1

100%x valuetrue

error true 3.3, eq. From

t

3. Then estimate & adding 2nd term;

ex = 1 + x and for x = 0.5,

e0.5 = 1 + 0.5 = 1.5

and so on continues until:

a s then stop computing

t 1.6487211.5

1.648721

100 9.02%

a 1.51

1.5

100 33.3%

• Table below shows the entire results:

Terms Result t(%/) a(%)

1 1 39.3 -

2 1.5 9.02 33.3

3 1.625 1.44 7.69

6 1.648697917 0.00142 0.0158

• Thus, after 6 terms are included, the approximate error (a%) falls below s = 0.05%, and the computation is terminated.

• Computer retain only a fixed number of significant figures during a

calculation. Number such as and e cannot be expressed by a fixed number

of significant figures.

• Therefore, they cannot be represented exactly by the computer.

• Two major forms of numerical error:

1. Round-off error

– Due to computers can represent only quantities with a finite number

of digits, so numbers cannot be represented exactly, e.g: =

3.1415926535……..

3.142 (4 SF)

– The omission/deleting of the remaining significant figures called

Round-off error

Two major forms of numerical error

Two major forms of numerical error

2) Truncation error

– Result from using numerical methods (approximation) to represent an exact mathematical procedure.

– An example: In the introduction, we have derived velocity of a falling parachutist by a finite-divided-difference equation:

• Truncation error was introduced into NM because the difference equation only approximates the true value.

• Mathematical formulation that is used widely in NM to express functions in an approximate fashion is the Taylor Series.

Represent by finite-divided difference equation (numerical approach:

Note: Mathematical formulation that used widely in numerical method to express functions in an approximate fashion TAYLOR SERIES

dv

dtv

t

v(ti1) v(ti)

ti1 ti

Summary

t a

The true percent relative error Approximation percent relative error

To account for the magnitudes of the quantities being evaluated is to normalize the error to the true value.

To normalize the error using the best available estimate of the true value.

Example :

Certain numerical method use an iterative approach to computes answers.

For such a cases, the error is often estimated as the difference between previous and current approximation.

CHAPTER 2b TAYLORS SERIES

Presenter: Dr. Zalilah Sharer

© 2018 School of Chemical and Energy Engineering

Universiti Teknologi Malaysia

16 September 2018

Truncation Errors and Taylor Series

• 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.

• 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.

• Any smooth function can be approximated as a polynomial.

• Taylor series can be built term by term.

• The first term in the series is called zero–order approximation

The value of f at the new point value of f at the old point

=> Perfect estimation if the function is constant

• In this case xi and xi+1 are close to each other, where the new value is similar to the old value.

• When the function changes at all over the interval, use first order approximation

“Developed by adding term of a slope f’(xi) multiplied by the distance between xi and xi+1 into the zero-order approximation”

• The expression is in the form of a straight line/linear trend & capable of predicting an increase or decrease of the function between xi and xi+1 .

• -term is added to capture some of the curvature that the function might exhibit

'

1 1( ) ( ) ( )( )i i i i if x f x f x x x

1( ) ( )i if x f x

• For the curvature function, second-order approximation is used.

“Second-order term is added to the series to capture some of the curvature (curve)”.

• Complete Taylor series expansion

' 2

1 1 1

"( )( ) ( ) ( )( ) ( )

2!

ii i i i i i i

f xf x f x f x x x x x

' 2

1 1 1

33

1 1

"( )( ) ( ) ( )( ) ( )

2!

( ) ( )( ) ..... ( )

3! !

ii i i i i i i

nni i

i i i i n

f xf x f x f x x x x x

f x f xx x x x R

n

• An equal sign (=) replaces the approximate sign () because a

complete Taylor series is an infinite series,

• The remainder term, Rn, is

where, n = nth-order approximation

= value of x lies between xi and xi+1

• Taylor series are simplify by defining a step size, h = xi+1 – xi :

where,

( 1)1

1

( )( )

( 1)!

nn

n i i

fR x x

n

n

ni

n

ii

iii

Rhn

xf

hxf

hxf

hxfxfxf

!

)(

............!3

)(

!2

)( )()()(

)(

3

3

2

1

1

)1(

)!1(

)(

n

n

nh

n

fR

Example 3

Use zero through fourth order Taylor series expansions to approximate the function:

from xi = 0 with h = 1. Predict the function’s value at xi+1.

Guideline:

1) xi+1=?

2) True value?

3) 0 order to 4th order

4 3 2( ) 0.1 0.15 0.5 0.25 1.2f x x x x x

Solution • Because we are dealing with a known function, we can

compute values for f(x) between 0 and 1.

• The results (Fig.3.1) indicate that the function starts at f(0) = 1.2 and then curved downward to f(1) = 0.2.

• Thus, the true value that we are trying to predict is 0.2.

2.1)0(

2.1)0(25.0)0(5.0)0(15.0)0(1.0)0( 234

f

f

2.0)1(

2.1)1(25.0)1(5.0)1(15.0)1(1.0)1( 234

f

f

Fig 3.1

(a) Taylor series; n = 0 (zero-order),

f (xi+1) f (xi)

• Thus, f(x i+1) 1.2

• As shown in Fig.3.1, zero-order approximation is a constant, thus the truncation error is ;

Et = true value - approximation

= 0.2 – 1.2 = -1.0

(b) Taylor series; n = 1 (first-order),

• Thus, the first derivative must be determined & evaluated at x = 0;

f ’ (0) = -0.4(0.0)3 – 0.45(0.0)2 – 1.0(0.0) – 0.25

= -0.25

f (xi1) f (xi) f (xi)(xi1 xi)

• Therefore, the first-order approximation,

f (xi+1) 1.2 – 0.25h

f (1) = 0.95

• The approximation value begin to downward trajectory of the function in the form of a sloping straight line (Fig. 3.1).

• This results in a reduction of the Et to;

Et = 0.2 – 0.95 = -0.75

• (c) Taylor series; n = 2 (second-order),

• Thus, the second derivative must be determined & evaluated at x = 0; f’’ = -1.2(0.0)2 – 0.9(0.0) – 1.0 = -1.0

f (xi1) f (xi) f (xi)(xi1 xi)f (xi)

2!(xi1 xi)

2

• Therefore, the second-order approximation;

f (xi+1) 1.2 – 0.25h – 0.5 h2

• Substituting h = 1, thus, f (1) = 0.45

• The second derivative now adds some downward curvature resulting in an improve estimates as shown Fig. 4.1.

• The Et is reduced further to Et = 0.2 – 0.45 = -0.25

• Additional terms would improve the approximation even more. Inclusion of 3rd and 4th derivatives results in exactly the same equation we started with:

f (x) = 1.2 – 0.25h – 0.5h2 – 0.15h3 – 0.1h4

• The remainder term, R4;

because the 5th derivative of the 4th order polynomial = 0.

• The Taylor series expansion to the fourth derivative yields an exact estimate at xi + 1 =1

0!5

)( 5

)5(

4 h

fR

Working together with your Buddy

And Do Quiz 2

Quiz 2

The following infinite series can be used to approximate ex:

Use the Taylor series to estimate f(x) = e-x at xi+1 = 1 for xi = 0.2. Employ the zero-, first-, second- and third order versions and compute the ltl for each case.

!......

!321

3

2

n

xxxxe

n

x

Solution

• For xi = 0.2, xi+1 =1 and h = 0.8.

• True value = e-1 = 0.367879

• Zero order.........3rd order

• True percent relative error:

!......

62)(

32

1n

xhe

heheexf

n

xixixix

i

true errort = 100%

true value

Using Taylor Series to Estimate Truncation Errors

• From Chapter 1 (examples 1 and 2- falling parachutist), we have predicted velocity as a function of time, v(t).

• v(t) can be expanded in a Taylor series

• Truncate above equation after the first order derivative term to give;

• This equation is called a finite divided difference (FDD)

nii

i

iiiiiRtt

tvtttvtvtv

....)(

!2

)("))((')()( 2

111

iiii

ii

itt

R

tt

tvtvtv

1

1

1

1

1

)()()('

First order

approximation Truncation error

Taylor series in numerical differentiation

Forward difference approximation on the first derivative

• Eq 4.14 can be represented generally as;

where,

fi = first forward difference

f /h = first finite divided difference

O(h) = Truncation error

h = step size (length of the interval over which the approximation is made)

f (x i) f (x i1) f (x i)

x i1 x i

O(x i1 x i)

or

f (x i) f i

hO(h)

Forward difference approximation of the first derivative

xi x i+1 x

f(x)

h

The term “forward” difference because it utilizes data at i and i+1 to estimate the derivative

Backward difference approximation of the first derivative

• Taylor series can be expanded backward to calculate a previous value on the basis of a present value,

• Truncating after the first derivative & rearranging yields:

where:

O(h) = the error

fi = first backward

difference

h

f

h

xfxfxf iii

i

)()()( 1

xi x i-1 x

f(x)

h

Centred difference approximation of the first derivative

Rearranging FDD and BWD;

f (xi) f (xi1) f (xi1)

2hO(h2)

xi x i-1 x

f(x)

h

x i+1

h

• Notice that the truncation error is of the order h2, in contrast to the forward & backward approximations that were of the order h.

• In practice the centered difference is more accurate representation of the derivative compared to forward & backward differences.

• Thus, if we halve the step size h using a forward or backward difference, we would approximately halve the truncation error, whereas for the centered difference, the error would be quartered.

Finite difference approximation of higher derivates

• FW

f ’’(xi) = f(xi+2) – 2f(xi+1) + f(xi) + O(h)

h2

• BW

f ’’(xi) = f(xi) – 2f(xi-1) + f(xi-2) + O(h)

h2

Finite difference approximation of higher derivates

• CENTERED

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

h2

Example 4

Use forward and backward difference approximation of O(h) and a centered differences approximation of O(h2) to estimate the first derivative of:

at x=0.5, using a step size h=0.5. Repeat the computation using h= 0.25

4 3 2( ) 0.1 0.15 0.5 0.25 1.2f x x x x x

Solution Guideline to solution: 1) Do 1st derivative/1st differentiate 2) True value

At x = 0.5 using step size h = 0.5

3 2'( ) 0.4 0.45 1.0 0.25f x x x x

Note that the derivative of the equation is:

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

To compute the true values:

f ’(0.5) = -0.9125

Solution

3) for h=0.5 xi-1=? f(xi-1)=? xi+1=? f(xi+1)= xi=? f(xi)= 4) Compute forward divided difference?

1( ) ( )'( ) i i

i

f x f xf x

h

?t

Solution

5) Backward divided difference? 6) Centered divided difference? 7) Continues from step 3 to step 6 for h =0.25

1( ) ( )'( ) i i

i

f x f xf x

h

?t

h

xfxfxf ii

i2

)()()( 11

?t

For h = 0.25:

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

xi = 0.5 f(xi) = 0.925

x i+1 = 0.75 f(x i+1) = 0.63632813

Which can be used to compute the forward divided difference:

f’(0.5) 0.63632813 – 0.925/0.25 = -1.155

t= 26.5%

Backward divided difference:

f’(0.5) 0.925 – 1.10351563/0.25 = -0.714

t= 21.7%

And centered divided difference:

f’(0.5) 0.63632813 - 1.10351563 /0.5 = -0.934

t= 2.4%

Solution

For both step size (h = 0.5 and 0.25), the centered difference approximation is more accurate than forward or backward differences

Work with your buddy and Do Quiz

Quiz 4

Use zero-through third order Taylor expansions to predict f(3) for

f(x) = 25x3 – 6x2 + 7x -88

Using a base point at x = 1. Compute the true percent relative error t ,

for each approximation.

Quiz 5

Used a centred difference approximation of O(h2) to estimate the first derivative of the function examined in Quiz 4.

Perform the evaluation at x=2 using step sizes of h = 0.25 and 0.125. Compare your estimates with the true value of the second derivative. Interpret your results on the basis of the remainder term of the Taylor series expansion.

Example 5

Where J = Flux

dT = Temp. difference

dx = Distance difference

In one experiment data below was obtained:

If J=60 when x=0 what is the value of k?

X, m 0 0.1 0.2

T, °C 20 17 15

Solution • Use forward divided difference

1

0

( ) ( )

17 20

0.1

30(substitute into eq)

60 ( 30)

6020

30

i i

x

f x f xdT

dx h

k

k

Solution Use Forward Difference only if:

Use backward difference only if:

Use forward, backward or centered if

x,m 0 0.1 0.2

xi xi+1 xi+2

T, °C 20 17 15

f(xi) f(xi+1) f (xi+2)

x,m 0 0.1 0.2

Xi-1 xi xi+1

T, °C 20 17 15

f(xi-1) f(xi) f (xi+1)

x,m 0 0.1 0.2

Xi-2 Xi-1 xi

T, °C 20 17 15

f(xi-2) f(xi-1) f (xi)

Question?

THE END

Thank You for the Attention

Recommended