0% found this document useful (0 votes)
54 views

Numerical Accuracy of Bisection Method

This document presents a study on evaluating the numerical accuracy of the bisection method for calculating square roots. A C++ program was developed to calculate square roots from 1 to 25 using the bisection method in the interval [0,6]. The lowest accuracy was observed for sqrt(1) with a percentage error of 0.000381469700. The highest accuracy was for sqrt(13) with a percentage error of 0.000000905160. On average, the percentage error was 0.000041549568, indicating accuracy could be improved by reducing the tolerance value.

Uploaded by

Atul Atake
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Numerical Accuracy of Bisection Method

This document presents a study on evaluating the numerical accuracy of the bisection method for calculating square roots. A C++ program was developed to calculate square roots from 1 to 25 using the bisection method in the interval [0,6]. The lowest accuracy was observed for sqrt(1) with a percentage error of 0.000381469700. The highest accuracy was for sqrt(13) with a percentage error of 0.000000905160. On average, the percentage error was 0.000041549568, indicating accuracy could be improved by reducing the tolerance value.

Uploaded by

Atul Atake
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

International Multidisciplinary Research Journal 2012, 2(1):01-04

ISSN: 2231-6302
Available Online: http://irjs.info/

Numerical accuracy of bisection method


R. B. Srivastava* and Narendra Deo Dixit

Department of Mathematics, M. L. K. P. G. College, Balrampur, U. P., India

Abstract
A computer program in C++ language has been developed to calculate square roots of numbers from 1 to 25 in interval [0, 6]
using bisection method. Accuracy of bisection method has been found out in each calculation. Lowest accuracy has been
observed in the calculation of square root of 1 in the interval [0, 6] and percentage error is equal to 0.000381469700. Highest
accuracy has been observed in the evaluation of square root of 13 in the interval [0, 6] and percentage error is equal to
0.000000905160. Average percentage error of bisection method in the calculation of square roots of natural numbers from 1
to 25 has been found to be 0.000041549568 which indicates that the accuracy of bisection method can be increased by
reducing tolerance value.

Keywords: Bisection method, numerical accuracy, percentage error, Intermediate-Value theorem, algorithm.

INTRODUCTION
Intermediate-Value Theorem. Let us consider a continuous function
Numerical analysis involves the study of methods of f(x) over the interval [a, b]. If
computing numerical data. Many problems across mathematics can f(a)f(b) < 0
be reduced to linear algebra, this too is studied numerically. Then the values of f(a) and f(b) must be nonzero and each of
Numerical solutions to differential equations require the different sign. That is, if f(a) is negative, f(b) must be positive.[9-13]
determination not of a few numbers but of an entire function; in Likewise, if f(a) is positive, f(b) must be negative. In light of the
particular, convergence must be judged by some global criterion.[1-5] Intermediate-Value theorem, the intermediate-value that we seek is
The bisection method is the simplest and most robust zero, which certainly lies between the positive and negative numbers
algorithm for finding the root of a one-dimensional continuous represented by f(a) and f(b). The conclusion of the Intermediate-
function on a closed interval. The basic idea is a follows- Value theorem is that there is a point, ξ , between a and b
Suppose that f(x) is a continuous function defined over an where f(ξ)=0. That is, the solution to f(x)=0 lies somewhere between
interval [a; b] and f(a) and f(b) have opposite signs. Then by the a and b.
intermediate value theorem, there exists at least one r ε [a; b] such The bisection method checks the midpoint, c, of the interval [a,
that f(r) = 0. The method is iterative and each iteration starts by b]. If f(c) = 0, the task of finding a root is complete. If f(c) ≠ 0 , then
breaking the current interval bracketing the root into two subintervals for the same reason, there must be a root in either [a, c] if f(a)f(c) < 0
of equal length. One of the two subintervals must have endpoints of or on [c, b] if f(c)f(b) < 0.
different signs. This subinterval becomes the new interval and the This procedure defines the bisection method. At each step the
next iteration begins. Thus we can define smaller and smaller interval in which there is guaranteed to be a root of the equation is
intervals such that each interval contains r by looking at subintervals halved (bisected), and the method terminates as soon as the width of
of the current interval and choosing the one in which f(x) changes the interval containing the root is less than some error tolerance δ >
signs. This process continues until the width of the interval 0. Since the bisection method keeps a bounded interval where there
containing a root shrinks below some predetermined error tolerance. is at least one root at each step, it falls in the category of bracketing
[6-8] This method’s major drawback is that it is the slowest among all methods.[14-18]
the root finding methods. However, the method always converges An algorithmic definition of the bisection method is as follows [7]
to a solution and would be good to use as a starter for one of the Inputs: the function f(x), the initial interval [a, b] and the stopping
other methods. tolerance δ

MATERIAL AND METHOD if ( (f(a) * f(b) ≥ 0) then


begin
The bisection method is developed with the support of the c=(a + b) / 2
while ( f(c) < δ )
Received: Sept 13, 2011; Revised: Dec 17, 2011; Accepted: Dec 27, 2011. Begin
c=(a + b)/2
*Corresponding Author
if ( sign f(a)) = (sign f(c)) then a=c else b=c
R. B. Srivastava end
Department of Mathematics return c;
M. L. K. P. G. College, Balrampur, U. P., India end
Tel: +91-9415036245; Fax: else
Email: [email protected] write(“Root does not exist”)
2 R.B.Srivastava et al.,

Computer program for bisection method developed by us is printf("Root= %20.15f\n",c[n]);


given below- printf("Value of function=%20.15f\n", f(c[n]));
printf("No. of iterations=%3d\n",n);
#include<conio.h> printf("Actual value of root=%15.12f\n",sqrt(avr));
#include<stdio.h> fprintf(fpt,"Actual value of root=%15.12f\n",sqrt(avr));
#include<math.h> printf("\n");
//Bisection method getch();
void main(void) }
{ else
FILE *fpt; {
int n; printf("There is no root in the given interval\n");
float a[1000],b[1000],c[1000],delta,rl,ru,d,aa; getch();
double f(float x); }
//avr is the variable whose square root is to be calculated fclose(fpt);
double avr=25.0; }
clrscr(); //Function definition
//Filename to store result double f(float x)
fpt=fopen("nddb25.txt", "w"); {
rl=0; ru=6.0; n=1; a[1]=rl; b[1]=ru; aa=fabs(rl-ru); double r;
//Value of function f(x) r=x*x-25;
fprintf(fpt,"f(x)=x^2-25\n"); return(r);
fprintf(fpt,"rl= %6.2f\n",rl); }
fprintf(fpt,"ru= %6.2f\n",ru);
//to check existence of root between the interval With the help of above computer program, square roots of the
d=f(rl)*f(ru); natural numbers from 1 to 25 in the interval [0, 6] have been
delta=0.00001; calculated. For this, the following functions have been taken
fprintf(fpt," n a[n] b[n] c[n] f(c[n])\n"); f(x) = x2 - n = 0 where n = 1, 2, 3, ……. , 25
printf(" n a[n] b[n] c[n] f(c[n])\n"); Numerical accuracy of bisection method has been has been
if (d<0) measured by percentage error and defined as follows–
{ Percentage error = error in the value of square root * 100/actual
while(aa > delta) value of square root
{ Numerical accuracy of bisection method is inversely
if (a[n]==b[n]) break; proportional to percentage error.
c[n]=(a[n]+b[n])/2;
if (((f(c[n])>0) && (f(a[n])>0)) || ((f(c[n])<0) && (f(a[n])<0))) RESULT AND DISCUSSION
{
a[n+1]=c[n]; Square roots of natural numbers from 1 to 25 have been
b[n+1]=b[n]; calculated using bisection method in the interval [0, 6] with stopping
} tolerance 0.00001.
else
{ Calculation of square root of 1 by bisection method
b[n+1]=c[n];
a[n+1]=a[n]; Bisection method has been applied to calculate the roots of
} equation
aa=fabs(f(c[n])); f(x) = x2 – 1 = 0
fprintf(fpt,"%3d %15.12f %15.12f %15.12f %18.12f\n", n,a[n], b[n], In the interval [0, 6] using computer program developed by us.
c[n], f(c[n])); Initial value, last value, middle point of interval and value of function
printf("%3d %15.12f %15.12f %15.12f %18.12f\n", n,a[n], b[n], at middle point of the interval in each iteration is included in Table-1.
c[n],f(c[n])); Estimated value of square root of 1 by bisection method after each
if (aa > delta) n=n+1; iteration is shown in Graph-1.
}

Table1. Initial value, last value, middle point of interval and value of function at middle point of the interval in the calculation of square root of 1 by bisection method

Number of
Initial value (a) Last value (b) Middle point (c) Value of function f(x) at x=c
iterations
1 0.000000000000 6.000000000000 3.000000000000 8.000000000000
2 0.000000000000 3.000000000000 1.500000000000 1.250000000000
3 0.000000000000 1.500000000000 0.750000000000 -0.437500000000
4 0.750000000000 1.500000000000 1.125000000000 0.265625000000
5 0.750000000000 1.125000000000 0.937500000000 -0.121093750000
6 0.937500000000 1.125000000000 1.031250000000 0.063476562500
International Multidisciplinary Research Journal 2012, 2(1):01-04 3

7 0.937500000000 1.031250000000 0.984375000000 -0.031005859375


8 0.984375000000 1.031250000000 1.007812500000 0.015686035156
9 0.984375000000 1.007812500000 0.996093750000 -0.007797241211
10 0.996093750000 1.007812500000 1.001953125000 0.003910064697
11 0.996093750000 1.001953125000 0.999023437500 -0.001952171326
12 0.999023437500 1.001953125000 1.000488281250 0.000976800919
13 0.999023437500 1.000488281250 0.999755859375 -0.000488221645
14 0.999755859375 1.000488281250 1.000122070312 0.000244155526
15 0.999755859375 1.000122070312 0.999938964844 -0.000122066587
16 0.999938964844 1.000122070312 1.000030517578 0.000061036088
17 0.999938964844 1.000030517578 0.999984741211 -0.000030517345
18 0.999984741211 1.000030517578 1.000007629395 0.000015258847
19 0.999984741211 1.000007629395 0.999996185303 -0.000007629380

Actual value of square root of 1 1.000000000000


Calculated value of square root of 1 by bisection method 0.999996185303
Difference between actual and calculated values of square root of 1 0.000003814697
Percentage error in the value of square root of 1 calculated by bisection method 0.000381469700

Graph 1. Estimated value of square root of 1 by bisection method after each iteration

Estimated value of square root of 1 in each iteration of bisection method

3.5
Estimated value of root

3
2.5
2
1.5
1
0.5
0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Iteration

Similarly, the square roots of natural numbers from 2 to 25 Highest percentage error has been obtained in the calculation
have been calculated with the help of computer program to draw the of square root of 1 in the interval [0, 6] and is equal to
appropriate conclusion. 0.000381469700. It means if roots lies in the beginning of the interval
then the error in the calculated value of root of equation by bisection
CONCLUSION method is greatest. Exact value of root, value of root calculated by
bisection method and percentage error in the calculation of root by
Lowest percentage error has been obtained in the calculation bisection method is shown in Table-2. Average percentage error of
of square root of 13 in the interval [0, 6] and is equal to bisection method in the calculation of square roots of natural
0.000000905160. It means if roots lies in the middle of the interval numbers from 1 to 25 has been found to be 0.000041549568 which
then the error in the calculated value of root of equation by bisection indicates that the accuracy of bisection method can be increased by
method is least. reducing tolerance value.

Table 2. Numerical accuracy of bisection method in the calculation of roots of functions f(x) = x2 – n; n=1, 2, …., 25

Value of root obtained by Percentage error in bisection


S. No. Function Exact Value of root
bisection method method
1 f(x)=x2-1 1.000000000000 0.999996185303 0.000381469700
2 f(x)=x2-2 1.414213562373 1.414215087891 0.000107870412
3 f(x)=x2-3 1.732050807569 1.732051849365 0.000060148120
4 f(x)=x2-4 2.000000000000 1.999998092651 0.000095367450
5 f(x)=x2-5 2.236067977500 2.236066818237 0.000051843817
6 f(x)=x2-6 2.449489742783 2.449490547180 0.000032839370
7 f(x)=x2-7 2.645751311065 2.645750999451 0.000011777902
8 f(x)=x2-8 2.828427124746 2.828427314758 0.000006717939
9 f(x)=x2-9 3.000000000000 2.999998569489 0.000047683700
10 f(x)=x2-10 3.162277660168 3.162277221680 0.000013866208
11 f(x)=x2-11 3.316624790355 3.316623687744 0.000033244973
12 f(x)=x2-12 3.464101615138 3.464100837708 0.000022442471
13 f(x)=x2-13 3.605551275464 3.605551242828 0.000000905160
14 f(x)=x2-14 3.741657386774 3.741657257080 0.000003466218
15 f(x)=x2-15 3.872983346207 3.872983932495 0.000015137891
16 f(x)=x2-16 4.000000000000 3.999999046326 0.000023841850
17 f(x)=x2-17 4.123105625618 4.123106002808 0.000009148201
4 R.B.Srivastava et al.,

Value of root obtained by Percentage error in bisection


S. No. Function Exact Value of root
bisection method method
18 f(x)=x2-18 4.242640687119 4.242639541626 0.000026999529
19 f(x)=x2-19 4.358898943541 4.358900070190 0.000025847101
20 f(x)=x2-20 4.472135955000 4.472136497498 0.000012130624
21 f(x)=x2-21 4.582575694956 4.582574844360 0.000018561526
22 f(x)=x2-22 4.690415759823 4.690415382385 0.000008047005
23 f(x)=x2-23 4.795831523313 4.795831203461 0.000006669375
24 f(x)=x2-24 4.898979485566 4.898979663849 0.000003639187
25 f(x)=x2-25 5.000000000000 5.000000953674 0.000019073480
Average percentage error in bisection method 0.000041549568

REFERENCES
[11] Hart, V. G.; Howard, L. N.,1978. Austral. Math. Soc. Gaz., 5 (3):
73-89.
[1] Speck, G. P., 1977. New Zealand Math. Mag., 14(1):34-36.
[12] Speck, G. P.,1977. New Zealand Math. Mag., 14 (1): 34-36.
[2] Garey M. R., Johnson D. S., Stockmeyer L., 1976. Theoretical
[13] Franklin F.,1981. American Journal of Mathematics, 4(1/4): 275-
Computer Science, 1(3):237-267. 276.
[3] Nievergelt, Yves,1994. SIAM Rev., 36(2): 258-264.
[14] Fiduccia C. M., Mattheyses R. M.,1982. Proceedings of the 19th
[4] Bui T., 1984. IEEE FOCS, 181-191. Design Automation Conference, 175-181.
[5] Jerrum M., 1993. Sorkin G. B., IEEE FOCS, 94-103. [15] Rall L. B.,1974. SIAM Journal on Numerical Analysis, 11(1): 34-
36.
[6] Baushev A.N., Morozova E.Y,2007. Lectures notes in
engineering and computer science, 2:801-803. [16] Jorge J. More,1971. SIAM Journal on Numerical Analysis, 8(2):
325-336.
[7] Torczon, V, 1991. SIAM J. Optim., 1:123-145.
[17] McKinnon, K.I.M.,1998. SIAM J. Optim, 9:148-158.
[8] Torczon V.,1997. SIAM J. Optim, 7(1):1-25.
[9] Kazuo Murota,1982. SIAM Journal on Numerical Analysis, 19(4): [18] Kernighan B., Lin S.,1970. The Bell System Technical Journal,
793-799. 49(2):291-307.

[10] Reddien G. W.,1978. SIAM Journal on Numerical Analysis,


15( 5): 993-996.

You might also like