I need to write a program that implements Newton's method ((guess + x/guess) / (2)). The program should prompt the user for the value to find the squareroot of (x) and the number of times to improve the guess. Starting with a guess value of x/2, your program should loop the specified number of times applying newton's method and report the final value of guess. You should also subtract your estimate from the value of math.sqrt() to show how close it is.
So far.. I got:
import math
def main():
value, guess = input("Please enter the value, and the number of times to loop: ")
while(
top = guess + value / guess
final_value = float(top) / 2
close = final_value - math.sqrt(x)
close_two = math.sqrt(x)
print "The guess is", final_value, "which is", close, "away from", close_two
main()
I'm so lost... could someone please help me?