Tenzin N.

asked • 05/25/20

Problem regarding Newton Last guess and Next guess.

Square Root



Write a function named squareRootFinder to determine the square root of a number. The square root of a number can be approximated by repeated calculation using the formula

NG = 0.5(LG + N/LG)

where NG stands for the next guess and LG stands for the last guess. The loop should repeat until the difference between NG and LG is less than 0.00001, and then return the value of NG. Use an initial guess of 1.0. Write a main function that asks the user for a number and uses your squareRootFinder function to find the square root of that number.

(This algorithm is called Newton's Method and can approximate square roots relatively rapidly, even if you start with a terrible guess).

Your squareRootFinder function should be defined exactly as follows (it must take a double as a parameter and return a double as a final result:

  double squareRootFinder(double number)


Frequently there are rounding errors when doing floating-point math which should be avoided at any cost!!!!!



PLEASE USE C++ PROGRAMMING FOR THIS PROBLEM!!!!!!!!!!!!!

1 Expert Answer

By:

Patrick B. answered • 05/26/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.