Está en la página 1de 1

clc

clear all

format long

x1=input('Enter the Initial Guess x1 =');

n=input('Enter number of iterations =');

y=(1+0.3*cos(x1));

y1=(-0.3*sin(x1));

while(y1>1)

fprintf('\n Initial Guess is wrong');

x1=input('\n Enter the Initial Guess x1 =');

y=(1+0.3*cos(x1));

y1=(-0.3*sin(x1));

end

for i=1:n

x2=(1+0.3*cos(x1));

x1=x2;

y1=(1+0.3*cos(x1));

y2=(-0.3*sin(x1));

end

fprintf('final root is x2=%f',x2);

También podría gustarte