Professional Documents
Culture Documents
Input 1
Input 1
Input 1
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