Professional Documents
Culture Documents
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
PROCESS:
[‘a’ and ‘b’ are two float type variables and initially a=0.0 and b=1.0]
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’.
[End of ‘If’]
Step2.11: Set y x
[End of ‘If’]
[End of ‘Else’]
Step 2.19: Display the value of the root correct up to 4 decimal places i.e. print “x”
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;
while(f(a)*f(b)>0)
{
21
a=b;
b=b++;
scanf("%f",&err);
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));
if(f(x)<0)
a=x;
22
else
b=x;
}while(fabs(x-y)>err);
getch( );
OUTPUT:
23
DISCUSSION: