.

Tuesday, June 4, 2019

Rate of convergence and bisection

Rate of touchnce and bisectionRate of convergence estimate of the speed with which a given sequence or looping approaches its limit, often measured by the number of terms or evaluations involved in obtaining a given accuracy. Although strictly speaking, a limit does non give information about any finite first part of the sequence, this concept is of practical importance if we deal with a sequence of successive approximations for an reiterative regularity, as then typically fewer iterations are needed to yield a useful approximation if the rate of convergence is higher. This may even entertain the difference between needing ten or a million iterations.Rate of convergence is measured in terms of rate at which the relative error decreases between successive approximations. There are mainly two type of convergence linear and quadratic.Convergence of a sequence subject to the condition, for p 1, thatas n increases is called pth-order convergence for example, quadratic convergence w hen p = 2. One similarly speaks of logarithmic convergence or exp singlential convergence.The Bisection orderIn mathematics, the bisection rule is a al-Qaida-finding algorithmic program which repeatedly bisects an interval then selects a subinterval in which a locate must lie for further processing. It is a very simple and risque method acting, but it is also relatively slow. The bisection method is simple, robust, and straight-forward take an interval a, b such that f(a) and f(b) have opposite signs, find the midpoint of a, b, and then decide whether the root lies on a, (a + b)/2 or (a + b)/2, b. Repeat until the interval is sufficiently small.The bisection method, suitable for implementation on a computer allows to find the roots of the equation f (x) = 0, based on the following theoremTheorem If f is continuous for x between a and b and if f (a) and f(b) have opposite signs, then there exists at least one real root of f (x) = 0 between a and b.Procedure Suppose that a contin uous lean f is banish at x = a and positive at x = b, so that there is at least one real root between a and b. (As a rule, a and b may be found from a graph of f.) If we calculate f ((a +b)/2), which is the function value at the point of bisection of the interval af ((a + b)/2) = 0, in which case (a + b)/2 is the rootf ((a + b)/2) f ((a + b)/2) 0, in which case the root lies between a and (a + b)/2.Advantages and drawbacks of the bisection methodAdvantages of Bisection mannerThe bisection method is eternally convergent. 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 decrease in the error in the solution of the equation.Drawbacks of Bisection MethodThe convergence of 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 have the root.If a function is such that i t just touches the x-axis (Figure 3.8) such asit will be unable to find the lower guess, , and upper guess, , such thatFor functions where there is a singularity and it reverses sign at the singularity, bisection method may converge on the singularity (Figure 3.9).An example includeand, are valid initial guesses which satisfy.However, the function is not continuous and the theorem that a root exists is also not applicable.Figure.3.8. Function has a single root at that cannot be bracketed.Figure.3.9. Function has no root but changes sign.False position methodThe pretended-position method is a modification on the bisection method. The false position method or regula falsi method is a root-finding algorithm that combines features from the bisection method and the secant method. If it is known that the root lies on a,b, then it is reasonable that we can approximate the function on the interval by interpolating the points (a, f(a)) and (b, f(b)).The method of false position dates back t o the ancient Egyptians. It remains an effective alternative to the bisection method for solving the equation f(x) = 0 for a real root between a and b, given that f (x) is continuous and f (a) and f(b) have opposite signs. The algorithm is suitable for automatic computationProcedureThe curvey = f(x)is not largely a straight line. However, one may join the points (a,f(a)) and (b,f(b)) by the straight lineThus straight line cuts thex-axis at (X, 0) whereso thatSuppose thatf(a)is negative andf(b)is positive. As in the bisection method, there are the three possibilities f(X) = 0, when caseXis therootf(X) f(X)0, when the root lies betweenXanda.Again, in Case1, the process is terminated, in either Case2or Case3, the process can be repeated until the root is obtained to the desired accuracy.Convergence of False Position Method and Bisection MethodSource code for False Position Method caseful code of False-position methodC code was written for clarity instead of efficiency. It was knowing to solve the same business as solved by the Newtons method and secant method code to find the positive number x where cos(x) = x3. This problem is transformed into a root-finding problem of the formf(x) = cos(x) x3 = 0.include include double f(double x)return cos(x) x*x*xdouble FalsiMethod(double s, double t, double e, int m)int n,side=0double r,fr,fs = f(s),ft = f(t)for (n = 1 n r = (fs*t ft*s) / (fs ft)if (fabs(t-s) fr = f(r)if (fr * ft 0)t = r ft = frif (side==-1) fs /= 2side = -1else if (fs * fr 0)s = r fs = frif (side==+1) ft /= 2side = +1elsebreakreturn rint main(void)printf(%0.15fn, FalsiMethod(0, 1, 5E-15, 100))return 0After running this code, the last answer is approximately 0.865474033101614Example 1Consider finding the root of f(x) = x2 3. Let clapperclaw = 0.01, abs = 0.01 and start with the interval 1, 2.Table 1. False-position method applied to f(x)=x2 3.abf(a)f(b)cf(c)Update measuring Size1.02.0-2.001.001.6667-0.2221a = c0.66671.66672.0-0.22211.01.7273-0.0 164a = c0.06061.72732.0-0.01641.01.73170.0012a = c0.0044Thus, with the third iteration, we note that the last step 1.7273 1.7317 is less than 0.01 and f(1.7317) Note that after three iterations of the false-position method, we have an acceptable answer (1.7317 where f(1.7317) = -0.0044) whereas with the bisection method, it took seven iterations to find a (notable less accurate) acceptable answer (1.71344 where f(1.73144) = 0.0082)Example 2Consider finding the root of f(x) = e-x(3.2 sin(x) 0.5 cos(x)) on the interval 3, 4, this time with step = 0.001, abs = 0.001.Table 2. False-position method applied to f(x)= e-x(3.2 sin(x) 0.5 cos(x)).abf(a)f(b)cf(c)UpdateStep Size3.04.00.047127-0.0383723.5513-0.023411b = c0.44873.03.55130.047127-0.0234113.3683-0.0079940b = c0.18303.03.36830.047127-0.00799403.3149-0.0021548b = c0.05343.03.31490.047127-0.00215483.3010-0.00052616b = c0.01393.03.30100.047127-0.000526163.2978-0.00014453b = c0.00323.03.29780.047127-0.000144533.2969-0.000036998b = c0 .0009Thus, after the one-sixth iteration, we note that the final step, 3.2978 3.2969 has a size less than 0.001 and f(3.2969) In this case, the solution we found was not as good as the solution we found using the bisection method (f(3.2963) = 0.000034799) however, we only used six instead of eleven iterations.Source code for Bisection methodincludeincludedefine epsilon 1e-6main()double g1,g2,g,v,v1,v2,dxint found,converged,ifound=0printf( enter the first guessn)scanf(%lf,g1)v1=g1*g1*g1-15printf(value 1 is %lfn,v1)while (found==0)printf(enter the second guessn)scanf(%lf,g2)v2=g2*g2*g2-15printf( value 2 is %lfn,v2)if (v1*v20)found=0elsefound=1printf(right guessn)i=1while (converged==0)printf(n iteration=%dn,i)g=(g1+g2)/2printf(new guess is %lfn,g)v=g*g*g-15printf(new value is%lfn,v)if (v*v10)g1=gprintf(the next guess is %lfn,g)dx=(g1-g2)/g1elseg2=gprintf(the next guess is %lfn,g)dx=(g1-g2)/g1if (fabs(dx)less than epsilonconverged=1i=i+1printf(nth calculated value is %lfn,v)Example 1Consider finding the root of f(x) = x2 3. Let step = 0.01, abs = 0.01 and start with the interval 1, 2.Table 1. Bisection method applied to f(x)=x2 3.abf(a)f(b)c=(a+b)/2f(c)Updatenew b a1.02.0-2.01.01.5-0.75a = c0.51.52.0-0.751.01.750.062b = c0.251.51.75-0.750.06251.625-0.359a = c0.1251.6251.75-0.35940.06251.6875-0.1523a = c0.06251.68751.75-0.15230.06251.7188-0.0457a = c0.03131.71881.75-0.04570.06251.73440.0081b = c0.01561.719881.7344-0.04570.00811.7266-0.0189a = c0.0078Thus, with the seventh iteration, we note that the final interval, 1.7266, 1.7344, has a width less than 0.01 and f(1.7344) Example 2Consider finding the root of f(x) = e-x(3.2 sin(x) 0.5 cos(x)) on the interval 3, 4, this time with step = 0.001, abs = 0.001.Table 1. Bisection method applied to f(x)= e-x(3.2 sin(x) 0.5 cos(x)).abf(a)f(b)c=(a+b)/2f(c)Updatenew b a3.04.00.047127-0.0383723.5-0.019757b = c0.53.03.50.047127-0.0197573.250.0058479a = c0.253.253.50.0058479-0.0197573.375-0.0086808b = c0.1253.253.3750.0 058479-0.00868083.3125-0.0018773b = c0.06253.253.31250.0058479-0.00187733.28120.0018739a = c0.03133.28123.31250.0018739-0.00187733.2968-0.000024791b = c0.01563.28123.29680.0018739-0.0000247913.2890.00091736a = c0.00783.2893.29680.00091736-0.0000247913.29290.00044352a = c0.00393.29293.29680.00044352-0.0000247913.29480.00021466a = c0.0023.29483.29680.00021466-0.0000247913.29580.000094077a = c0.0013.29583.29680.000094077-0.0000247913.29630.000034799a = c0.0005Thus, after the 11th iteration, we note that the final interval, 3.2958, 3.2968 has a width less than 0.001 and f(3.2968) Comparison of rate of convergence for bisection and false-position methodLike the bisection method, the method of false position has almost assured convergence, and it may converge to a root faster. Finally, note that bisection is rather slow afterniterations the interval containing the root is of length(b a)/2n. However, provided values offcan be generated readily, as when a computer is used, the rather large number of iterations which can be involved in the application of bisection is of relatively little consequence.The false position method would be better i.e. converges to the root more rapidly as it takes into account the relative magnitudes of f(b) and f(a) unlike bisection which just uses the midpoint of a and b, where a,b is the interval over which the root occurs. Following is the example of the convergence rate of bisection method and false position method for the similar equation which shows that rate of convergence of false position method is faster than that of the bisection method.

No comments:

Post a Comment