In my previous posts, I presented optimizations for e bunch of Maths functions, so lets continue and see whats next in the list ! Today I am going to explore ways to optimize Math.pow(2,x) or 2^x , as well as Math.exp One easy trick to fast perform 2^i for integers is to use bit shifting, […]

~ read more ~## Posts tagged Newton-Raphson

# reciprocal 1/x tricks **updated**

Can we fast compute 1.0/x ? static public function recriprocal( value:Number ):Number { return 1.0/value; } So here some ideas, we already have a fast way to compute 1/sqrt(x), if you look at 1/x and 1/sqrt(x) , you will notice that both equations are pretty close, so it gives us a pretty good “first guess”. […]

~ read more ~# sqrt trick

To compute the sqrt, we can use the Newton-Raphson method to converge to a sqrt. Newton serie is: x_(i+1) = x_i – f(x_i)/f'(x_i) for the sqrt we have: sqrt(n) = x or n = x^2 our newton function f(x) becomes: f(x) = x^2 – n. and first derivative: f'(x) = 2x; with our particular f(x), […]

~ read more ~
## Recent Comments