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

Fixed point Code:

function [xr i] = Fix(xo,es)


ea = es + 1;
i = 0;
if (abs(3*xo^2)>=1 || (3*xo^2)==0)
else
while (ea>es)
xi = xo^3 + 1;
ea = abs((xi-xo)/xi);
xo = xi;
i = i + 1;
if (i == 200)
break;
end
end
xr = xi;
end

Secant Method Code:


function [xr i] = Secant (xo,x1,es)
ea = es + 1;
i = 0;
while (Ea>Es)
xi = x1-(x1^3 - x1 + 1)*(x1-xo)/((x1^3 - x1 + 1)-(xo^3 - xo + 1));
ea = abs((xi-x1)/xi);
xo = x1;
x1 = xi;
i = i + 1;
if (i == 200)
break;
end
end
xr = xi;
end

You might also like