Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Łukasz Jagiełło - Fast Inverse Square Root - Pa...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Łukasz Jagiełło - Fast Inverse Square Root - Papers We Love SF 2017

Fast inverse square root, sometimes referred to as Fast InvSqrt() or by the hexadecimal constant 0x5f3759df, is an algorithm that estimates 1/√x, the reciprocal (or multiplicative inverse) of the square root of a 32-bit floating-point number x in IEEE 754 floating-point format.

Avatar for Lukasz Jagiello

Lukasz Jagiello

May 25, 2017
Tweet

Other Decks in Technology

Transcript

  1. n = 2 1 / sqrt(n) = 0.70710678119 g =

    1 1st ng = g*(1.5 - (n/2)*g*g) 0.5 70.71067811831%
  2. n = 2 1 / sqrt(n) = 0.70710678119 g =

    1 1st ng = g*(1.5 - (n/2)*g*g) 0.5 70.71067811831% 2nd ng = g*(1.5 - (n/2)*g*g) 0.625 88.38834764789%
  3. n = 2 1 / sqrt(n) = 0.70710678119 g =

    1 1st ng = g*(1.5 - (n/2)*g*g) 0.5 70.71067811831% 2nd ng = g*(1.5 - (n/2)*g*g) 0.625 88.38834764789% 3rd ng = g*(1.5 - (n/2)*g*g) 0.693359375 98.05582317187% 4th ng = g*(1.5 - (n/2)*g*g) 0.7067084685 99.94367007917% 5th ng = g*(1.5 - (n/2)*g*g) 0.7071064447 99.99995241313%
  4. modern CPU - Intel Xeon E5-2667v3 the hack is actually

    ~x2 slower in 2017 used to be ~x4 times faster back in ~2003
  5. ?