Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 330: Numerical Methods.  True error is the difference between the true value (also called the exact value) and the approximate value.  True Error.

Similar presentations


Presentation on theme: "CSE 330: Numerical Methods.  True error is the difference between the true value (also called the exact value) and the approximate value.  True Error."— Presentation transcript:

1 CSE 330: Numerical Methods

2  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  The approximate value is obtained from the previous equation as  The true value can be obtainted from the derivative of the function  The true value from the above equation is  True error = True value – Approximate value =

4  The magnitude of true error does not show how bad the error is.  A true error 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 X10 -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 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 % 5

6  In the previous section, we discussed how to calculate true errors  Such errors are calculated only if true values are known.  An example where this would be useful is when one is checking if a program is in working order and you know some examples where the true error is known  But mostly we will not have the luxury of knowing true values as why would you want to find the approximate values if you know the true values  So when we are solving a problem numerically, we will only have access to approximate values  We need to know how to quantify error for such cases 6

7  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 and respectively  So the relative approximate error in percentage is % 7

8  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  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 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 number 10

11  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  A non-algebric equation is called transcendantal equation.  These include trigonometric, exponential and logarithmic functions  Examples of transcendantal equation are: 12

13  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 to make the task simple and efficient 13

14  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  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  Before an iterative process is initaited, 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 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  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  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  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  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 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 f (x) xℓxℓ xuxu x 21

22  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 f (x) xℓxℓ xuxu x xℓxℓ xuxu x 23

24 f (x) xℓxℓ xuxu x 24

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

26  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  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  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  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  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  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 <

32  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

33  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 and So, the lower and upper limit of the new bracket is x l = 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  Next estimate of the root is, =0.082  Hence, the root is bracketed between x m and x u that is, between and So, the lower and upper limit of the new bracket is x l =0.055 and x u =

35  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  x m =  Hence, the root is bracketed between and, that is, between and So the lower and upper limit of the new bracket is x l = and x u =  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 Table 1 Root of as function of number of iterations for bisection method. Iterationsxlxl xuxu xmxm % error f(x m ) X X X X X X X X X X

38  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  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 39

40 f (x)f (x) x 40

41  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 f (x) x 42

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 43 iteration_count=0 x mold = x l X mold= x m =

44 Thanks 44


Download ppt "CSE 330: Numerical Methods.  True error is the difference between the true value (also called the exact value) and the approximate value.  True Error."

Similar presentations


Ads by Google