Download presentation

Presentation is loading. Please wait.

Published byAdrian Beasley Modified over 6 years ago

1
CSE 330: Numerical Methods

2
What is true error? True error is the difference between the true value (also called the exact value) and the approximate value. True Error = True value – Approximate value Example 1 The derivative of a function at a particular value of can be approximately calculated by For and h=0.3, find at x=2 a) the approximate value of f’(x) b) the true value of f’(x) c) the true error 2

3
True error for the example The approximate value is obtained from the previous equation as 10.265 The true value can be obtainted from the derivative of the function The true value from the above equation is 9.514 True error = True value – Approximate value = -0.7506 3

4
Magnitude of the true error The magnitude of true error does not show how bad the error is. A true error -0.75061 may seem to be small, but if the function given in the Example 1 were the true error in calculating f’(2) with h=0.3 would be - 0.75061X10 -6 This value of true error is smaller, even when the two problems are similar in that they use the same value of the function argument, x=2 and the step size, h=0.3 This brings us to the definition of relative true error. 4

5
Relative True Error Relative true error is denoted by and is defined as the ratio between the true error and the true value. True Error Relative True Error, = -------- True value In both the case, the relative true error is 0.758895% 5

6
What is approximate error? True errors can be calculated only if true values are known. For example when one is checking if a program is correct and knows some cases where the true value is known But mostly we will not have the luxury of knowing true values So when we are solving a problem numerically, we only have access to approximate values We need to know how to quantify error for such cases 6

7
Definition of Approximate Error Approximate error is defined as the difference between the present approximation and previous approximation. Approximate Error= Present Approximation – Previous Approximation Relative approximate error is defined as the ratio between the approximate error and the present approximation In the previous exmple if we find the value of the derivative of the function at h=0.3 and h=0.15, the values 10.265 and 9.8799 respectively So the relative approximate error in percentage is -3.8942% 7

8
Use relative approximate errors to minimize the error In a numerical method that uses iterative process, a user can calculate relative approximate error at the end of each iteration The user may pre-specify a minimum acceptable tolerance called the pre-specified tolerance If the absolute relative approximate error is less than or equal to the pre-specified tolerance, then the acceptable error has been reached and no more iterations would be required 8

9
Introduction to finding Roots Mathematically models for a wide variety of problems in science and engineering can be formulated into equations of the form f(x)=0 where x and f(x) may be real, complex or vector quantities. The solution process often involves finding the values of x that would satisfy the equation These values are called the roots of the equation 9

10
Polynomial Equations Polynomial equations are a simple class of algebric equations that are represented as follows: This is called nth degree polynomial and has n numbers of roots. The roots may be real and different real and repeated complex numbers 10

11
Polynomial equations (continued) Since complex roots appear in pairs, if n is odd, then the polynomial has at least one real root. For example, a cubic equation of the type will have at least one real root and the remaining two may be real or complex roots. Some specific examples of polynomial equations are: 11

12
Transcendental Equations A non-algebric equation is called transcendantal equation. These include trigonometric, exponential and logarithmic functions Examples of transcendantal equation are: 12

13
Iterative Methods An iterative technique usually begins with an approximate value of the root, known as the initial guess, which is then successively corrected iteration by iteration under a certain mathematical basis The process of iteration stops when the desired level of accuracy is obtained Since in many cases, the iterative method needs a large number of iterations and arithmatic opeartion to reach a solution, the use of computers has become inevitable 13

14
Iterative Methods (continued) Iterative methods, based on the number of guesses they use, can be categorized into two categories: Bracketing methods (Interpolation methods) Open end methods (Extrapolation methods) Bracketing methods starts with two initial guesses that ‘bracket’ the root and then systematically reduce the width of the bracket until the solution is reached Two popular methods under Bracketing category are Bisection method False position method These methods are based on the assumption that the function changes sign in the vicinity of a root 14

15
Iterative Methods (continued) Open end methods use a single starting value or two values that do not necessarily bracket the root The following iterative methods fall under this category: Newton-Raphson method Secant method Muller’s method Fixed-point method Bairstow’s method 15

