2sqrt (example 3.1)

Percentage Accurate: 7.1% → 99.6%
Time: 10.4s
Alternatives: 7
Speedup: 2.0×

Specification

?
\[x > 1 \land x < 10^{+308}\]
\[\begin{array}{l} \\ \sqrt{x + 1} - \sqrt{x} \end{array} \]
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
	return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
	return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x):
	return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x)
	return Float64(sqrt(Float64(x + 1.0)) - sqrt(x))
end
function tmp = code(x)
	tmp = sqrt((x + 1.0)) - sqrt(x);
end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt{x + 1} - \sqrt{x}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 7.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{x + 1} - \sqrt{x} \end{array} \]
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
	return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
	return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x):
	return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x)
	return Float64(sqrt(Float64(x + 1.0)) - sqrt(x))
end
function tmp = code(x)
	tmp = sqrt((x + 1.0)) - sqrt(x);
end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt{x + 1} - \sqrt{x}
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\sqrt{1 + x} + \sqrt{x}} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))
double code(double x) {
	return 1.0 / (sqrt((1.0 + x)) + sqrt(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x))
end function
public static double code(double x) {
	return 1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
}
def code(x):
	return 1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x))
function code(x)
	return Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)))
end
function tmp = code(x)
	tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
end
code[x_] := N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\sqrt{1 + x} + \sqrt{x}}
\end{array}
Derivation
  1. Initial program 6.7%

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--N/A

      \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\color{blue}{\sqrt{x + 1} + \sqrt{x}}} \]
    2. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right), \color{blue}{\left(\sqrt{x + 1} + \sqrt{x}\right)}\right) \]
    3. rem-square-sqrtN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - \sqrt{x} \cdot \sqrt{x}\right), \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)\right) \]
    4. rem-square-sqrtN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - x\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
    5. associate--l+N/A

      \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 - x\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
    7. *-rgt-identityN/A

      \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
    8. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
    9. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
    10. *-rgt-identityN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
    11. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
    12. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left(\sqrt{x + 1}\right), \color{blue}{\left(\sqrt{x}\right)}\right)\right) \]
    13. pow1/2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left({\left(x + 1\right)}^{\frac{1}{2}}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
    14. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{1}{2}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
    15. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \left(\sqrt{x}\right)\right)\right) \]
    16. sqrt-lowering-sqrt.f649.1%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \mathsf{sqrt.f64}\left(x\right)\right)\right) \]
  4. Applied egg-rr9.1%

    \[\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{{\left(x + 1\right)}^{0.5} + \sqrt{x}}} \]
  5. Taylor expanded in x around 0

    \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \mathsf{sqrt.f64}\left(x\right)\right)\right) \]
  6. Step-by-step derivation
    1. Simplified99.6%

      \[\leadsto \frac{\color{blue}{1}}{{\left(x + 1\right)}^{0.5} + \sqrt{x}} \]
    2. Step-by-step derivation
      1. unpow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\left(\sqrt{x + 1}\right), \mathsf{sqrt.f64}\left(\color{blue}{x}\right)\right)\right) \]
      2. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(\left(x + 1\right)\right), \mathsf{sqrt.f64}\left(\color{blue}{x}\right)\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(\left(1 + x\right)\right), \mathsf{sqrt.f64}\left(x\right)\right)\right) \]
      4. +-lowering-+.f6499.6%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, x\right)\right), \mathsf{sqrt.f64}\left(x\right)\right)\right) \]
    3. Applied egg-rr99.6%

      \[\leadsto \frac{1}{\color{blue}{\sqrt{1 + x}} + \sqrt{x}} \]
    4. Add Preprocessing

    Alternative 2: 97.9% accurate, 2.0× speedup?

    \[\begin{array}{l} \\ {x}^{-0.5} \cdot 0.5 \end{array} \]
    (FPCore (x) :precision binary64 (* (pow x -0.5) 0.5))
    double code(double x) {
    	return pow(x, -0.5) * 0.5;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = (x ** (-0.5d0)) * 0.5d0
    end function
    
    public static double code(double x) {
    	return Math.pow(x, -0.5) * 0.5;
    }
    
    def code(x):
    	return math.pow(x, -0.5) * 0.5
    
    function code(x)
    	return Float64((x ^ -0.5) * 0.5)
    end
    
    function tmp = code(x)
    	tmp = (x ^ -0.5) * 0.5;
    end
    
    code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] * 0.5), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    {x}^{-0.5} \cdot 0.5
    \end{array}
    
    Derivation
    1. Initial program 6.7%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\frac{1}{16} \cdot \sqrt{\frac{1}{{x}^{3}}} + \frac{1}{2} \cdot \sqrt{x}\right)}{x}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\frac{1}{16} \cdot \sqrt{\frac{1}{{x}^{3}}} + \frac{1}{2} \cdot \sqrt{x}\right)\right), \color{blue}{x}\right) \]
    5. Simplified98.9%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \sqrt{\frac{1}{x}} + \left(\sqrt{x} \cdot 0.5 + 0.0625 \cdot \sqrt{\frac{1}{x \cdot \left(x \cdot x\right)}}\right)}{x}} \]
    6. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} \cdot \sqrt{x}\right)}, x\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{x} \cdot \frac{1}{2}\right), x\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\sqrt{x}\right), \frac{1}{2}\right), x\right) \]
      3. sqrt-lowering-sqrt.f6497.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(x\right), \frac{1}{2}\right), x\right) \]
    8. Simplified97.8%

      \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot 0.5}}{x} \]
    9. Step-by-step derivation
      1. div-invN/A

        \[\leadsto \left(\sqrt{x} \cdot \frac{1}{2}\right) \cdot \color{blue}{\frac{1}{x}} \]
      2. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sqrt{x}\right) \cdot \frac{\color{blue}{1}}{x} \]
      3. associate-*l*N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\left(\sqrt{x} \cdot \frac{1}{x}\right)} \]
      4. pow1/2N/A

        \[\leadsto \frac{1}{2} \cdot \left({x}^{\frac{1}{2}} \cdot \frac{\color{blue}{1}}{x}\right) \]
      5. inv-powN/A

        \[\leadsto \frac{1}{2} \cdot \left({x}^{\frac{1}{2}} \cdot {x}^{\color{blue}{-1}}\right) \]
      6. pow-prod-upN/A

        \[\leadsto \frac{1}{2} \cdot {x}^{\color{blue}{\left(\frac{1}{2} + -1\right)}} \]
      7. metadata-evalN/A

        \[\leadsto \frac{1}{2} \cdot {x}^{\frac{-1}{2}} \]
      8. metadata-evalN/A

        \[\leadsto \frac{1}{2} \cdot {x}^{\left(\frac{-1}{\color{blue}{2}}\right)} \]
      9. sqrt-pow1N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{{x}^{-1}} \]
      10. inv-powN/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{\frac{1}{x}} \]
      11. *-commutativeN/A

        \[\leadsto \sqrt{\frac{1}{x}} \cdot \color{blue}{\frac{1}{2}} \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{1}{x}}\right), \color{blue}{\frac{1}{2}}\right) \]
      13. inv-powN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{{x}^{-1}}\right), \frac{1}{2}\right) \]
      14. sqrt-pow1N/A

        \[\leadsto \mathsf{*.f64}\left(\left({x}^{\left(\frac{-1}{2}\right)}\right), \frac{1}{2}\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\left({x}^{\frac{-1}{2}}\right), \frac{1}{2}\right) \]
      16. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\left({x}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right), \frac{1}{2}\right) \]
      17. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(x, \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right), \frac{1}{2}\right) \]
      18. metadata-eval98.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \frac{1}{2}\right) \]
    10. Applied egg-rr98.2%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot 0.5} \]
    11. Add Preprocessing

    Alternative 3: 97.5% accurate, 2.0× speedup?

    \[\begin{array}{l} \\ \frac{0.5}{\sqrt{x}} \end{array} \]
    (FPCore (x) :precision binary64 (/ 0.5 (sqrt x)))
    double code(double x) {
    	return 0.5 / sqrt(x);
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = 0.5d0 / sqrt(x)
    end function
    
    public static double code(double x) {
    	return 0.5 / Math.sqrt(x);
    }
    
    def code(x):
    	return 0.5 / math.sqrt(x)
    
    function code(x)
    	return Float64(0.5 / sqrt(x))
    end
    
    function tmp = code(x)
    	tmp = 0.5 / sqrt(x);
    end
    
    code[x_] := N[(0.5 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{0.5}{\sqrt{x}}
    \end{array}
    
    Derivation
    1. Initial program 6.7%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\frac{1}{16} \cdot \sqrt{\frac{1}{{x}^{3}}} + \frac{1}{2} \cdot \sqrt{x}\right)}{x}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\frac{1}{16} \cdot \sqrt{\frac{1}{{x}^{3}}} + \frac{1}{2} \cdot \sqrt{x}\right)\right), \color{blue}{x}\right) \]
    5. Simplified98.9%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \sqrt{\frac{1}{x}} + \left(\sqrt{x} \cdot 0.5 + 0.0625 \cdot \sqrt{\frac{1}{x \cdot \left(x \cdot x\right)}}\right)}{x}} \]
    6. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(\frac{1}{2} \cdot \sqrt{x}\right)}, x\right) \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{x} \cdot \frac{1}{2}\right), x\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\left(\sqrt{x}\right), \frac{1}{2}\right), x\right) \]
      3. sqrt-lowering-sqrt.f6497.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(x\right), \frac{1}{2}\right), x\right) \]
    8. Simplified97.8%

      \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot 0.5}}{x} \]
    9. Step-by-step derivation
      1. div-invN/A

        \[\leadsto \left(\sqrt{x} \cdot \frac{1}{2}\right) \cdot \color{blue}{\frac{1}{x}} \]
      2. *-commutativeN/A

        \[\leadsto \left(\frac{1}{2} \cdot \sqrt{x}\right) \cdot \frac{\color{blue}{1}}{x} \]
      3. associate-*l*N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\left(\sqrt{x} \cdot \frac{1}{x}\right)} \]
      4. pow1/2N/A

        \[\leadsto \frac{1}{2} \cdot \left({x}^{\frac{1}{2}} \cdot \frac{\color{blue}{1}}{x}\right) \]
      5. inv-powN/A

        \[\leadsto \frac{1}{2} \cdot \left({x}^{\frac{1}{2}} \cdot {x}^{\color{blue}{-1}}\right) \]
      6. pow-prod-upN/A

        \[\leadsto \frac{1}{2} \cdot {x}^{\color{blue}{\left(\frac{1}{2} + -1\right)}} \]
      7. metadata-evalN/A

        \[\leadsto \frac{1}{2} \cdot {x}^{\frac{-1}{2}} \]
      8. metadata-evalN/A

        \[\leadsto \frac{1}{2} \cdot {x}^{\left(\frac{-1}{\color{blue}{2}}\right)} \]
      9. sqrt-pow1N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{{x}^{-1}} \]
      10. inv-powN/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{\frac{1}{x}} \]
      11. sqrt-divN/A

        \[\leadsto \frac{1}{2} \cdot \frac{\sqrt{1}}{\color{blue}{\sqrt{x}}} \]
      12. metadata-evalN/A

        \[\leadsto \frac{1}{2} \cdot \frac{1}{\sqrt{\color{blue}{x}}} \]
      13. un-div-invN/A

        \[\leadsto \frac{\frac{1}{2}}{\color{blue}{\sqrt{x}}} \]
      14. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{x}\right)}\right) \]
      15. sqrt-lowering-sqrt.f6497.8%

        \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(x\right)\right) \]
    10. Applied egg-rr97.8%

      \[\leadsto \color{blue}{\frac{0.5}{\sqrt{x}}} \]
    11. Add Preprocessing

    Alternative 4: 3.8% accurate, 15.8× speedup?

    \[\begin{array}{l} \\ \frac{x + \left(1 - x\right)}{1 + x \cdot \left(x \cdot -0.125\right)} \end{array} \]
    (FPCore (x) :precision binary64 (/ (+ x (- 1.0 x)) (+ 1.0 (* x (* x -0.125)))))
    double code(double x) {
    	return (x + (1.0 - x)) / (1.0 + (x * (x * -0.125)));
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = (x + (1.0d0 - x)) / (1.0d0 + (x * (x * (-0.125d0))))
    end function
    
    public static double code(double x) {
    	return (x + (1.0 - x)) / (1.0 + (x * (x * -0.125)));
    }
    
    def code(x):
    	return (x + (1.0 - x)) / (1.0 + (x * (x * -0.125)))
    
    function code(x)
    	return Float64(Float64(x + Float64(1.0 - x)) / Float64(1.0 + Float64(x * Float64(x * -0.125))))
    end
    
    function tmp = code(x)
    	tmp = (x + (1.0 - x)) / (1.0 + (x * (x * -0.125)));
    end
    
    code[x_] := N[(N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(x * N[(x * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{x + \left(1 - x\right)}{1 + x \cdot \left(x \cdot -0.125\right)}
    \end{array}
    
    Derivation
    1. Initial program 6.7%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\color{blue}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right), \color{blue}{\left(\sqrt{x + 1} + \sqrt{x}\right)}\right) \]
      3. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - \sqrt{x} \cdot \sqrt{x}\right), \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)\right) \]
      4. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - x\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      5. associate--l+N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 - x\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      10. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left(\sqrt{x + 1}\right), \color{blue}{\left(\sqrt{x}\right)}\right)\right) \]
      13. pow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left({\left(x + 1\right)}^{\frac{1}{2}}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
      14. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{1}{2}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
      15. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \left(\sqrt{x}\right)\right)\right) \]
      16. sqrt-lowering-sqrt.f649.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \mathsf{sqrt.f64}\left(x\right)\right)\right) \]
    4. Applied egg-rr9.1%

      \[\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{{\left(x + 1\right)}^{0.5} + \sqrt{x}}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \color{blue}{\left(1 + \left(\sqrt{x} + x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right)}\right) \]
    6. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\sqrt{x} + x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)}\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\sqrt{x}\right), \color{blue}{\left(x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)}\right)\right)\right) \]
      3. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \left(\color{blue}{x} \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f643.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{8}, \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
    7. Simplified3.8%

      \[\leadsto \frac{x + \left(1 - x\right)}{\color{blue}{1 + \left(\sqrt{x} + x \cdot \left(0.5 + -0.125 \cdot x\right)\right)}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\frac{-1}{8} \cdot {x}^{2}\right)}\right)\right) \]
    9. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \left(\frac{-1}{8} \cdot \left(x \cdot \color{blue}{x}\right)\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \left(\left(\frac{-1}{8} \cdot x\right) \cdot \color{blue}{x}\right)\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \left(x \cdot \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\frac{-1}{8}}\right)\right)\right)\right) \]
      6. *-lowering-*.f643.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{8}}\right)\right)\right)\right) \]
    10. Simplified3.8%

      \[\leadsto \frac{x + \left(1 - x\right)}{1 + \color{blue}{x \cdot \left(x \cdot -0.125\right)}} \]
    11. Add Preprocessing

    Alternative 5: 3.7% accurate, 18.6× speedup?

    \[\begin{array}{l} \\ \frac{x + \left(1 - x\right)}{x \cdot \left(x \cdot -0.125\right)} \end{array} \]
    (FPCore (x) :precision binary64 (/ (+ x (- 1.0 x)) (* x (* x -0.125))))
    double code(double x) {
    	return (x + (1.0 - x)) / (x * (x * -0.125));
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = (x + (1.0d0 - x)) / (x * (x * (-0.125d0)))
    end function
    
    public static double code(double x) {
    	return (x + (1.0 - x)) / (x * (x * -0.125));
    }
    
    def code(x):
    	return (x + (1.0 - x)) / (x * (x * -0.125))
    
    function code(x)
    	return Float64(Float64(x + Float64(1.0 - x)) / Float64(x * Float64(x * -0.125)))
    end
    
    function tmp = code(x)
    	tmp = (x + (1.0 - x)) / (x * (x * -0.125));
    end
    
    code[x_] := N[(N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(x * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{x + \left(1 - x\right)}{x \cdot \left(x \cdot -0.125\right)}
    \end{array}
    
    Derivation
    1. Initial program 6.7%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\color{blue}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right), \color{blue}{\left(\sqrt{x + 1} + \sqrt{x}\right)}\right) \]
      3. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - \sqrt{x} \cdot \sqrt{x}\right), \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)\right) \]
      4. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - x\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      5. associate--l+N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 - x\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      10. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left(\sqrt{x + 1}\right), \color{blue}{\left(\sqrt{x}\right)}\right)\right) \]
      13. pow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left({\left(x + 1\right)}^{\frac{1}{2}}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
      14. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{1}{2}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
      15. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \left(\sqrt{x}\right)\right)\right) \]
      16. sqrt-lowering-sqrt.f649.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \mathsf{sqrt.f64}\left(x\right)\right)\right) \]
    4. Applied egg-rr9.1%

      \[\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{{\left(x + 1\right)}^{0.5} + \sqrt{x}}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \color{blue}{\left(1 + \left(\sqrt{x} + x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right)}\right) \]
    6. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\sqrt{x} + x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)}\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\sqrt{x}\right), \color{blue}{\left(x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)}\right)\right)\right) \]
      3. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \left(\color{blue}{x} \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f643.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{8}, \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
    7. Simplified3.8%

      \[\leadsto \frac{x + \left(1 - x\right)}{\color{blue}{1 + \left(\sqrt{x} + x \cdot \left(0.5 + -0.125 \cdot x\right)\right)}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \color{blue}{\left(\frac{-1}{8} \cdot {x}^{2}\right)}\right) \]
    9. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\frac{-1}{8} \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
      2. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\left(\frac{-1}{8} \cdot x\right) \cdot \color{blue}{x}\right)\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(x \cdot \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\frac{-1}{8}}\right)\right)\right) \]
      6. *-lowering-*.f643.7%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{8}}\right)\right)\right) \]
    10. Simplified3.7%

      \[\leadsto \frac{x + \left(1 - x\right)}{\color{blue}{x \cdot \left(x \cdot -0.125\right)}} \]
    11. Add Preprocessing

    Alternative 6: 3.3% accurate, 41.0× speedup?

    \[\begin{array}{l} \\ \frac{-8}{x \cdot x} \end{array} \]
    (FPCore (x) :precision binary64 (/ -8.0 (* x x)))
    double code(double x) {
    	return -8.0 / (x * x);
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = (-8.0d0) / (x * x)
    end function
    
    public static double code(double x) {
    	return -8.0 / (x * x);
    }
    
    def code(x):
    	return -8.0 / (x * x)
    
    function code(x)
    	return Float64(-8.0 / Float64(x * x))
    end
    
    function tmp = code(x)
    	tmp = -8.0 / (x * x);
    end
    
    code[x_] := N[(-8.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{-8}{x \cdot x}
    \end{array}
    
    Derivation
    1. Initial program 6.7%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\color{blue}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right), \color{blue}{\left(\sqrt{x + 1} + \sqrt{x}\right)}\right) \]
      3. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - \sqrt{x} \cdot \sqrt{x}\right), \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)\right) \]
      4. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - x\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      5. associate--l+N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 - x\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      7. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 \cdot 1 - x \cdot 1\right)\right), \left(\color{blue}{\sqrt{x + 1}} + \sqrt{x}\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x \cdot 1\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      10. *-rgt-identityN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\sqrt{x + 1} + \sqrt{x}\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left(\sqrt{x + 1}\right), \color{blue}{\left(\sqrt{x}\right)}\right)\right) \]
      13. pow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left({\left(x + 1\right)}^{\frac{1}{2}}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
      14. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{1}{2}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right) \]
      15. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \left(\sqrt{x}\right)\right)\right) \]
      16. sqrt-lowering-sqrt.f649.1%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \mathsf{sqrt.f64}\left(x\right)\right)\right) \]
    4. Applied egg-rr9.1%

      \[\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{{\left(x + 1\right)}^{0.5} + \sqrt{x}}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \color{blue}{\left(1 + \left(\sqrt{x} + x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right)}\right) \]
    6. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \color{blue}{\left(\sqrt{x} + x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)}\right)\right) \]
      2. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\left(\sqrt{x}\right), \color{blue}{\left(x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)}\right)\right)\right) \]
      3. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \left(\color{blue}{x} \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right)\right)\right) \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)}\right)\right)\right)\right) \]
      5. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right)\right)\right)\right)\right) \]
      6. *-lowering-*.f643.8%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(1, \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\frac{-1}{8}, \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
    7. Simplified3.8%

      \[\leadsto \frac{x + \left(1 - x\right)}{\color{blue}{1 + \left(\sqrt{x} + x \cdot \left(0.5 + -0.125 \cdot x\right)\right)}} \]
    8. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-8}{{x}^{2}}} \]
    9. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(-8, \color{blue}{\left({x}^{2}\right)}\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(-8, \left(x \cdot \color{blue}{x}\right)\right) \]
      3. *-lowering-*.f643.4%

        \[\leadsto \mathsf{/.f64}\left(-8, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right) \]
    10. Simplified3.4%

      \[\leadsto \color{blue}{\frac{-8}{x \cdot x}} \]
    11. Add Preprocessing

    Alternative 7: 1.1% accurate, 41.0× speedup?

    \[\begin{array}{l} \\ x \cdot \left(x \cdot -0.125\right) \end{array} \]
    (FPCore (x) :precision binary64 (* x (* x -0.125)))
    double code(double x) {
    	return x * (x * -0.125);
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = x * (x * (-0.125d0))
    end function
    
    public static double code(double x) {
    	return x * (x * -0.125);
    }
    
    def code(x):
    	return x * (x * -0.125)
    
    function code(x)
    	return Float64(x * Float64(x * -0.125))
    end
    
    function tmp = code(x)
    	tmp = x * (x * -0.125);
    end
    
    code[x_] := N[(x * N[(x * -0.125), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    x \cdot \left(x \cdot -0.125\right)
    \end{array}
    
    Derivation
    1. Initial program 6.7%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \mathsf{\_.f64}\left(\color{blue}{\left(1 + x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)}, \mathsf{sqrt.f64}\left(x\right)\right) \]
    4. Step-by-step derivation
      1. +-lowering-+.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \left(x \cdot \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right), \mathsf{sqrt.f64}\left(\color{blue}{x}\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \left(\frac{1}{2} + \frac{-1}{8} \cdot x\right)\right)\right), \mathsf{sqrt.f64}\left(x\right)\right) \]
      3. +-lowering-+.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{-1}{8} \cdot x\right)\right)\right)\right), \mathsf{sqrt.f64}\left(x\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(x \cdot \frac{-1}{8}\right)\right)\right)\right), \mathsf{sqrt.f64}\left(x\right)\right) \]
      5. *-lowering-*.f641.1%

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \frac{-1}{8}\right)\right)\right)\right), \mathsf{sqrt.f64}\left(x\right)\right) \]
    5. Simplified1.1%

      \[\leadsto \color{blue}{\left(1 + x \cdot \left(0.5 + x \cdot -0.125\right)\right)} - \sqrt{x} \]
    6. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{-1}{8} \cdot {x}^{2}} \]
    7. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{-1}{8} \cdot \left(x \cdot \color{blue}{x}\right) \]
      2. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{8} \cdot x\right) \cdot \color{blue}{x} \]
      3. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(\frac{-1}{8} \cdot x\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{\left(\frac{-1}{8} \cdot x\right)}\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(x, \left(x \cdot \color{blue}{\frac{-1}{8}}\right)\right) \]
      6. *-lowering-*.f641.1%

        \[\leadsto \mathsf{*.f64}\left(x, \mathsf{*.f64}\left(x, \color{blue}{\frac{-1}{8}}\right)\right) \]
    8. Simplified1.1%

      \[\leadsto \color{blue}{x \cdot \left(x \cdot -0.125\right)} \]
    9. Add Preprocessing

    Developer Target 1: 99.6% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \frac{1}{\sqrt{x + 1} + \sqrt{x}} \end{array} \]
    (FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x))))
    double code(double x) {
    	return 1.0 / (sqrt((x + 1.0)) + sqrt(x));
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = 1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x))
    end function
    
    public static double code(double x) {
    	return 1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x));
    }
    
    def code(x):
    	return 1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x))
    
    function code(x)
    	return Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x)))
    end
    
    function tmp = code(x)
    	tmp = 1.0 / (sqrt((x + 1.0)) + sqrt(x));
    end
    
    code[x_] := N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{1}{\sqrt{x + 1} + \sqrt{x}}
    \end{array}
    

    Reproduce

    ?
    herbie shell --seed 2024161 
    (FPCore (x)
      :name "2sqrt (example 3.1)"
      :precision binary64
      :pre (and (> x 1.0) (< x 1e+308))
    
      :alt
      (! :herbie-platform default (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))
    
      (- (sqrt (+ x 1.0)) (sqrt x)))