Вы находитесь на странице: 1из 2

Gerfel Philip Gonzales

BSECE 5

Simple Fixed-point Method


1 SCINOTE CODE

//Gerfel Philip C. Gonzales


//BSECE 5

//Laboratory 3
//Simple Fixed-point Method

function fixed_point()
f = input("Input the rearranged function to be evaluated:","string");
p0 = input("Input initial guess p0:");
es = input("Input your desired stopping criterion:");
maxiter = input("Maximum no. of iterations:");

disp(['Root Error'])
for iter = 1:maxiter;
x = p0;
p = evstr(f);
er = abs((p-p0)/(abs(p)+%eps));

printf('%8.4f %f\n',p,er);

//evaluation
if (er <= es) then break end;
if (er == 1) then break end;
p0 = p;
end
if (er == 1) then disp('The algorithm is diverging.');
else printf('\n\nRoot is %f with %f error at %dth iteration',p,er,iter);
end

endfunction
Gerfel Philip Gonzales
BSECE 5

2 SIMULATION
Find the root of 𝒙𝟑 + 𝟓𝒙 − 𝟓 = 𝟎 with a approximation error of 𝟎. 𝟎𝟎𝟏 and maximum number of
iteration of 100 starting with x = 0.75.
𝟓−𝒙𝟑
Rearranged 𝒙 = 𝟓
.

2.1 CHOOSING A GUESS ROOT OF 0 .75

Вам также может понравиться