16
Starting an iterative process Before an iterative process is initiated, we have to determine either an approximate value of root or a ‘search’ interval that contains a root One simple method is to plot the function Graphical representation will not only provide us rough estimate of the root but also help us in understanding the properties of the function Largest possible root For a polynomial represented by the largest possible root is given by 16

17
Starting an iterative process Search Bracket Another relationship that might be useful for determining the search intervals that contain the real roots of a polynomial is where x is the root of the polynomial. This will be the maximum absolute value of the roots That means that no roots exceed x max in absolute magnitude and thus, all real roots lie within the interval (-|x * max |,|x * max |) 17

18
Starting an iterative process (continued) There is another relationship that suggests an interval for roots. All roots x satisfy the inequality where the ‘max’ denotes the maximum of the absolute values of |a 0 |, |a 1 |, |a 2 |,...... |a n-2 |, |a n-1 | 18

19
Example #1 Consider the polynomial equation Estimate the possible initial guess value The largest possible root is That is, no root can be larger than the value 4 All roots must satisfy the relation Therefore, all real roots lie in the interval. We can use these two points as initial guesses for the bracketing methods and one of them for the open end methods 19

20
Iteration Stopping Criterion We must have an objective criterion for deciding when to stop the process We may use one of the following tests < E a (absolute error in x) 0 < E (value of function at root) There may be the situations where these tests may fail In cases where we do not know whether the process converges or not, we must have a limit on the number of iterations, like Iterations > N (limit on iterations) 20

21
Bisection Method One of the first numerical methods developed to find the root of a nonlinear equation f(x)=0 was the bisection method (also called binary-search method). The method is based on the following theorem. Theorem An equation, where f(x) is a real continuous function, has at least one root between x l and x u and if f(x l )f(x u )<0 21 f (x) xℓxℓ xuxu x

22
Bisection method (continued) Since the method is based on finding the root between two points, the method falls under the category of bracketing methods. Since the root is bracketed between two points, x l and x u one can find the mid-point, x m between x l and x u. This gives us two new intervals x l and x m and x m and x u 22

23
There may not be any roots between the two points, if the function does not change sign 23 f (x) xℓxℓ xuxu x xℓxℓ xuxu x

24
If the function does not change sign between the two points, roots of the equation may still exist 24 f (x) xℓxℓ xuxu x

25
xℓxℓ xuxu x More than one root may exist between the two points if the function changes sign between the two points 25

26
Decision making process Is the root now between x l and x m or between x m and x u ? Well, one can find the sign of, and if then the new bracket is between x l and x m otherwise, it is between x m and x u. So, you can see that you are literally halving the interval. As one repeats this process, the width of the interval [x l, x u ] becomes smaller and smaller, and you can reach to the root of the equation f(x)=0. 26

27
Complete Algorithm for the Bisection Method Step #1: Choose x l and x u as two guesses for the root such that in other words, f(x) changes sign between x l and x u. Step #2: Estimate the root, x m of the equation as the mid-point between x l and x u as, Step #3: Now check the following If then the root lies between x l and x m then x l = x l and x u = x m. If then the root lies between x m and x u then x l = x m and x u = x u. If then the root is x m and stop the iteration. 27

28
Complete Algorithm for the Bisection Method (continued) Step #4: Find the new estimate of the root Step #5: Find the absolute relative approximate error as where, = estimated root from present iteration = estimated root from previous iteration 28

29
Complete Algorithm for the Bisection Method (continued) Step #6: Compare the absolute relative approximate error with the pre-specified relative error tolerance. Step #7: If then go to Step 3, else stop the algorithm. Note: one should also check whether the number of iterations is more than the maximum number of iterations allowed. If so, one needs to terminate the algorithm and notify the user about it. 29

30
An Exercise A ceramic company that makes floats for commodes. The floating ball has a specific gravity of 0.6 and has a radius of 5.5 cm. You are asked to find the depth x to which the ball is submerged when floating in water. The equation that gives the depth to which the ball is submerged under water is given by Use the bisection method of finding roots of equations to find the depth to which the ball is submerged under water. Conduct three iterations to estimate the root of the above equation. Find the absolute relative approximate error at the end of each iteration. 30

