Target Formula
y = 1 / √x
x =

1 How the Bits are Interpreted (IEEE 754)

Before doing math, know how your the computer stores floating point numbers.
Here is how your input 4.0 looks in memory:

[sign]
[exponent]
[mantissa]
Sign Bit (ORANGE) Determines if the number is positive or negative.
0 = Positive (+)
1 = Negative (-) (not supported)
Exponent (BLUE) Uses a 127-bias. To get the real power of 2, subtract 127:
0 - 127 = 0
Meaning: 20
Mantissa (green) These bits represent the fractional precision. The computer assumes a hidden leading 1.
Value: 1 + 0 = 0
Combined: (1.0 + 0) × 20 = 0
⚠️ MATHEMATICAL ERROR

Negative numbers are not supported by this algorithm.

2 The Magic Subtraction

We shift the bits and subtract them from the magic constant 0x5f3759df.

0x5f3759df


( i >> 1 )
=

Resulting Bits (The "Dirty" Guess)
How bit subtraction works: Subtracting from this constant "flips" the exponent (positive to negative) and adjusts for the IEEE 754 bias. This magically performs the 1/x and square root steps at the same time.
Interpretation of Bits
Exponent: 0 (20)
Scientific Formula
1.00 × 20
Accuracy Comparison
MAGIC GUESS
0.000000
EXPECTED RESULT
0.000000
Initial Hack Error: 0%

3 Newton's Refinement

y = y * (1.5 - ( (x * 0.5) * y * y ))
Final Refined Output
0
Exact Target (1/√x)
0