Monday, April 1, 2019

Rate of convergence and bisection

Rate of crossroad and bisectionRate of intersection regard of the speed with which a giftn eon or iteration approaches its limit, lots measured by the number of terms or evaluations involved in obtaining a assumption accuracy. Although strictly speaking, a limit does not give information about any finite first part of the sequence, this idea is of practical importance if we deal with a sequence of successive approximations for an iterative manner, as then typically fewer iterations are needed to exit a useful approximation if the prescribe of receivence is higher. This may eventide make the difference in the midst of needing ten or a gazillion iterations.Rate of convergence is measured in terms of rate at which the relative error decreases amid successive approximations. There are in the main two type of convergence linear and quadratic. converging of a sequence subject to the condition, for p 1, thatas n increases is called pth-order convergence for example, quadra tic convergence when p = 2. One similarly speaks of logarithmic convergence or exp 1ntial intimacy convergence.The Bisection MethodIn mathematics, the bisection regularity acting is a groundwork- purpose algorithm which repeatedly bisects an musical interval then selects a subinterval in which a root must imposition for further processing. It is a very simple and robust rule, but it is as well relatively slow. The bisection manner is simple, robust, and lawful-forward take an interval a, b such that f(a) and f(b) have confrontation 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 rule, fitting 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 in that location exists at least(prenominal) one rea l root of f (x) = 0 between a and b.Procedure count on that a continuous function f is disallow 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 prove from a graph of f.) If we calculate f ((a +b)/2), which is the function rank at the point of bisection of the interval af ((a + b)/2) = 0, in which plate (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 draw spurs of the bisection methodAdvantages of Bisection MethodThe bisection method is always convergent. Since the method brackets the root, the method is coverd 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 get out take larger number of iterations to rag the root.If a function is such that it 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 as well 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. infatuated position methodThe false-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 know 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 to 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 primarily 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 trinity possibilities f(X) = 0, when caseXis therootf(X) f(X)0, when the root lies betweenXanda.Again, in shift1, the process is terminated, in either type2or Case3, the process can be repeated until the root is obtained to the desired accuracy.Convergence of False Position Method and Bisection Method character enter for False Position MethodExample edict o f False-position methodC code was written for clarity instead of efficiency. It was designed to solve the same chore 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 treble 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 track this code, the final answer is approximately 0.865474033101614Example 1Consider finding the root of f(x) = x2 3. Let timbre = 0.01, abs = 0.01 and start with the interval 1, 2.Table 1. False-position method apply to f(x)=x2 3.abf(a)f(b)cf(c)Update Step coat1.02.0-2.001.001.6667-0.2221a = c0.66671.66672.0-0.22211.01.7273-0.0164a = c0.06061.72732.0-0.01641.01.73170.0012a = c0.0044Thus, with the one-third iteration, we telephone line that the last tempo 1.7273 1.7317 is little 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.3010 0.047127-0.000526163.2978-0.00014453b = c0.00323.03.29780.047127-0.000144533.2969-0.000036998b = c0.0009Thus, after the 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 name was not as good as the solution we rear utilize 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( nurse 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 beside 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.5 0.047127-0.0197573.250.0058479a = c0.253.253.50.0058479-0.0197573.375-0.0086808b = c0.1253.253.3750.0058479-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 eleventh 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 most assured convergence, and it may converge to a root faster. Finally, note that bisection is quite an slow afterniterations the interval containing the root is of length( b a)/2n. However, provided set offcan be generated readily, as when a computer is used, the rather large number of iterations which can be involved in the exertion of bisection is of relatively little consequence.The false position method would be burst i.e. converges to the root more rapidly as it takes into account the relative magnitudes of f(b) and f(a) different bisection which just uses the midpoint of a and b, where a,b is the interval over which the root occurs. avocation 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

Note: Only a member of this blog may post a comment.

What Warren Buffets eating habits can teach you about your career

What Warren Buffets dietary patterns can show you your profession Have you at any point heard the expression â€Å"you are what you...