31
Boundary of the Solution From the physics of the problem, the ball would be submerged between x= 0 and x=2R where, R = radius of the ball that is, 0< x < 2R or 0< x < 0.11 31

32
Test for the boundaries of the root Lets us assume, Check if the function changes sign between x l and x u. Hence, So there is at least one root between x l and x u that is between 0 and 0.11. 32

33
Iteration 1 The estimate of the root is x m =(0+0.11)/2=0.055 Hence the root is bracketed between x m and x u that is between 0.055 and 0.11. So, the lower and upper limit of the new bracket is x l = 0.055 and x u = 0.11 At this point, the absolute relative approximate error cannot be calculated as we do not have a previous approximation 33

34
Iteration 2 Next estimate of the root is, =0.082 Hence, the root is bracketed between x m and x u that is, between 0.055 and 0.0825. So, the lower and upper limit of the new bracket is x l =0.055 and x u =0.0825 34

35
Iteration 2 (continued) The absolute relative approximate error at the end of Iteration 2 is =33.33% Let us assume that acceptable error is less than 5%. But because the absolute relative approximate error after 1 st iteration is greater than 5%, so the error is not acceptable. 35

36
Iteration 3 x m =0.06875 Hence, the root is bracketed between and, that is, between 0.055 and 0.06875. So the lower and upper limit of the new bracket is x l = 0.055 and x u = 0.06875 The absolute relative approximate error at the ends of Iteration 3 is 20% Still the absolute relative approximate error is greater than 5% 36

37
Convergence after ten iterations Table 1 Root of as function of number of iterations for bisection method. 37 Iterationsxlxl xuxu xmxm % error f(x m ) 10.000000.110.055---------- 6.655X10 -5 20.0550.110.082533.33 -1.622X10 -4 30.0550.08250.0687520.00 -5.5.63X10 -5 40.0550.068750.0618811.11 4.484X10 -6 50.061880.068750.065315.263 -2.593X10 -5 60.061880.065310.063592.702 -1.080X10 -5 70.061880.063590.062731.370 -3.176X10 -6 80.061880.062730.06230.6897 6.497X10 -7 90.06230.062730.062520.3436 -1.265X10 -6 100.06230.062520.062410.1721 -3.077X10 -7

38
Advantages of bisection method Since the method brackets the root, the method is guaranteed to converge. As iterations are conducted, the interval gets halved. So one can guarantee the error in the solution of the equation. 38

39
Drawbacks of bisection method The convergence of the bisection method is slow as it is simply based on halving the interval. If one of the initial guesses is closer to the root, it will take larger number of iterations to reach the root. If a function is such that it just touches the x-axis (Figure 6) such as it will be unable to find the lower guess, x l, and upper guess, x u, such that (why is that?) 39

40
Figure 6 : The equation has a single root that cannot be bracketed 40 f (x)f (x) x

41
Drawbacks of bisection method A singularity in a function is defined as a point where the function becomes infinite. For functions where there is a singularity and it reverses sign at the singularity, the bisection method may not converge on the singularity (Figure 7). An example includes where x l =-2 and x u =3 are valid initial guesses which satisfy However, the function is not continuous and the theorem that a root exists is also not applicable. 41

42
Figure 7 : The equation has no root but changes sign 42 f (x) x

43
Flow Chart of Bisection Method 43 Read x l and x u Define the function f(x l )f(x u ) : 0 x u = x m Find x m =(x l +x u )/2 A Read E limit & max_iteration f(x l )f(x m ):0 E a = |(x m -x mold )*100/x m | x l = x m E a : E limit Iteration_count : max_iteration Iteration_count++ Print Count, x m & f(x m ) No convergence Start < > < > > < < > Stop iteration_count=0 x mold = x l X mold= x m =

44
#Thanks 44

Similar presentations

© 2022 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google