You are on page 1of 6

18

ASSIGNMENT 5
FINDING A ROOT OF AN EQUATION BY REGULA FALSI METHOD

STATEMENT:
In the ‘Regula Falsi’ method we first find a sufficiently small interval [a0,b0], such that
f(a0).f(b0)<0, by tabulation or graphical method, and which contains only one root α (say)
of f(x)=0, i.e., f’(x) maintains same sign in [a0,b0]. In this method:
𝑓(𝑥0 )
𝑥𝑛+1 = 𝑥0 − (𝑥 − 𝑥0 )
𝑓(𝑥𝑛 ) − 𝑓(𝑥0 ) 𝑛

ALGORITHM:
INPUT: A function 3x−cos x−1

OUTPUT: An isolated root of the equation.

PROCESS:

Step 1: Create a function “float f (float x)”

Step 1.1: Return (3x−cosx−1)

[End of the function “float f (float x)”]


19

Step 2: Create the function “void main()”

[‘a’ and ‘b’ are two float type variables and initially a=0.0 and b=1.0]

Step 2.1: While(f(a)*f(b)>0) then repeat Step 2.2 to Step 2.3

Step 2.2: Set ab

Step 2.3: Set bb+1

[End of Step 2.1 ‘While’ loop]

Step 2.4: Display the two integer values ‘a’ and ‘b’ in which the root lies i.e.
print “a,b”.

Step 2.5: Take the value of Error in a float type variable ‘err’.

Step 2.6: If (f(a) >0 ) then

Step 2.7: Set aa+b

Step 2.8: Set ba−b

Step 2.9: Set aa−b

[End of ‘If’]

Step 2.10: Do Step 2.11 to Step to Step 2.18

Step2.11: Set y  x

Step 2.12: Set xa−((f(a)/(f(b)−f(a)))×(b−a))

Step 2.13: If(f(x)<0) then

Step 2.14: Set ax

[End of ‘If’]

Step 2.15: Else

Step 2.16: Set bx

[End of ‘Else’]

Step 2.17: Print “a,b,f(a),f(b),x,f(x)”


20

Step 2.18: While(fabs(x-y)>err) then go to Step 2.10 repeatedly

Step 2.19: Display the value of the root correct up to 4 decimal places i.e. print “x”

[End of the function “void main()”]

Step 3: Stop

PROGRAM CODE:

#include <stdio.h>

#include <conio.h>

#include <math.h>

float f(float x)

return ((3*x)-cos(x)-1);

void main( )

int n=0;

float a=0.0, b=1.0, x=0.0, y=0.0, err;

while(f(a)*f(b)>0)

{
21

a=b;

b=b++;

printf("Enter the error: ");

scanf("%f",&err);

printf("\n\troot lies between: %f and %f",a,b);

printf("\n\n a(-ve)\tb(+ve)\t f(a)\t f(b)\t x\t f(x)");

printf("\n----------------------------------------------------------------------------\n");

if(f(a)>0)

a=a+b;

b=a-b;

a=a-b;

do

y=x;

x=a-((f(a)/(f(b)-f(a)))*(b-a));

printf("\n %.4f\t\t%.4f\t %.4f\t %.4f\t%.4f\t\t%.4f",a,b,f(a),f(b),x,f(x));

if(f(x)<0)

a=x;
22

else

b=x;

}while(fabs(x-y)>err);

printf("\n\nThe root is: %.4f",x);

getch( );

OUTPUT:
23

DISCUSSION:

As in the bisection method, the sequence of successive approximations obtained by formula


is invariably convergent. For the convergence of Regula-Falsi Method, the interval [a0,b0]
must be very small. For discontinuous functions, this method can only be expected to find a
point where the function changes sign. In addition to sign changes, it is also possible for the
method to converge to a point where the limit of the function is zero, even if the function is
undefined (or has another value) at that point. It is mathematically possible with
discontinuous functions for the method to fail to converge to a zero limit or sign change,
but this is not a problem in practice since it would require an infinite sequence of
coincidences for both endpoints to get stuck converging to discontinuities where the sign
does not change. The method of bisection avoids this hypothetical convergence problem.

You might also like