Created
March 10, 2011 16:31
-
-
Save ramalho/864410 to your computer and use it in GitHub Desktop.
Raiz quadrada pelo método de Newton
This file contains hidden or 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
def media(x, y): | |
return float(x + y)/2 | |
def raizq(x): | |
''' raiz quadrada pelo metodo de Newton ''' | |
chute = 1.0 | |
while abs(chute * chute - x) >= 0.0001: | |
chute = media(chute, float(x)/chute) | |
return chute |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment