One numerical method for calculating the cubic root of a number VX is by using i
ID: 3710065 • Letter: O
Question
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 with X2 + 2x) /3, which is then used for calculating a third, and more accurate value xs, and so on. The general equation for calculating the value of xii from x, is i+1 Write an m-file which uses x 100 as the first estimate to calculate the cube-root of 100 (x -the cube root of the number you're calculating). Stop the looping when the relative error with each iteration is smaller than le-5. le. E = and print out the value using fprintf. smaller than le-s. le.EDetermine the number of iterations required to achieve this criterion E.g. The number of iterations required is 16 and the cube root of 999 is 9.996666, using x1-999.Explanation / Answer
//take random input to find out cube root
x1= input()
prev = x1;
//initialize count which count number of iteration
count=0;
while(1)
{
new = ((num/(prev*prev))+2*prev)/3
count++;
E = (new-prev)/prev;
if(new<E)
break;
}
fprintf("the number of iteration required is %d and the cube root of %4.2f is %4.2f,using x1=%d",count,num,x1);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.