Tutorial:

Example: Suppose your requirement is to approximate Pi to 8 digits, which means the error goal is 1e-8. Use the following function to calculate how many loops can reach the error goal.

The solution can be the following:

P=27; % the cubic root of this number

xold=P/3;

E=1;

xold=0;

while(E>1e-5)

xnew=((P/xold^2)+2*xold)/3;

E=abs((xnew-xold)/xold);

xold=xnew;

end

fprintf('The cube root of %2.2f is %2.2f\n',P,xnew);

Task:

Send your work to the email by Wednesday.