Created
February 13, 2013 11:33
-
-
Save nafu/4943999 to your computer and use it in GitHub Desktop.
Newton-Raphson ( for root finding)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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