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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started