2isqrt (example 3.6)

Percentage Accurate: 38.1% → 99.9%
Time: 9.3s
Alternatives: 5
Speedup: 2.0×

Specification

?
\[x > 1 \land x < 10^{+308}\]
\[\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 5 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: 38.1% 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.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 0:\\ \;\;\;\;{x}^{-1.5} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x + \left(-1 - x\right)}{x \cdot \left(-1 - x\right)}}{{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)))) 0.0)
   (* (pow x -1.5) 0.5)
   (/
    (/ (+ x (- -1.0 x)) (* x (- -1.0 x)))
    (+ (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)))) <= 0.0) {
		tmp = pow(x, -1.5) * 0.5;
	} else {
		tmp = ((x + (-1.0 - x)) / (x * (-1.0 - x))) / (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)))) <= 0.0d0) then
        tmp = (x ** (-1.5d0)) * 0.5d0
    else
        tmp = ((x + ((-1.0d0) - x)) / (x * ((-1.0d0) - x))) / ((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)))) <= 0.0) {
		tmp = Math.pow(x, -1.5) * 0.5;
	} else {
		tmp = ((x + (-1.0 - x)) / (x * (-1.0 - x))) / (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)))) <= 0.0:
		tmp = math.pow(x, -1.5) * 0.5
	else:
		tmp = ((x + (-1.0 - x)) / (x * (-1.0 - x))) / (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)))) <= 0.0)
		tmp = Float64((x ^ -1.5) * 0.5);
	else
		tmp = Float64(Float64(Float64(x + Float64(-1.0 - x)) / Float64(x * Float64(-1.0 - x))) / 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)))) <= 0.0)
		tmp = (x ^ -1.5) * 0.5;
	else
		tmp = ((x + (-1.0 - x)) / (x * (-1.0 - x))) / ((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], 0.0], N[(N[Power[x, -1.5], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(x + N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 34.7%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log5.0%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{\log \left(\frac{1}{\sqrt{x + 1}}\right)}} \]
      2. log-rec5.0%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{\color{blue}{-\log \left(\sqrt{x + 1}\right)}} \]
      3. pow1/25.0%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-\log \color{blue}{\left({\left(x + 1\right)}^{0.5}\right)}} \]
      4. log-pow5.0%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-\color{blue}{0.5 \cdot \log \left(x + 1\right)}} \]
      5. +-commutative5.0%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \log \color{blue}{\left(1 + x\right)}} \]
      6. log1p-define5.0%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} \]
    4. Applied egg-rr5.0%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
    5. Taylor expanded in x around inf 4.5%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - \left(e^{--0.5 \cdot \log \left(\frac{1}{x}\right)} + \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--r+5.7%

        \[\leadsto \color{blue}{\left(\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}\right) - \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)} \]
    7. Simplified99.2%

      \[\leadsto \color{blue}{\left(0.3125 \cdot \frac{{x}^{-0.5}}{{x}^{3}} + 0\right) - \mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)} \]
    8. Taylor expanded in x around inf 63.2%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    9. Step-by-step derivation
      1. exp-to-pow60.7%

        \[\leadsto 0.5 \cdot \sqrt{\frac{1}{\color{blue}{e^{\log x \cdot 3}}}} \]
      2. *-commutative60.7%

        \[\leadsto 0.5 \cdot \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \]
      3. exp-neg63.3%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \]
      4. distribute-lft-neg-in63.3%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\left(-3\right) \cdot \log x}}} \]
      5. metadata-eval63.3%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-3} \cdot \log x}} \]
      6. *-rgt-identity63.3%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\left(-3 \cdot \log x\right) \cdot 1}}} \]
      7. *-rgt-identity63.3%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-3 \cdot \log x}}} \]
      8. *-commutative63.3%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\log x \cdot -3}}} \]
      9. exp-to-pow65.9%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-3}}} \]
      10. unpow1/265.9%

        \[\leadsto 0.5 \cdot \color{blue}{{\left({x}^{-3}\right)}^{0.5}} \]
      11. exp-to-pow63.3%

        \[\leadsto 0.5 \cdot {\color{blue}{\left(e^{\log x \cdot -3}\right)}}^{0.5} \]
      12. *-commutative63.3%

        \[\leadsto 0.5 \cdot {\left(e^{\color{blue}{-3 \cdot \log x}}\right)}^{0.5} \]
      13. exp-prod93.0%

        \[\leadsto 0.5 \cdot \color{blue}{e^{\left(-3 \cdot \log x\right) \cdot 0.5}} \]
      14. *-commutative93.0%

        \[\leadsto 0.5 \cdot e^{\color{blue}{0.5 \cdot \left(-3 \cdot \log x\right)}} \]
      15. associate-*r*93.0%

        \[\leadsto 0.5 \cdot e^{\color{blue}{\left(0.5 \cdot -3\right) \cdot \log x}} \]
      16. metadata-eval93.0%

        \[\leadsto 0.5 \cdot e^{\color{blue}{-1.5} \cdot \log x} \]
      17. *-rgt-identity93.0%

        \[\leadsto 0.5 \cdot e^{\color{blue}{\left(-1.5 \cdot \log x\right) \cdot 1}} \]
      18. *-rgt-identity93.0%

        \[\leadsto 0.5 \cdot e^{\color{blue}{-1.5 \cdot \log x}} \]
      19. *-commutative93.0%

        \[\leadsto 0.5 \cdot e^{\color{blue}{\log x \cdot -1.5}} \]
      20. exp-to-pow100.0%

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

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

    if 0.0 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64)))))

    1. Initial program 60.2%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--59.9%

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

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

        \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{x} \cdot \sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      4. add-sqr-sqrt60.8%

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      6. metadata-eval62.1%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      7. add-sqr-sqrt62.3%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      9. inv-pow62.3%

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{{\left(\sqrt{x}\right)}^{-1}} + \frac{1}{\sqrt{x + 1}}} \]
      10. sqrt-pow262.3%

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{{x}^{\left(\frac{-1}{2}\right)}} + \frac{1}{\sqrt{x + 1}}} \]
      11. metadata-eval62.3%

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
      12. inv-pow62.3%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{-0.5} + \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}} \]
      14. +-commutative62.3%

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{-0.5} + {\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}} \]
      15. metadata-eval62.3%

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{-0.5} + {\left(1 + x\right)}^{\color{blue}{-0.5}}} \]
    4. Applied egg-rr62.3%

      \[\leadsto \color{blue}{\frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}} \]
    5. Step-by-step derivation
      1. frac-2neg62.3%

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{-1}{-\left(1 + x\right)}}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
      2. metadata-eval62.3%

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

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

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

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

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

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

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

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

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

