Question: The Heron method is a method the ancient Greeks used to compute the square root of a number n. The method generates a sequence of
The Heron method is a method the ancient Greeks used to compute the square root of a number n. The method generates a sequence of numbers that represent better and better approximations for sqrt n. The first number in the sequence is an arbitrary guess; every other number in the sequence is obtained from the previous number prev using the formula Please use simple python
1/2(prev + (n/prev))
Write function heron () that takes as input two numbers:n and error. The function should start with an inital guess of 1.0 for sqrt n and then repeatedly generate better approximations until the differenve ( more precisely, the absolute value of the difference) between successive approximations is at most error.
>>> heron (4.0, 0.5)
2.05
>>> heron (4.0, 0.1)
2.000609756097561
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
