Iterative Square Root
//------------------------------------------------------------------
float function_IterativeSquareRoot (float x) {
// http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
// Ancient Babylonian technology
functionName = "Iterative (Heron's) Square Root";
float y = 0.5;
int n = 6;
for (int i=0; i<n; i++) {
y = (y + x/y)/2.0;
}
return y;
}
Was browsing some code by Golan Levin and stumbled on this…
There are some real gems in the repo – might port some stuff from there in the future…