Alternative 2: 99.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ 0.3125 \cdot {x}^{-3.5} - \mathsf{fma}\left(0.375, {x}^{-2.5}, -0.5 \cdot {x}^{-1.5}\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (- (* 0.3125 (pow x -3.5)) (fma 0.375 (pow x -2.5) (* -0.5 (pow x -1.5)))))
double code(double x) {
	return (0.3125 * pow(x, -3.5)) - fma(0.375, pow(x, -2.5), (-0.5 * pow(x, -1.5)));
}
function code(x)
	return Float64(Float64(0.3125 * (x ^ -3.5)) - fma(0.375, (x ^ -2.5), Float64(-0.5 * (x ^ -1.5))))
end
code[x_] := N[(N[(0.3125 * N[Power[x, -3.5], $MachinePrecision]), $MachinePrecision] - N[(0.375 * N[Power[x, -2.5], $MachinePrecision] + N[(-0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.3125 \cdot {x}^{-3.5} - \mathsf{fma}\left(0.375, {x}^{-2.5}, -0.5 \cdot {x}^{-1.5}\right)
\end{array}
Derivation
  1. Initial program 35.8%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-exp-log7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{\log \left(\frac{1}{\sqrt{x + 1}}\right)}} \]
    2. log-rec7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - e^{\color{blue}{-\log \left(\sqrt{x + 1}\right)}} \]
    3. pow1/27.2%

      \[\leadsto \frac{1}{\sqrt{x}} - e^{-\log \color{blue}{\left({\left(x + 1\right)}^{0.5}\right)}} \]
    4. log-pow7.2%

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

      \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \log \color{blue}{\left(1 + x\right)}} \]
    6. log1p-define7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} \]
  4. Applied egg-rr7.2%

    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
  5. Taylor expanded in x around inf 6.3%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - \left(e^{--0.5 \cdot \log \left(\frac{1}{x}\right)} + \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)\right)} \]
  6. Step-by-step derivation
    1. associate--r+7.4%

      \[\leadsto \color{blue}{\left(\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}\right) - \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)} \]
  7. Simplified98.6%

    \[\leadsto \color{blue}{\left(0.3125 \cdot \frac{{x}^{-0.5}}{{x}^{3}} + 0\right) - \mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)} \]
  8. Step-by-step derivation
    1. sub-neg98.6%

      \[\leadsto \color{blue}{\left(0.3125 \cdot \frac{{x}^{-0.5}}{{x}^{3}} + 0\right) + \left(-\mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)\right)} \]
    2. +-rgt-identity98.6%

      \[\leadsto \color{blue}{0.3125 \cdot \frac{{x}^{-0.5}}{{x}^{3}}} + \left(-\mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)\right) \]
    3. pow-div98.6%

      \[\leadsto 0.3125 \cdot \color{blue}{{x}^{\left(-0.5 - 3\right)}} + \left(-\mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)\right) \]
    4. metadata-eval98.6%

      \[\leadsto 0.3125 \cdot {x}^{\color{blue}{-3.5}} + \left(-\mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)\right) \]
    5. pow-pow99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} + \left(-\mathsf{fma}\left(-0.5, \color{blue}{{x}^{\left(-0.5 \cdot 3\right)}}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)\right) \]
    6. metadata-eval99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} + \left(-\mathsf{fma}\left(-0.5, {x}^{\color{blue}{-1.5}}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)\right) \]
    7. associate-/l*99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} + \left(-\mathsf{fma}\left(-0.5, {x}^{-1.5}, \color{blue}{0.375 \cdot \frac{{x}^{-0.5}}{{x}^{2}}}\right)\right) \]
    8. pow-div99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} + \left(-\mathsf{fma}\left(-0.5, {x}^{-1.5}, 0.375 \cdot \color{blue}{{x}^{\left(-0.5 - 2\right)}}\right)\right) \]
    9. metadata-eval99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} + \left(-\mathsf{fma}\left(-0.5, {x}^{-1.5}, 0.375 \cdot {x}^{\color{blue}{-2.5}}\right)\right) \]
  9. Applied egg-rr99.4%

    \[\leadsto \color{blue}{0.3125 \cdot {x}^{-3.5} + \left(-\mathsf{fma}\left(-0.5, {x}^{-1.5}, 0.375 \cdot {x}^{-2.5}\right)\right)} \]
  10. Step-by-step derivation
    1. sub-neg99.4%

      \[\leadsto \color{blue}{0.3125 \cdot {x}^{-3.5} - \mathsf{fma}\left(-0.5, {x}^{-1.5}, 0.375 \cdot {x}^{-2.5}\right)} \]
    2. fma-define99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} - \color{blue}{\left(-0.5 \cdot {x}^{-1.5} + 0.375 \cdot {x}^{-2.5}\right)} \]
    3. +-commutative99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} - \color{blue}{\left(0.375 \cdot {x}^{-2.5} + -0.5 \cdot {x}^{-1.5}\right)} \]
    4. fma-define99.4%

      \[\leadsto 0.3125 \cdot {x}^{-3.5} - \color{blue}{\mathsf{fma}\left(0.375, {x}^{-2.5}, -0.5 \cdot {x}^{-1.5}\right)} \]
  11. Simplified99.4%

    \[\leadsto \color{blue}{0.3125 \cdot {x}^{-3.5} - \mathsf{fma}\left(0.375, {x}^{-2.5}, -0.5 \cdot {x}^{-1.5}\right)} \]
  12. Add Preprocessing

