2isqrt (example 3.6)

Percentage Accurate: 38.8% → 98.4%
Time: 9.7s
Alternatives: 4
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 4 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.8% 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: 98.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} + \color{blue}{\frac{-1}{\sqrt{x + 1}}} \]
    6. metadata-eval27.5%

      \[\leadsto {x}^{-0.5} + \frac{\color{blue}{-1}}{\sqrt{x + 1}} \]
    7. +-commutative27.5%

      \[\leadsto {x}^{-0.5} + \frac{-1}{\sqrt{\color{blue}{1 + x}}} \]
  4. Applied egg-rr27.5%

    \[\leadsto \color{blue}{{x}^{-0.5} + \frac{-1}{\sqrt{1 + x}}} \]
  5. Step-by-step derivation
    1. *-rgt-identity27.5%

      \[\leadsto {x}^{-0.5} + \color{blue}{\frac{-1}{\sqrt{1 + x}} \cdot 1} \]
    2. cancel-sign-sub27.5%

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

      \[\leadsto {x}^{-0.5} - \color{blue}{\left(-\frac{-1}{\sqrt{1 + x}} \cdot 1\right)} \]
    4. *-rgt-identity27.5%

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

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{--1}{\sqrt{1 + x}}} \]
    6. metadata-eval27.5%

      \[\leadsto {x}^{-0.5} - \frac{\color{blue}{1}}{\sqrt{1 + x}} \]
    7. unpow1/227.5%

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{{\left(1 + x\right)}^{0.5}}} \]
    8. exp-to-pow7.5%

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

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

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

      \[\leadsto {x}^{-0.5} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
    12. *-commutative7.5%

      \[\leadsto {x}^{-0.5} - e^{-\color{blue}{\mathsf{log1p}\left(x\right) \cdot 0.5}} \]
    13. distribute-rgt-neg-in7.5%

      \[\leadsto {x}^{-0.5} - e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \left(-0.5\right)}} \]
    14. log1p-undefine7.5%

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

      \[\leadsto {x}^{-0.5} - e^{\log \left(1 + x\right) \cdot \color{blue}{-0.5}} \]
    16. exp-to-pow35.0%

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

    \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
  7. Step-by-step derivation
    1. flip--35.0%

      \[\leadsto \color{blue}{\frac{{x}^{-0.5} \cdot {x}^{-0.5} - {\left(1 + x\right)}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}} \]
    2. pow-prod-up22.3%

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

      \[\leadsto \frac{{x}^{\color{blue}{-1}} - {\left(1 + x\right)}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    4. inv-pow21.9%

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{1}{1 + x}}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    8. div-inv35.1%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \left(1 + x\right) - x \cdot 1}{x \cdot \left(1 + x\right)}} \cdot \frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    10. frac-times36.9%

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

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

    \[\leadsto \color{blue}{\frac{\left(\left(1 + x\right) - x \cdot 1\right) \cdot 1}{\left(x \cdot \left(1 + x\right)\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}} \]
  9. Step-by-step derivation
    1. *-rgt-identity36.9%

      \[\leadsto \frac{\color{blue}{\left(1 + x\right) - x \cdot 1}}{\left(x \cdot \left(1 + x\right)\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} \]
    2. *-rgt-identity36.9%

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)\right)}} \]
  10. Simplified98.4%

    \[\leadsto \color{blue}{\frac{1}{x \cdot \left(\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)\right)}} \]
  11. Step-by-step derivation
    1. distribute-lft-in98.4%

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

      \[\leadsto \frac{1}{x \cdot \left(\left(1 + x\right) \cdot {x}^{-0.5} + \color{blue}{{\left(1 + x\right)}^{1}} \cdot {\left(1 + x\right)}^{-0.5}\right)} \]
    3. pow-prod-up98.4%

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

      \[\leadsto \frac{1}{x \cdot \left(\left(1 + x\right) \cdot {x}^{-0.5} + {\left(1 + x\right)}^{\color{blue}{0.5}}\right)} \]
    5. pow1/298.4%

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

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

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

    \[\leadsto \frac{1}{x \cdot \left(\left(1 + x\right) \cdot {x}^{-0.5}\right) + x \cdot \sqrt{1 + x}} \]
  14. Add Preprocessing

Alternative 2: 98.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} + \color{blue}{\frac{-1}{\sqrt{x + 1}}} \]
    6. metadata-eval27.5%

      \[\leadsto {x}^{-0.5} + \frac{\color{blue}{-1}}{\sqrt{x + 1}} \]
    7. +-commutative27.5%

      \[\leadsto {x}^{-0.5} + \frac{-1}{\sqrt{\color{blue}{1 + x}}} \]
  4. Applied egg-rr27.5%

    \[\leadsto \color{blue}{{x}^{-0.5} + \frac{-1}{\sqrt{1 + x}}} \]
  5. Step-by-step derivation
    1. *-rgt-identity27.5%

      \[\leadsto {x}^{-0.5} + \color{blue}{\frac{-1}{\sqrt{1 + x}} \cdot 1} \]
    2. cancel-sign-sub27.5%

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

      \[\leadsto {x}^{-0.5} - \color{blue}{\left(-\frac{-1}{\sqrt{1 + x}} \cdot 1\right)} \]
    4. *-rgt-identity27.5%

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

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{--1}{\sqrt{1 + x}}} \]
    6. metadata-eval27.5%

      \[\leadsto {x}^{-0.5} - \frac{\color{blue}{1}}{\sqrt{1 + x}} \]
    7. unpow1/227.5%

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{{\left(1 + x\right)}^{0.5}}} \]
    8. exp-to-pow7.5%

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

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

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

      \[\leadsto {x}^{-0.5} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
    12. *-commutative7.5%

      \[\leadsto {x}^{-0.5} - e^{-\color{blue}{\mathsf{log1p}\left(x\right) \cdot 0.5}} \]
    13. distribute-rgt-neg-in7.5%

      \[\leadsto {x}^{-0.5} - e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \left(-0.5\right)}} \]
    14. log1p-undefine7.5%

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

      \[\leadsto {x}^{-0.5} - e^{\log \left(1 + x\right) \cdot \color{blue}{-0.5}} \]
    16. exp-to-pow35.0%

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

    \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
  7. Step-by-step derivation
    1. flip--35.0%

      \[\leadsto \color{blue}{\frac{{x}^{-0.5} \cdot {x}^{-0.5} - {\left(1 + x\right)}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}} \]
    2. pow-prod-up22.3%

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

      \[\leadsto \frac{{x}^{\color{blue}{-1}} - {\left(1 + x\right)}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    4. inv-pow21.9%

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{1}{1 + x}}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    8. div-inv35.1%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \left(1 + x\right) - x \cdot 1}{x \cdot \left(1 + x\right)}} \cdot \frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    10. frac-times36.9%

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

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

    \[\leadsto \color{blue}{\frac{\left(\left(1 + x\right) - x \cdot 1\right) \cdot 1}{\left(x \cdot \left(1 + x\right)\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}} \]
  9. Step-by-step derivation
    1. *-rgt-identity36.9%

      \[\leadsto \frac{\color{blue}{\left(1 + x\right) - x \cdot 1}}{\left(x \cdot \left(1 + x\right)\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} \]
    2. *-rgt-identity36.9%

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot \left(\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)\right)}} \]
  10. Simplified98.4%

    \[\leadsto \color{blue}{\frac{1}{x \cdot \left(\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)\right)}} \]
  11. Step-by-step derivation
    1. distribute-lft-in98.4%

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

      \[\leadsto \frac{1}{x \cdot \left(\left(1 + x\right) \cdot {x}^{-0.5} + \color{blue}{{\left(1 + x\right)}^{1}} \cdot {\left(1 + x\right)}^{-0.5}\right)} \]
    3. pow-prod-up98.4%

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

      \[\leadsto \frac{1}{x \cdot \left(\left(1 + x\right) \cdot {x}^{-0.5} + {\left(1 + x\right)}^{\color{blue}{0.5}}\right)} \]
    5. pow1/298.4%

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

    \[\leadsto \frac{1}{x \cdot \color{blue}{\left(\left(1 + x\right) \cdot {x}^{-0.5} + \sqrt{1 + x}\right)}} \]
  13. Add Preprocessing

Alternative 3: 97.7% 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 34.9%

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{{x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}}\right)}^{3} \]
    6. inv-pow27.5%

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

      \[\leadsto {\left(\sqrt[3]{{x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}}\right)}^{3} \]
    8. +-commutative35.0%

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

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

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

    \[\leadsto {\color{blue}{\left(\sqrt{\frac{1}{x}} \cdot \sqrt[3]{0.5}\right)}}^{3} \]
  6. Step-by-step derivation
    1. unpow-prod-down96.7%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot 1}{\frac{x}{1} \cdot \sqrt{x}}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    8. /-rgt-identity95.5%

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

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

      \[\leadsto \frac{1 \cdot 1}{\color{blue}{\sqrt{x \cdot x}} \cdot \sqrt{x}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    11. sqrt-prod65.3%

      \[\leadsto \frac{1 \cdot 1}{\color{blue}{\sqrt{\left(x \cdot x\right) \cdot x}}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    12. unpow365.3%

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

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

      \[\leadsto \frac{\color{blue}{\sqrt{1}}}{\sqrt{{x}^{3}}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    15. sqrt-div65.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    16. pow-flip65.8%

      \[\leadsto \sqrt{\color{blue}{{x}^{\left(-3\right)}}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    17. sqrt-pow196.5%

      \[\leadsto \color{blue}{{x}^{\left(\frac{-3}{2}\right)}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    18. metadata-eval96.5%

      \[\leadsto {x}^{\left(\frac{\color{blue}{-3}}{2}\right)} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    19. metadata-eval96.5%

      \[\leadsto {x}^{\color{blue}{-1.5}} \cdot {\left(\sqrt[3]{0.5}\right)}^{3} \]
    20. rem-cube-cbrt97.8%

      \[\leadsto {x}^{-1.5} \cdot \color{blue}{0.5} \]
  7. Applied egg-rr97.8%

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

Alternative 4: 5.7% accurate, 2.0× speedup?

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

\\
{x}^{-0.5}
\end{array}
Derivation
  1. Initial program 34.9%

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  4. Step-by-step derivation
    1. inv-pow5.7%

      \[\leadsto \sqrt{\color{blue}{{x}^{-1}}} \]
    2. sqrt-pow15.7%

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

      \[\leadsto {x}^{\color{blue}{-0.5}} \]
    4. *-un-lft-identity5.7%

      \[\leadsto \color{blue}{1 \cdot {x}^{-0.5}} \]
  5. Applied egg-rr5.7%

    \[\leadsto \color{blue}{1 \cdot {x}^{-0.5}} \]
  6. Step-by-step derivation
    1. *-lft-identity5.7%

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
  7. Simplified5.7%

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

Developer target: 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 2024103 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64
  :pre (and (> x 1.0) (< x 1e+308))

  :alt
  (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))

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