Skip to content

Instantly share code, notes, and snippets.

@nafu
Created February 13, 2013 11:33
Show Gist options
  • Save nafu/4943999 to your computer and use it in GitHub Desktop.
Save nafu/4943999 to your computer and use it in GitHub Desktop.
Newton-Raphson ( for root finding)
epsilon = 0.01
y = 1234567.0
guess = y/2.0
while abs(guess*guess - y) >= epsilon:
guess = guess - (((guess**2) - y)/(2*guess))
print(guess)
print('Square root of ' + str(y) + ' is about ' + str(guess))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment