Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a homework question on mathematica -- must use the proper code: The anci

ID: 675233 • Letter: T

Question

This is a homework question on mathematica -- must use the proper code:

The ancient Babylonians devised the following algorithm for finding the square root of a number A. First start with a resonable guess and call it x0. If x0 really were the square root of A, then x0^2=A, or equivalently x0=A/x0. But since your guess is not likely to be the square root of A, the numbers x0 and A/x0 will be different. Hence, let us use their average as our next guess:

x1= (x0+A/x0)/2

We then repeat the process using x1 to produce x2, and so on, with each successive step taking us closer to the square root of A.

Use this idea to find an approximation to the square root of 7000. Use 100 as your initial guess. Repeat the procedure 10 times. What is the final number? What is the absolute value of the difference between A and the square of the final number you found?

Explanation / Answer

1 Start with an arbitrary positive start value x0 (the closer to the root, the better).

2 Initialize y = 1.

3. Do following until desired approximation is achieved.

a) Get the next approximation for root using average of x0 and y

b) Set y = n/x0

float sRoot(float n)

{

float x = n;

float y = 1;

float e = 0.000001;

while(x0 - y > e)

{

x1= (x0+A/x0)/2;

y = n/x0;

}

return x0;

}

int main()

{

int n = 50;

printf ("Square root of %d is %f", n, sRoot(n));

getchar();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote