Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

ASSIGNMENT NO:

PROGRAM ON : Successive Approximation Method


Roll No:B-25

Function File :
Function g.m => function y=g(x)
y=log(1.4/cos(x));

Function dg.m => function y=dg(x)


y=tan(x);

Program File :
x1=input('enter the value of first root x1=');
n=input('enter the no. of iterations n=');
a=dg(x1);
while (abs(a)>1)
x1=input('enter the value of first root x1=');
a=dg(x1);
end
for i=1:1:n
x2=g(x1);
x1=x2;
end
fprintf('The root of equation is x2=%f',x2);

Program Output :

enter the value of first root x1=0.2

enter the no. of iterations n=5

The root of equation is x2=0.430590

Solver Solution :
x=fzero('exp(x)*cos(x)-1.4',0.2)

x =0.4336

You might also like