Question

TASK 4 2 MARKS L06J] One numerical method for calculating the cubic root of a number VX is by using iterations. The process starts by choosing a value xi as a first estimate of the solution. Using this value, a second a more accurate value x2 can be calculated wx22x) /3, which is then used for calculating a third, and more accurate value x3, and so on. The general equation for calculating the value of xfrom x is Xi+1 - write an m-file which uses X1-100 as the first estimate to calculate the cube-root of 100 (X1 = the cube root of the number youre calculating). Stop the looping when the relative error with each iteration is smaller than 1e-5. l.e. E and print out the value using fprintf. 41. Determine the number of iterations required to achieve this criterion ci E.g. The number of iterations required is 16 and the cube root of 999 is 9.996666, using xi-999.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
clear
X=100;
x1=100;
xCurrent=x1;
tol=1e-5;
xOld=1/tol;
E=abs((xCurrent-xOld)/xCurrent);
i=0;
while E>tol
    xNew=(X/xCurrent^2+2*xCurrent)/3;
    xOld=xCurrent;
    xCurrent=xNew;
    E=abs((xCurrent-xOld)/xCurrent);
    i=i+1;
end
fprintf('The number of iterations required is %d and the cube root of %d is %f, using x1=%d.\n',i,X,xCurrent,x1)

Command Window > CubeRootX The number of iterations required is 12 and the cube root of 100 is 4.641589, using x1=100.

Add a comment
Know the answer?
Add Answer to:
TASK 4 2 MARKS L06J] One numerical method for calculating the cubic root of a number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT