2isqrt (example 3.6)

Percentage Accurate: 69.3% → 99.7%
Time: 11.5s
Alternatives: 8
Speedup: 2.0×

Specification

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

\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\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 8 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: 69.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.7× speedup?

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

\\
{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(x + 1\right) + \sqrt{x} \cdot \sqrt{x + 1}}
\end{array}
Derivation
  1. Initial program 69.7%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. *-un-lft-identity69.7%

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
    2. clear-num69.7%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
    3. associate-/r/69.7%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
    4. prod-diff69.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    5. *-un-lft-identity69.7%

      \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    6. fma-neg69.7%

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    7. *-un-lft-identity69.7%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    8. pow1/269.7%

      \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    9. pow-flip66.0%

      \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    10. metadata-eval66.0%

      \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    11. pow1/266.0%

      \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    12. pow-flip69.9%

      \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    13. +-commutative69.9%

      \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    14. metadata-eval69.9%

      \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
  3. Applied egg-rr69.9%

    \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
  4. Step-by-step derivation
    1. associate-+l-69.9%

      \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
    2. expm1-log1p69.9%

      \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
    3. expm1-def53.7%

      \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
    4. associate--l-53.7%

      \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
    5. fma-udef53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
    6. distribute-lft1-in53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
    7. metadata-eval53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
    8. mul0-lft53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
    9. metadata-eval53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
    10. expm1-def69.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
    11. expm1-log1p69.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
  5. Simplified69.9%

    \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
  6. Step-by-step derivation
    1. metadata-eval69.9%

      \[\leadsto {x}^{\color{blue}{\left(\frac{-1}{2}\right)}} - {\left(1 + x\right)}^{-0.5} \]
    2. sqrt-pow265.9%

      \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - {\left(1 + x\right)}^{-0.5} \]
    3. inv-pow65.9%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - {\left(1 + x\right)}^{-0.5} \]
    4. metadata-eval65.9%

      \[\leadsto \frac{1}{\sqrt{x}} - {\left(1 + x\right)}^{\color{blue}{\left(\frac{-1}{2}\right)}} \]
    5. sqrt-pow269.7%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{{\left(\sqrt{1 + x}\right)}^{-1}} \]
    6. inv-pow69.7%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{1 + x}}} \]
    7. clear-num69.7%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{1 + x}}{1}}} \]
    8. frac-sub69.7%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{\sqrt{1 + x}}{1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}}} \]
    9. *-un-lft-identity69.7%

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{1 + x}}{1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    10. /-rgt-identity69.7%

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    11. +-commutative69.7%

      \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    12. *-rgt-identity69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    13. /-rgt-identity69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{1 + x}}} \]
    14. sqrt-unprod69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(1 + x\right)}}} \]
    15. +-commutative69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
  7. Applied egg-rr69.7%

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
  8. Step-by-step derivation
    1. flip--70.1%

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    2. add-sqr-sqrt70.4%

      \[\leadsto \frac{\frac{\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    3. add-sqr-sqrt70.6%

      \[\leadsto \frac{\frac{\left(x + 1\right) - \color{blue}{x}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
  9. Applied egg-rr70.6%

    \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
  10. Step-by-step derivation
    1. *-un-lft-identity70.6%

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    2. sqrt-prod70.5%

      \[\leadsto \frac{1 \cdot \frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}{\color{blue}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    3. times-frac70.6%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \frac{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}} \]
    4. pow1/270.6%

      \[\leadsto \frac{1}{\color{blue}{{x}^{0.5}}} \cdot \frac{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
    5. pow-flip70.7%

      \[\leadsto \color{blue}{{x}^{\left(-0.5\right)}} \cdot \frac{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
    6. metadata-eval70.7%

      \[\leadsto {x}^{\color{blue}{-0.5}} \cdot \frac{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
    7. associate--l+70.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{\frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
  11. Applied egg-rr70.7%

    \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{\frac{x + \left(1 - x\right)}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}} \]
  12. Step-by-step derivation
    1. associate-/l/70.7%

      \[\leadsto {x}^{-0.5} \cdot \color{blue}{\frac{x + \left(1 - x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}} \]
    2. +-commutative70.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    3. sub-neg70.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 + \left(-x\right)\right)} + x}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    4. associate-+l+99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{1 + \left(\left(-x\right) + x\right)}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    5. neg-mul-199.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    6. *-lft-identity99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(-1 \cdot x + \color{blue}{1 \cdot x}\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    7. distribute-rgt-out99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + \color{blue}{x \cdot \left(-1 + 1\right)}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    8. metadata-eval99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    9. distribute-rgt-in99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
    10. rem-square-sqrt99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
    11. +-commutative99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(1 + x\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
    12. +-commutative99.7%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
  13. Simplified99.7%

    \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
  14. Final simplification99.7%

    \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(x + 1\right) + \sqrt{x} \cdot \sqrt{x + 1}} \]

Alternative 2: 99.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{x + 1}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\sqrt{x \cdot \left(x + 1\right)}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (+ x 1.0))))
   (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 0.0)
     (* 0.5 (pow x -1.5))
     (/ (/ 1.0 (+ (sqrt x) t_0)) (sqrt (* x (+ x 1.0)))))))
double code(double x) {
	double t_0 = sqrt((x + 1.0));
	double tmp;
	if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
		tmp = 0.5 * pow(x, -1.5);
	} else {
		tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (x + 1.0)));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((x + 1.0d0))
    if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 0.0d0) then
        tmp = 0.5d0 * (x ** (-1.5d0))
    else
        tmp = (1.0d0 / (sqrt(x) + t_0)) / sqrt((x * (x + 1.0d0)))
    end if
    code = tmp
end function
public static double code(double x) {
	double t_0 = Math.sqrt((x + 1.0));
	double tmp;
	if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
		tmp = 0.5 * Math.pow(x, -1.5);
	} else {
		tmp = (1.0 / (Math.sqrt(x) + t_0)) / Math.sqrt((x * (x + 1.0)));
	}
	return tmp;
}
def code(x):
	t_0 = math.sqrt((x + 1.0))
	tmp = 0
	if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 0.0:
		tmp = 0.5 * math.pow(x, -1.5)
	else:
		tmp = (1.0 / (math.sqrt(x) + t_0)) / math.sqrt((x * (x + 1.0)))
	return tmp
function code(x)
	t_0 = sqrt(Float64(x + 1.0))
	tmp = 0.0
	if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 0.0)
		tmp = Float64(0.5 * (x ^ -1.5));
	else
		tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / sqrt(Float64(x * Float64(x + 1.0))));
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = sqrt((x + 1.0));
	tmp = 0.0;
	if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0)
		tmp = 0.5 * (x ^ -1.5);
	else
		tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x * (x + 1.0)));
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x * N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\sqrt{x \cdot \left(x + 1\right)}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 0.0

    1. Initial program 38.3%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity38.3%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num38.3%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/38.3%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff38.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity38.3%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg38.3%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity38.3%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/238.3%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip30.1%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval30.1%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/230.1%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip38.3%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative38.3%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval38.3%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr38.3%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-38.3%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p38.3%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def5.0%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-5.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef5.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in5.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval5.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft5.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval5.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def38.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p38.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified38.3%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u64.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)\right)} \]
      2. expm1-udef38.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} - 1} \]
      3. pow-flip38.3%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\color{blue}{{x}^{\left(-3\right)}}}\right)} - 1 \]
      4. sqrt-pow138.3%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \color{blue}{{x}^{\left(\frac{-3}{2}\right)}}\right)} - 1 \]
      5. metadata-eval38.3%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\left(\frac{\color{blue}{-3}}{2}\right)}\right)} - 1 \]
      6. metadata-eval38.3%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\color{blue}{-1.5}}\right)} - 1 \]
    8. Applied egg-rr38.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)\right)} \]
      2. expm1-log1p100.0%

        \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
    10. Simplified100.0%

      \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]

    if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 97.8%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity97.8%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num97.8%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/97.8%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff97.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity97.8%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg97.8%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity97.8%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/297.8%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip98.2%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval98.2%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/298.2%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip98.3%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative98.3%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval98.3%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr98.3%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-98.3%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p98.3%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def97.4%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-97.4%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef97.4%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in97.4%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval97.4%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft97.4%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval97.4%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def98.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p98.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified98.3%

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Step-by-step derivation
      1. metadata-eval98.3%

        \[\leadsto {x}^{\color{blue}{\left(\frac{-1}{2}\right)}} - {\left(1 + x\right)}^{-0.5} \]
      2. sqrt-pow297.9%

        \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - {\left(1 + x\right)}^{-0.5} \]
      3. inv-pow97.9%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - {\left(1 + x\right)}^{-0.5} \]
      4. metadata-eval97.9%

        \[\leadsto \frac{1}{\sqrt{x}} - {\left(1 + x\right)}^{\color{blue}{\left(\frac{-1}{2}\right)}} \]
      5. sqrt-pow297.8%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{{\left(\sqrt{1 + x}\right)}^{-1}} \]
      6. inv-pow97.8%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{1 + x}}} \]
      7. clear-num97.8%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{1 + x}}{1}}} \]
      8. frac-sub97.8%

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{\sqrt{1 + x}}{1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}}} \]
      9. *-un-lft-identity97.8%

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{1 + x}}{1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
      10. /-rgt-identity97.8%

        \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
      11. +-commutative97.8%

        \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
      12. *-rgt-identity97.8%

        \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
      13. /-rgt-identity97.8%

        \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{1 + x}}} \]
      14. sqrt-unprod97.8%

        \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(1 + x\right)}}} \]
      15. +-commutative97.8%

        \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
    7. Applied egg-rr97.8%

      \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
    8. Step-by-step derivation
      1. flip--98.5%

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
      2. add-sqr-sqrt99.1%

        \[\leadsto \frac{\frac{\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
      3. add-sqr-sqrt99.5%

        \[\leadsto \frac{\frac{\left(x + 1\right) - \color{blue}{x}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    9. Applied egg-rr99.5%

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    10. Taylor expanded in x around 0 99.5%

      \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 0:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{x + 1}}}{\sqrt{x \cdot \left(x + 1\right)}}\\ \end{array} \]

Alternative 3: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 10^{-13}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ x 1.0)))) 1e-13)
   (* 0.5 (pow x -1.5))
   (- (pow x -0.5) (pow (+ x 1.0) -0.5))))
double code(double x) {
	double tmp;
	if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 1e-13) {
		tmp = 0.5 * pow(x, -1.5);
	} else {
		tmp = pow(x, -0.5) - pow((x + 1.0), -0.5);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((x + 1.0d0)))) <= 1d-13) then
        tmp = 0.5d0 * (x ** (-1.5d0))
    else
        tmp = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((x + 1.0)))) <= 1e-13) {
		tmp = 0.5 * Math.pow(x, -1.5);
	} else {
		tmp = Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((x + 1.0)))) <= 1e-13:
		tmp = 0.5 * math.pow(x, -1.5)
	else:
		tmp = math.pow(x, -0.5) - math.pow((x + 1.0), -0.5)
	return tmp
function code(x)
	tmp = 0.0
	if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(x + 1.0)))) <= 1e-13)
		tmp = Float64(0.5 * (x ^ -1.5));
	else
		tmp = Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (((1.0 / sqrt(x)) + (-1.0 / sqrt((x + 1.0)))) <= 1e-13)
		tmp = 0.5 * (x ^ -1.5);
	else
		tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e-13], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 10^{-13}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 1e-13

    1. Initial program 38.5%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity38.5%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num38.5%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/38.5%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff38.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity38.5%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg38.5%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity38.5%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/238.5%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip30.5%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval30.5%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/230.5%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip38.6%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative38.6%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval38.6%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr38.6%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-38.6%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p38.6%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def5.3%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-5.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef5.3%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in5.3%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval5.3%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft5.3%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval5.3%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def38.6%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p38.6%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified38.6%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u64.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)\right)} \]
      2. expm1-udef37.7%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} - 1} \]
      3. pow-flip37.7%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\color{blue}{{x}^{\left(-3\right)}}}\right)} - 1 \]
      4. sqrt-pow137.7%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \color{blue}{{x}^{\left(\frac{-3}{2}\right)}}\right)} - 1 \]
      5. metadata-eval37.7%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\left(\frac{\color{blue}{-3}}{2}\right)}\right)} - 1 \]
      6. metadata-eval37.7%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\color{blue}{-1.5}}\right)} - 1 \]
    8. Applied egg-rr37.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def99.3%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)\right)} \]
      2. expm1-log1p99.3%

        \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
    10. Simplified99.3%

      \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]

    if 1e-13 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.0%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity99.0%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.0%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.0%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity99.0%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg99.0%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity99.0%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/299.0%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip99.4%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval99.4%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/299.4%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip99.4%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative99.4%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval99.4%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr99.4%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-99.4%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p99.4%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def99.2%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-99.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef99.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in99.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval99.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft99.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval99.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def99.4%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p99.4%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 10^{-13}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\ \end{array} \]

Alternative 4: 99.5% accurate, 0.7× speedup?

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

\\
\frac{\frac{1 + x \cdot 0}{\left(x + 1\right) + \sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x}}
\end{array}
Derivation
  1. Initial program 69.7%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. *-un-lft-identity69.7%

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
    2. clear-num69.7%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
    3. associate-/r/69.7%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
    4. prod-diff69.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    5. *-un-lft-identity69.7%

      \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    6. fma-neg69.7%

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    7. *-un-lft-identity69.7%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    8. pow1/269.7%

      \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    9. pow-flip66.0%

      \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    10. metadata-eval66.0%

      \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    11. pow1/266.0%

      \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    12. pow-flip69.9%

      \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    13. +-commutative69.9%

      \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    14. metadata-eval69.9%

      \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
  3. Applied egg-rr69.9%

    \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
  4. Step-by-step derivation
    1. associate-+l-69.9%

      \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
    2. expm1-log1p69.9%

      \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
    3. expm1-def53.7%

      \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
    4. associate--l-53.7%

      \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
    5. fma-udef53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
    6. distribute-lft1-in53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
    7. metadata-eval53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
    8. mul0-lft53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
    9. metadata-eval53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
    10. expm1-def69.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
    11. expm1-log1p69.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
  5. Simplified69.9%

    \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
  6. Step-by-step derivation
    1. metadata-eval69.9%

      \[\leadsto {x}^{\color{blue}{\left(\frac{-1}{2}\right)}} - {\left(1 + x\right)}^{-0.5} \]
    2. sqrt-pow265.9%

      \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - {\left(1 + x\right)}^{-0.5} \]
    3. inv-pow65.9%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - {\left(1 + x\right)}^{-0.5} \]
    4. metadata-eval65.9%

      \[\leadsto \frac{1}{\sqrt{x}} - {\left(1 + x\right)}^{\color{blue}{\left(\frac{-1}{2}\right)}} \]
    5. sqrt-pow269.7%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{{\left(\sqrt{1 + x}\right)}^{-1}} \]
    6. inv-pow69.7%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{1 + x}}} \]
    7. clear-num69.7%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{1 + x}}{1}}} \]
    8. frac-sub69.7%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{\sqrt{1 + x}}{1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}}} \]
    9. *-un-lft-identity69.7%

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{1 + x}}{1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    10. /-rgt-identity69.7%

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    11. +-commutative69.7%

      \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    12. *-rgt-identity69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \frac{\sqrt{1 + x}}{1}} \]
    13. /-rgt-identity69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{1 + x}}} \]
    14. sqrt-unprod69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(1 + x\right)}}} \]
    15. +-commutative69.7%

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
  7. Applied egg-rr69.7%

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
  8. Step-by-step derivation
    1. flip--70.1%

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    2. add-sqr-sqrt70.4%

      \[\leadsto \frac{\frac{\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    3. add-sqr-sqrt70.6%

      \[\leadsto \frac{\frac{\left(x + 1\right) - \color{blue}{x}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
  9. Applied egg-rr70.6%

    \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
  10. Step-by-step derivation
    1. div-inv70.6%

      \[\leadsto \frac{\color{blue}{\left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    2. sqrt-prod70.5%

      \[\leadsto \frac{\left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\color{blue}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    3. times-frac70.6%

      \[\leadsto \color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}} \]
    4. associate--l+70.6%

      \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
  11. Applied egg-rr70.6%

    \[\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}} \]
  12. Step-by-step derivation
    1. associate-*l/70.6%

      \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}{\sqrt{x}}} \]
  13. Simplified99.5%

    \[\leadsto \color{blue}{\frac{\frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}}{\sqrt{x}}} \]
  14. Final simplification99.5%

    \[\leadsto \frac{\frac{1 + x \cdot 0}{\left(x + 1\right) + \sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x}} \]

Alternative 5: 98.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.7:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.7)
   (- (pow x -0.5) (/ 1.0 (+ 1.0 (* x 0.5))))
   (* 0.5 (pow x -1.5))))
double code(double x) {
	double tmp;
	if (x <= 1.7) {
		tmp = pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
	} else {
		tmp = 0.5 * pow(x, -1.5);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 1.7d0) then
        tmp = (x ** (-0.5d0)) - (1.0d0 / (1.0d0 + (x * 0.5d0)))
    else
        tmp = 0.5d0 * (x ** (-1.5d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 1.7) {
		tmp = Math.pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
	} else {
		tmp = 0.5 * Math.pow(x, -1.5);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.7:
		tmp = math.pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)))
	else:
		tmp = 0.5 * math.pow(x, -1.5)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.7)
		tmp = Float64((x ^ -0.5) - Float64(1.0 / Float64(1.0 + Float64(x * 0.5))));
	else
		tmp = Float64(0.5 * (x ^ -1.5));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.7)
		tmp = (x ^ -0.5) - (1.0 / (1.0 + (x * 0.5)));
	else
		tmp = 0.5 * (x ^ -1.5);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.7], N[(N[Power[x, -0.5], $MachinePrecision] - N[(1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.69999999999999996

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Taylor expanded in x around 0 99.0%

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{1 + 0.5 \cdot x}} \]
    3. Step-by-step derivation
      1. *-commutative99.0%

        \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{1 + \color{blue}{x \cdot 0.5}} \]
    4. Simplified99.0%

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{1 + x \cdot 0.5}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)\right)} - \frac{1}{1 + x \cdot 0.5} \]
      2. expm1-udef92.1%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)} - 1\right)} - \frac{1}{1 + x \cdot 0.5} \]
      3. pow1/292.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{x}^{0.5}}}\right)} - 1\right) - \frac{1}{1 + x \cdot 0.5} \]
      4. pow-flip92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{x}^{\left(-0.5\right)}}\right)} - 1\right) - \frac{1}{1 + x \cdot 0.5} \]
      5. metadata-eval92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left({x}^{\color{blue}{-0.5}}\right)} - 1\right) - \frac{1}{1 + x \cdot 0.5} \]
    6. Applied egg-rr92.1%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{-0.5}\right)} - 1\right)} - \frac{1}{1 + x \cdot 0.5} \]
    7. Step-by-step derivation
      1. expm1-def92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5}\right)\right)} - \frac{1}{1 + x \cdot 0.5} \]
      2. expm1-log1p99.4%

        \[\leadsto \color{blue}{{x}^{-0.5}} - \frac{1}{1 + x \cdot 0.5} \]
    8. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5}} - \frac{1}{1 + x \cdot 0.5} \]

    if 1.69999999999999996 < x

    1. Initial program 40.2%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity40.2%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num40.2%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/40.2%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff40.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity40.2%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg40.2%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity40.2%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/240.2%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip32.6%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval32.6%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/232.6%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip40.4%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative40.4%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval40.4%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr40.4%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-40.4%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p40.3%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def8.2%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-8.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def40.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p40.4%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified40.4%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u63.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)\right)} \]
      2. expm1-udef37.5%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} - 1} \]
      3. pow-flip37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\color{blue}{{x}^{\left(-3\right)}}}\right)} - 1 \]
      4. sqrt-pow137.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \color{blue}{{x}^{\left(\frac{-3}{2}\right)}}\right)} - 1 \]
      5. metadata-eval37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\left(\frac{\color{blue}{-3}}{2}\right)}\right)} - 1 \]
      6. metadata-eval37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\color{blue}{-1.5}}\right)} - 1 \]
    8. Applied egg-rr37.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def96.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)\right)} \]
      2. expm1-log1p96.8%

        \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
    10. Simplified96.8%

      \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.7:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \]

Alternative 6: 98.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.0) (+ (+ (pow x -0.5) (* x 0.5)) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
	} else {
		tmp = 0.5 * pow(x, -1.5);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 1.0d0) then
        tmp = ((x ** (-0.5d0)) + (x * 0.5d0)) + (-1.0d0)
    else
        tmp = 0.5d0 * (x ** (-1.5d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = (Math.pow(x, -0.5) + (x * 0.5)) + -1.0;
	} else {
		tmp = 0.5 * Math.pow(x, -1.5);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.0:
		tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0
	else:
		tmp = 0.5 * math.pow(x, -1.5)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.0)
		tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0);
	else
		tmp = Float64(0.5 * (x ^ -1.5));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.0)
		tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0;
	else
		tmp = 0.5 * (x ^ -1.5);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg99.6%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/299.6%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip100.0%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval100.0%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/2100.0%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip100.0%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative100.0%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p100.0%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def100.0%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot x + {x}^{-0.5}\right) - 1} \]

    if 1 < x

    1. Initial program 40.2%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity40.2%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num40.2%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/40.2%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff40.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity40.2%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg40.2%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity40.2%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/240.2%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip32.6%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval32.6%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/232.6%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip40.4%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative40.4%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval40.4%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr40.4%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-40.4%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p40.3%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def8.2%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-8.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def40.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p40.4%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified40.4%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u63.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)\right)} \]
      2. expm1-udef37.5%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} - 1} \]
      3. pow-flip37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\color{blue}{{x}^{\left(-3\right)}}}\right)} - 1 \]
      4. sqrt-pow137.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \color{blue}{{x}^{\left(\frac{-3}{2}\right)}}\right)} - 1 \]
      5. metadata-eval37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\left(\frac{\color{blue}{-3}}{2}\right)}\right)} - 1 \]
      6. metadata-eval37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\color{blue}{-1.5}}\right)} - 1 \]
    8. Applied egg-rr37.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def96.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)\right)} \]
      2. expm1-log1p96.8%

        \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
    10. Simplified96.8%

      \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \]

Alternative 7: 98.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.68) (+ (pow x -0.5) -1.0) (* 0.5 (pow x -1.5))))
double code(double x) {
	double tmp;
	if (x <= 0.68) {
		tmp = pow(x, -0.5) + -1.0;
	} else {
		tmp = 0.5 * pow(x, -1.5);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.68d0) then
        tmp = (x ** (-0.5d0)) + (-1.0d0)
    else
        tmp = 0.5d0 * (x ** (-1.5d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.68) {
		tmp = Math.pow(x, -0.5) + -1.0;
	} else {
		tmp = 0.5 * Math.pow(x, -1.5);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.68:
		tmp = math.pow(x, -0.5) + -1.0
	else:
		tmp = 0.5 * math.pow(x, -1.5)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.68)
		tmp = Float64((x ^ -0.5) + -1.0);
	else
		tmp = Float64(0.5 * (x ^ -1.5));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.68)
		tmp = (x ^ -0.5) + -1.0;
	else
		tmp = 0.5 * (x ^ -1.5);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.68], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + -1\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.680000000000000049

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg99.6%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/299.6%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip100.0%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval100.0%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/2100.0%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip100.0%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative100.0%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p100.0%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def100.0%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval100.0%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified100.0%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - 1} \]

    if 0.680000000000000049 < x

    1. Initial program 40.2%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity40.2%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num40.2%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/40.2%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff40.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity40.2%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg40.2%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity40.2%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. pow1/240.2%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. pow-flip32.6%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval32.6%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/232.6%

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip40.4%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative40.4%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval40.4%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    3. Applied egg-rr40.4%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. associate-+l-40.4%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p40.3%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      3. expm1-def8.2%

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-8.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
      6. distribute-lft1-in8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
      7. metadata-eval8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
      8. mul0-lft8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
      9. metadata-eval8.2%

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
      10. expm1-def40.3%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p40.4%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
    5. Simplified40.4%

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    7. Step-by-step derivation
      1. expm1-log1p-u63.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)\right)} \]
      2. expm1-udef37.5%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} - 1} \]
      3. pow-flip37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\color{blue}{{x}^{\left(-3\right)}}}\right)} - 1 \]
      4. sqrt-pow137.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \color{blue}{{x}^{\left(\frac{-3}{2}\right)}}\right)} - 1 \]
      5. metadata-eval37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\left(\frac{\color{blue}{-3}}{2}\right)}\right)} - 1 \]
      6. metadata-eval37.5%

        \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\color{blue}{-1.5}}\right)} - 1 \]
    8. Applied egg-rr37.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)} - 1} \]
    9. Step-by-step derivation
      1. expm1-def96.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)\right)} \]
      2. expm1-log1p96.8%

        \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
    10. Simplified96.8%

      \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \]

