Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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: 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);

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

Step: 1

import javautilScanner import javalangMath public class Newton public static void mainString a... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions