Question: Create a package named newton_sqrt and write a program to use the computing a square root. Newton's method for calculating the square root of N

Create a package named newton_sqrt and write a program to use the computing a square root.

Newton's method for calculating the square root of N starts by making root. I would recommend starting with an initial guess of N/2.

It then computes a better guess, according to the following formula:

new_guess = ((N/last_guess) + last_guess)/2; You will want to use a while loop for this algorigthm. Each time you do the calculation you wi get a more accurate answer. Have your while loop continue executing until the accuracy is

It can be shown that the accuracy of your "new_guess" is: accuracy = absolute_value of (new_guess - last_guess) If you are unfamiliar with absolute value, then we would say that for some variable x: double x, absolute_value_of_x; // .... x gets a value somehow if (xPrint the "Newton_sqrt" answer for computing a square root at the end of your while loop. Compare it with the Java Math function: Math.sqrt(N);

>= 0) else absolute_value_of_x = x; absolute_value_of_x = -x; Sample output might

Newton Square Root problem

Create a package named newton_sqrt and write a program to use the "Newton's method" for computing a square root. Newton's method for calculating the square root of N starts by making a guess at the square root. I would recommend starting with an initial guess of N/2.

It then computes a better guess, according to the following formula: new_guess = ((N/last_guess) + last_guess)/2;

You will want to use a while loop for this algorigthm. Each time you do the calculation you will get a more accurate answer. Have your while loop continue executing until the accuracy is

It can be shown that the accuracy of your "new_guess" is: accuracy = absolute_value of (new_guess - last_guess)

If you are unfamiliar with absolute value, then we would say that for some variable x:

double x, absolute_value_of_x;

// ..... x gets a value somehow if (x >= 0)

absolute_value_of_x = x; else absolute_value_of_x = -x;

Print the "Newton_sqrt" answer for computing a square root at the end of your while loop. Compare it with the Java Math function: Math.sqrt(N);

double x, absolute_value_of_x; // .... x gets a value somehow if (x >= 0) else absolute_value_of_x = x; absolute_value_of_x = -x; Sample output might look like: Enter in N for Newton: 200 Newton (200.0)=14.142135623730955 Math.sqrt =14.142135623730951

Step by Step Solution

3.42 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement the Newtons method for finding the square root in Java follow these steps The code will ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!