Alternative 8: 51.6% accurate, 2.0× speedup?

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

\\
0.5 \cdot {x}^{-1.5}
\end{array}
Derivation
  1. Initial program 69.7%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. *-un-lft-identity69.7%

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
    2. clear-num69.7%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
    3. associate-/r/69.7%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
    4. prod-diff69.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    5. *-un-lft-identity69.7%

      \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    6. fma-neg69.7%

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    7. *-un-lft-identity69.7%

      \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    8. pow1/269.7%

      \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    9. pow-flip66.0%

      \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    10. metadata-eval66.0%

      \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    11. pow1/266.0%

      \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    12. pow-flip69.9%

      \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    13. +-commutative69.9%

      \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    14. metadata-eval69.9%

      \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
  3. Applied egg-rr69.9%

    \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
  4. Step-by-step derivation
    1. associate-+l-69.9%

      \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
    2. expm1-log1p69.9%

      \[\leadsto {x}^{-0.5} - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
    3. expm1-def53.7%

      \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
    4. associate--l-53.7%

      \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
    5. fma-udef53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
    6. distribute-lft1-in53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}}\right)\right) \]
    7. metadata-eval53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
    8. mul0-lft53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0}\right)\right) \]
    9. metadata-eval53.7%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \color{blue}{1}\right) \]
    10. expm1-def69.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
    11. expm1-log1p69.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{{\left(1 + x\right)}^{-0.5}} \]
  5. Simplified69.9%

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

    \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
  7. Step-by-step derivation
    1. expm1-log1p-u34.7%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)\right)} \]
    2. expm1-udef21.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} - 1} \]
    3. pow-flip21.7%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \sqrt{\color{blue}{{x}^{\left(-3\right)}}}\right)} - 1 \]
    4. sqrt-pow121.8%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot \color{blue}{{x}^{\left(\frac{-3}{2}\right)}}\right)} - 1 \]
    5. metadata-eval21.8%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\left(\frac{\color{blue}{-3}}{2}\right)}\right)} - 1 \]
    6. metadata-eval21.8%

      \[\leadsto e^{\mathsf{log1p}\left(0.5 \cdot {x}^{\color{blue}{-1.5}}\right)} - 1 \]
  8. Applied egg-rr21.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)} - 1} \]
  9. Step-by-step derivation
    1. expm1-def51.7%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.5 \cdot {x}^{-1.5}\right)\right)} \]
    2. expm1-log1p51.7%

      \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
  10. Simplified51.7%

    \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
  11. Final simplification51.7%

    \[\leadsto 0.5 \cdot {x}^{-1.5} \]

Developer target: 99.0% accurate, 1.0× speedup?

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

\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}

Reproduce

?
herbie shell --seed 2023313 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

  :herbie-target
  (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))