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 Newton's method for computing a square root. Newton's method for calculating the square

image text in transcribed
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 .000001 It can be shown that the accuracy of your "new guess" is: absolute_value of (new guess-last guess) If you are unfamiliar with absolute value, then we would say that for some variable x accuracy double x, absolute_value of x 1 .x gets a value somehow if (x- 0) absolutevalueofx = x; - - - else absolute value ofx -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); sample output might look like: Enter in N for Newton: 200 Newton (200.0)-14.142135623730955 Math.sqrt -14.142135623730951

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions