Input 1

You might also like

You are on page 1of 1

Input

g=inline('(1+0.3*cos(X))');
dg=inline('(-0.3*sin(x))');
x1=input('enter initial guessx1=');
acc=input('enter the acc=');
a=dg(x1);
while(abs(a)>1)
x1=input('enter initial guessx1=');
a=dg(x1);
end
x2=g(x1);
while(abs(x2-x1)>acc)
x1=x2;
x2=g(x1);
end
fprintf('root of equation=%f',x2);

output
enter initial guessx1=0.5
enter the acc=0.0001
root of equation=1.128410

syntax
x=fzero('(1+0.3*cos(x)-x)',0.5)

x = 1.128410

You might also like