Created
March 21, 2017 03:24
-
-
Save a-eid/c7b778da4fdd1af4fbf8fc5e0db47233 to your computer and use it in GitHub Desktop.
newton method sqrt recursive
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
// square root of x in range of e .. g could be much better guessed . | |
function sq(x , e , g ){ | |
g = g || x / 2 | |
if(Math.abs( g * g - x ) < e ) | |
return g | |
else | |
return sq( x , e , ( g + x / g ) / 2 ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment