Documente Academic
Documente Profesional
Documente Cultură
Plan
Youssef Belhamadia
Chapter 1 : Roundo and Truncation Errors Introduction Errors Truncation Errors Roundo Errors
7 janvier 2014
p. 1
c Youssef Belhamadia
p. 2
c Youssef Belhamadia
Introduction
Introduction
Plan
Comments
Chapter 1 : Roundo and Truncation Errors Introduction Errors Truncation Errors Roundo Errors
p. 3
c Youssef Belhamadia
p. 4
c Youssef Belhamadia
Introduction
Introduction
Introduction
What are numerical methods and why should you study them ?
Example 1 The roots of the quadratic formula ax 2 + bx + c = 0 are : b b2 4ac b + b2 4ac and x2 = . x1 = 2a 2a 2 1. Consider x 3x + 2 = 0 and try to nd x1 : a) First method : b + b2 4ac = 2. x1 = 2a b) Second method : b + b2 4ac b b2 4ac x1 = 2a b b2 4ac x1 = b 2c = 2. b2 4ac
Comments
p. 6
c Youssef Belhamadia
Introduction
Introduction
Introduction
What are numerical methods and why should you study them ? Example 1 Consider x 2 + 62.10x + 1 = 0, try to nd x1 using four digit rounding :
1
Comments
2.000 2c = 0.016 = 60.10 62.06 b b2 4ac The exact roots are x1 = 0.01610723 and x2 = 62.08390. x1 =
p. 7 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295 p. 8 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
First method : b + b2 4ac 62.10 + 62.06 x1 = = = 0.020 2a 2.000 . Second method : b b2 4ac b + b2 4ac x1 = 2a b b2 4ac
Introduction
Introduction
Introduction
Example 2 Evaluate f (x ) = x 3 6.1x 2 + 3.2x + 1.5 at x = 4.71 using three digit (rounding).
1
Comments
First method : f (4.71) = (4.71)3 6.1(4.71)2 + 3.2(4.71) + 1.5 f (4.71) = 105. 135. + 15.1 + 1.5 = 13.4
Second method : f (x ) = x 3 6.1x 2 + 3.2x + 1.5 = ((x 6.1)x + 3.2)x + 1.5 f (4.71) = 14.2
The exact value is -14.263899. Question : How many additions and multiplications are in the above two methods ?
p. 9 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295 p. 10 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
Introduction
Introduction
Introduction
Example 3
1
1
Comments
e (x ) dx ? e (x ) dx ?
2
The second integral exists but has a value that cannot be expressed in a simple form. Using numerical method we may obtain the following two values
1 0
e (x ) dx = 0.746809163 or
0
e (x ) dx = 0.746824133,
Introduction
Introduction
Introduction
Comments
What are numerical methods and why should you study them ?
1
Numerical methods are capable to solve (or provide an answer) nonlinearities, large systems of equations, and complicated geometries that are common in engineering and science and that are impossible to solve analytically. Numerical methods are an ecient tools for learning to use computers.
p. 13
c Youssef Belhamadia
p. 14
c Youssef Belhamadia
Errors
Errors
Plan
Comments
Chapter 1 : Roundo and Truncation Errors Introduction Errors Truncation Errors Roundo Errors
p. 15
c Youssef Belhamadia
p. 16
c Youssef Belhamadia
Errors
Errors
Introduction
Comments
Mathematical approximation and digital computers cause uncertain results. Engineers need constantly to accomplish objectives and make decision based on uncertain results. Is it possible to understand, quantify and control such errors in order to obtain acceptable results ?
p. 17
c Youssef Belhamadia
p. 18
c Youssef Belhamadia
Errors
Errors
Comments
Accuracy refers to how closely a computed or measured value agrees with the true or actual value. Precision refers to how closely a series of values agree or consistent with each other.
a) inaccurate and imprecise b) accurate and imprecise c) inaccurate and precise d) accurate and precise See gure 4.1 page 90 in the textbook.
p. 19
c Youssef Belhamadia
p. 20
c Youssef Belhamadia
Errors
Errors
Error Denitions
Denition
Consider u as the true value and v is as an approximation to u
1
Comments
True error, Et , is the dierence between the true value and the approximation. True error = Et = u v Absolute error, |Et |, is the absolute dierence between the true value and the approximation. Absolute error = |Et | = |u v |
uv u
t,
is
t
uv 100% u
p. 22 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
E and
c Youssef Belhamadia
Errors
Errors
Error Denitions
Example Consider the true value of a bridge as u = 10000cm and the approximate value is v = 9999cm . Consider the true value of a rivet as = 10cm and the approximate value is v = 9cm . For both the true error is Et = 1cm . However, when look at their percent relative errors :
Bridge :
t
Comments
= =
Rivet
t
Errors
Errors
Error Denitions
Denition
In numerical methods and real-world applications, the true answer is rarely known. In this situation an alternative error is used
1
Comments
Approximate percent relative error u v 100%, a = u where u is the present approximation and v is the previous approximation.
When performing computations, the computation is repeated until stopping criterion is satised | a| < s, where
s
is a prespecied tolerance.
We can be assured that the result is correct to at least n signicant gures, if 2n % s = 0.5 10
c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295 p. 26 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
p. 25
Errors
Errors
Error Denitions
Example
Estimate e 0.5 to three signicant gures
1 2
Comments
x2 xn + + + 2! n!
3 4
5 6
p. 27
Errors
Errors
Error Denitions
Example n 0 1 2 3 4 5 Approximation of e 0.3 e 0 .5 | t| | a| = 1 39.3 1.5 9.02 33.3 1.625 1.44 7.69 1.645833333 0.175 1.27 1.648437500 0.0172 0.158 1.648697917 0.00142 0.0158
s
Comments
After six terms, the approximate error falls below the computation is terminated. The exact value is e 0.5 = 1.648721
p. 29 c Youssef Belhamadia
= 0.05%, and
p. 30
c Youssef Belhamadia
Errors
Errors
Errors
Comments
Roundo error (due to computer approximations). Truncation error (due to mathematical approximations).
The Taylor series is a very good example to express the idea of truncation error mathematically.
p. 31
c Youssef Belhamadia
p. 32
c Youssef Belhamadia
Truncation Errors
Truncation Errors
Plan
Comments
Chapter 1 : Roundo and Truncation Errors Introduction Errors Truncation Errors Roundo Errors
p. 33
c Youssef Belhamadia
p. 34
c Youssef Belhamadia
Truncation Errors
Truncation Errors
Tylor Series
Taylor Theorem The Taylor theorem states that any smooth function can be approximated as a polynomial. f (n ) (xi ) n f (xi ) 2 f (3) (xi ) 3 h + h + + h + 2! 3! n! f (n ) (xi ) n f (xi ) 2 f (3) (xi ) 3 h + h + + h + Rn 2! 3! n! f n +1 ( ) n +1 h , (n + 1)!
Comments
Rn =
h = xi +1 xi , the subscript n denotes it is the remainder for the n th-order approximation and is a value of x between xi and xi +1 .
p. 35 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295 p. 36 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
Truncation Errors
Truncation Errors
Tylor Series
Comments
p. 37
c Youssef Belhamadia
p. 38
c Youssef Belhamadia
Truncation Errors
Truncation Errors
Tylor Series
1
Comments
In general, the n -th order Taylor series expansion will be exact for an n -th order polynomial. In other cases, it is usually necessary to truncate the series because it is not possible to carry out an innite number of additions. The remainder term Rn is of the order of h n +1 : R n = O (h n + 1 )
1 2
The more terms are used, the smaller the error. For a given number of terms, the smaller the spacing, h , the smaller the error.
c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295 p. 40 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
p. 39
Truncation Errors
Truncation Errors
Example
Example Use Taylor series expansions with n = 0 to 3 to approximate e 0.3 . Compare the errors Et and Ea and nd the upper bound of Rn . Approximation of e 0.3 Tylor approximation Et Ea 1 0.3498 1.3 0.0498 0.3 1.345 0.0045 0.04 1.3495 0.0003 0.004
Comments
n 0 1 2 3
Truncation Errors
Truncation Errors
Numerical Dierentiation
Finite-dierence approximations of the rst derivative
1
Comments
The rst order Taylor series can be used to calculate approximations to derivatives : Given : f (xi +1 ) = f (xi ) + f (xi )h + O (h 2 ) Then : f (xi ) = f (xi +1 ) f (xi ) + O (h ) h
This forward dierence is one of many examples for approximating the derivatives numerically and that can be developed from the Taylor series. More accurate approximations of the rst derivative can be developed by including higher-order terms of the Taylor series. f (xi +1 ) = f (xi ) + f (xi )h + f (xi ) 2 h + O (h 3 ) 2!
p. 44 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
p. 43
c Youssef Belhamadia
Truncation Errors
Truncation Errors
Comments
f (xi +1 ) f (xi ) + O (h ) h See gure 4.10 page 111 in the textbook. f (xi ) f (xi 1 ) + O (h ) h
f (xi +1 ) f (xi 1 ) + O (h 2 ) 2h
Civil Engineering Analysis II: CIV E 295 p. 46 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
Truncation Errors
Truncation Errors
Example
Example Approximate f (1) with f (x ) = x 3 + x 2 + x .
Approximation of f (1) h=1 Forward Backward Centered 11 3 7.5 5 3 1.5 h = 0.5 Forward Backward Centered 8.25 4.25 6.25 2.25 1.75 0.25 h = 0.25 Forward Backward Centered 7.06 5.06 6.06 1.06 1.06 0.06
Comments
Roundo Errors
Roundo Errors
Plan
Comments
Chapter 1 : Roundo and Truncation Errors Introduction Errors Truncation Errors Roundo Errors
p. 49
c Youssef Belhamadia
p. 50
c Youssef Belhamadia
Roundo Errors
Roundo Errors
Comments
Digital computers have magnitude and precision limits on their ability to represent numbers. In the decimal system, any number x (other than zero) can be represent in normalized oating-point form as x = 0.d1 d2 d3 dn 10n k-digit decimal machine numbers are of the form : x = 0.d1 d2 d3 dk 10n The oating point representation is binary system is similar to the decimal system.
By default, MATLAB has adopted the IEEE double-precision format in which eight bytes (64 bits) are used to represent oating-point numbers
c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295 p. 52 c Youssef Belhamadia Civil Engineering Analysis II: CIV E 295
p. 51
Roundo Errors
Roundo Errors
Comments
p. 54
c Youssef Belhamadia
Roundo Errors
Roundo Errors
Comments
p. 56
c Youssef Belhamadia
Roundo Errors
Roundo Errors
Comments
First method : x1 = b +
. Second method : x1 = b + x1 =
2c = 0.01610 b2 4ac
Roundo Errors
Roundo Errors
Other Errors
Comments
The total numerical error is the summation of the truncation and roundo errors. Blunders : errors caused by malfunctions of the computer or human imperfection. Model errors : errors resulting from incomplete mathematical models. Data uncertainty : errors resulting from the accuracy and/or precision of the data.
p. 59
c Youssef Belhamadia
p. 60
c Youssef Belhamadia