Alternative 3: 98.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(-0.375, {x}^{-1.5}, 0.5 \cdot \sqrt{\frac{1}{x}}\right)}{x} \end{array} \]
(FPCore (x)
 :precision binary64
 (/ (fma -0.375 (pow x -1.5) (* 0.5 (sqrt (/ 1.0 x)))) x))
double code(double x) {
	return fma(-0.375, pow(x, -1.5), (0.5 * sqrt((1.0 / x)))) / x;
}
function code(x)
	return Float64(fma(-0.375, (x ^ -1.5), Float64(0.5 * sqrt(Float64(1.0 / x)))) / x)
end
code[x_] := N[(N[(-0.375 * N[Power[x, -1.5], $MachinePrecision] + N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(-0.375, {x}^{-1.5}, 0.5 \cdot \sqrt{\frac{1}{x}}\right)}{x}
\end{array}
Derivation
  1. Initial program 35.8%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-exp-log7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{\log \left(\frac{1}{\sqrt{x + 1}}\right)}} \]
    2. log-rec7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - e^{\color{blue}{-\log \left(\sqrt{x + 1}\right)}} \]
    3. pow1/27.2%

      \[\leadsto \frac{1}{\sqrt{x}} - e^{-\log \color{blue}{\left({\left(x + 1\right)}^{0.5}\right)}} \]
    4. log-pow7.2%

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

      \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \log \color{blue}{\left(1 + x\right)}} \]
    6. log1p-define7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} \]
  4. Applied egg-rr7.2%

    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
  5. Taylor expanded in x around inf 6.3%

    \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - \left(e^{--0.5 \cdot \log \left(\frac{1}{x}\right)} + \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)\right)} \]
  6. Step-by-step derivation
    1. associate--r+7.4%

      \[\leadsto \color{blue}{\left(\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}\right) - \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)} \]
  7. Simplified98.6%

    \[\leadsto \color{blue}{\left(0.3125 \cdot \frac{{x}^{-0.5}}{{x}^{3}} + 0\right) - \mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)} \]
  8. Taylor expanded in x around inf 98.8%

    \[\leadsto \color{blue}{\frac{-0.375 \cdot \sqrt{\frac{1}{{x}^{3}}} - -0.5 \cdot \sqrt{\frac{1}{x}}}{x}} \]
  9. Step-by-step derivation
    1. Simplified98.8%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-0.375, {x}^{-1.5}, 0.5 \cdot \sqrt{\frac{1}{x}}\right)}{x}} \]
    2. Add Preprocessing

    Alternative 4: 97.9% accurate, 2.0× speedup?

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

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log7.2%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{\log \left(\frac{1}{\sqrt{x + 1}}\right)}} \]
      2. log-rec7.2%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{\color{blue}{-\log \left(\sqrt{x + 1}\right)}} \]
      3. pow1/27.2%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-\log \color{blue}{\left({\left(x + 1\right)}^{0.5}\right)}} \]
      4. log-pow7.2%

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

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \log \color{blue}{\left(1 + x\right)}} \]
      6. log1p-define7.2%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} \]
    4. Applied egg-rr7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
    5. Taylor expanded in x around inf 6.3%

      \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - \left(e^{--0.5 \cdot \log \left(\frac{1}{x}\right)} + \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)\right)} \]
    6. Step-by-step derivation
      1. associate--r+7.4%

        \[\leadsto \color{blue}{\left(\left(\sqrt{\frac{1}{x}} + 0.3125 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{3}}\right) - e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}\right) - \left(-0.5 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{x} + 0.375 \cdot \frac{e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}}{{x}^{2}}\right)} \]
    7. Simplified98.6%

      \[\leadsto \color{blue}{\left(0.3125 \cdot \frac{{x}^{-0.5}}{{x}^{3}} + 0\right) - \mathsf{fma}\left(-0.5, {\left({x}^{-0.5}\right)}^{3}, \frac{0.375 \cdot {x}^{-0.5}}{{x}^{2}}\right)} \]
    8. Taylor expanded in x around inf 63.1%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    9. Step-by-step derivation
      1. exp-to-pow60.6%

        \[\leadsto 0.5 \cdot \sqrt{\frac{1}{\color{blue}{e^{\log x \cdot 3}}}} \]
      2. *-commutative60.6%

        \[\leadsto 0.5 \cdot \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \]
      3. exp-neg63.1%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \]
      4. distribute-lft-neg-in63.1%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\left(-3\right) \cdot \log x}}} \]
      5. metadata-eval63.1%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-3} \cdot \log x}} \]
      6. *-rgt-identity63.1%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\left(-3 \cdot \log x\right) \cdot 1}}} \]
      7. *-rgt-identity63.1%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-3 \cdot \log x}}} \]
      8. *-commutative63.1%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\log x \cdot -3}}} \]
      9. exp-to-pow65.6%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-3}}} \]
      10. unpow1/265.6%

        \[\leadsto 0.5 \cdot \color{blue}{{\left({x}^{-3}\right)}^{0.5}} \]
      11. exp-to-pow63.1%

        \[\leadsto 0.5 \cdot {\color{blue}{\left(e^{\log x \cdot -3}\right)}}^{0.5} \]
      12. *-commutative63.1%

        \[\leadsto 0.5 \cdot {\left(e^{\color{blue}{-3 \cdot \log x}}\right)}^{0.5} \]
      13. exp-prod91.6%

        \[\leadsto 0.5 \cdot \color{blue}{e^{\left(-3 \cdot \log x\right) \cdot 0.5}} \]
      14. *-commutative91.6%

        \[\leadsto 0.5 \cdot e^{\color{blue}{0.5 \cdot \left(-3 \cdot \log x\right)}} \]
      15. associate-*r*91.6%

        \[\leadsto 0.5 \cdot e^{\color{blue}{\left(0.5 \cdot -3\right) \cdot \log x}} \]
      16. metadata-eval91.6%

        \[\leadsto 0.5 \cdot e^{\color{blue}{-1.5} \cdot \log x} \]
      17. *-rgt-identity91.6%

        \[\leadsto 0.5 \cdot e^{\color{blue}{\left(-1.5 \cdot \log x\right) \cdot 1}} \]
      18. *-rgt-identity91.6%

        \[\leadsto 0.5 \cdot e^{\color{blue}{-1.5 \cdot \log x}} \]
      19. *-commutative91.6%

        \[\leadsto 0.5 \cdot e^{\color{blue}{\log x \cdot -1.5}} \]
      20. exp-to-pow98.2%

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

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

      \[\leadsto {x}^{-1.5} \cdot 0.5 \]
    12. Add Preprocessing

    Alternative 5: 35.2% accurate, 209.0× speedup?

    \[\begin{array}{l} \\ 0 \end{array} \]
    (FPCore (x) :precision binary64 0.0)
    double code(double x) {
    	return 0.0;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = 0.0d0
    end function
    
    public static double code(double x) {
    	return 0.0;
    }
    
    def code(x):
    	return 0.0
    
    function code(x)
    	return 0.0
    end
    
    function tmp = code(x)
    	tmp = 0.0;
    end
    
    code[x_] := 0.0
    
    \begin{array}{l}
    
    \\
    0
    \end{array}
    
    Derivation
    1. Initial program 35.8%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log7.2%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{\log \left(\frac{1}{\sqrt{x + 1}}\right)}} \]
      2. log-rec7.2%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{\color{blue}{-\log \left(\sqrt{x + 1}\right)}} \]
      3. pow1/27.2%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-\log \color{blue}{\left({\left(x + 1\right)}^{0.5}\right)}} \]
      4. log-pow7.2%

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

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \log \color{blue}{\left(1 + x\right)}} \]
      6. log1p-define7.2%

        \[\leadsto \frac{1}{\sqrt{x}} - e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} \]
    4. Applied egg-rr7.2%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
    5. Taylor expanded in x around inf 4.6%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}} - e^{--0.5 \cdot \log \left(\frac{1}{x}\right)}} \]
    6. Step-by-step derivation
      1. distribute-lft-neg-in4.6%

        \[\leadsto \sqrt{\frac{1}{x}} - e^{\color{blue}{\left(--0.5\right) \cdot \log \left(\frac{1}{x}\right)}} \]
      2. metadata-eval4.6%

        \[\leadsto \sqrt{\frac{1}{x}} - e^{\color{blue}{0.5} \cdot \log \left(\frac{1}{x}\right)} \]
      3. *-commutative4.6%

        \[\leadsto \sqrt{\frac{1}{x}} - e^{\color{blue}{\log \left(\frac{1}{x}\right) \cdot 0.5}} \]
      4. exp-to-pow33.0%

        \[\leadsto \sqrt{\frac{1}{x}} - \color{blue}{{\left(\frac{1}{x}\right)}^{0.5}} \]
      5. unpow1/233.4%

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

        \[\leadsto \color{blue}{0} \]
    7. Simplified33.4%

      \[\leadsto \color{blue}{0} \]
    8. Add Preprocessing

    Developer Target 1: 98.4% 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 2024150 
    (FPCore (x)
      :name "2isqrt (example 3.6)"
      :precision binary64
      :pre (and (> x 1.0) (< x 1e+308))
    
      :alt
      (! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))
    
      (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))