2isqrt (example 3.6)

Percentage Accurate: 38.4% → 99.9%
Time: 12.2s
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.4% 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{1 + x}} \leq 0:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-1}{x}}{-1 - x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 0.0)
   (* 0.5 (pow x -1.5))
   (/ (/ (/ -1.0 x) (- -1.0 x)) (+ (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
double code(double x) {
	double tmp;
	if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0) {
		tmp = 0.5 * pow(x, -1.5);
	} else {
		tmp = ((-1.0 / x) / (-1.0 - x)) / (pow(x, -0.5) + pow((1.0 + x), -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((1.0d0 + x)))) <= 0.0d0) then
        tmp = 0.5d0 * (x ** (-1.5d0))
    else
        tmp = (((-1.0d0) / x) / ((-1.0d0) - x)) / ((x ** (-0.5d0)) + ((1.0d0 + x) ** (-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((1.0 + x)))) <= 0.0) {
		tmp = 0.5 * Math.pow(x, -1.5);
	} else {
		tmp = ((-1.0 / x) / (-1.0 - x)) / (Math.pow(x, -0.5) + Math.pow((1.0 + x), -0.5));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 0.0:
		tmp = 0.5 * math.pow(x, -1.5)
	else:
		tmp = ((-1.0 / x) / (-1.0 - x)) / (math.pow(x, -0.5) + math.pow((1.0 + x), -0.5))
	return tmp
function code(x)
	tmp = 0.0
	if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 0.0)
		tmp = Float64(0.5 * (x ^ -1.5));
	else
		tmp = Float64(Float64(Float64(-1.0 / x) / Float64(-1.0 - x)) / Float64((x ^ -0.5) + (Float64(1.0 + x) ^ -0.5)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 0.0)
		tmp = 0.5 * (x ^ -1.5);
	else
		tmp = ((-1.0 / x) / (-1.0 - x)) / ((x ^ -0.5) + ((1.0 + x) ^ -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[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-1.0 / x), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{-1}{x}}{-1 - x}}{{x}^{-0.5} + {\left(1 + x\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)))) < 0.0

    1. Initial program 36.9%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--36.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. clear-num36.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. pow1/236.9%

        \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      4. pow-flip36.9%

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

        \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      6. inv-pow36.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    10. Step-by-step derivation
      1. unpow-166.0%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-3}}} \]
      10. metadata-eval67.3%

        \[\leadsto 0.5 \cdot \sqrt{{x}^{\color{blue}{\left(2 \cdot -1.5\right)}}} \]
      11. pow-sqr67.4%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-1.5} \cdot {x}^{-1.5}}} \]
      12. rem-sqrt-square100.0%

        \[\leadsto 0.5 \cdot \color{blue}{\left|{x}^{-1.5}\right|} \]
      13. rem-square-sqrt99.5%

        \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}}\right| \]
      14. fabs-sqr99.5%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}\right)} \]
      15. rem-square-sqrt100.0%

        \[\leadsto 0.5 \cdot \color{blue}{{x}^{-1.5}} \]
    11. 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 57.2%

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

        \[\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. clear-num57.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. pow1/257.7%

        \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      4. pow-flip57.7%

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

        \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      6. inv-pow57.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\color{blue}{\frac{1 \cdot \left(-\left(1 + x\right)\right) - x \cdot -1}{x \cdot \left(-\left(1 + x\right)\right)}}}} \]
    7. Step-by-step derivation
      1. *-lft-identity99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\frac{1}{x \cdot \left(-1 - x\right)}}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}}} \]
    11. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto -1 \cdot \frac{\color{blue}{\frac{\frac{1}{x}}{-1 - x}}}{{x}^{-0.5} + {\left(x + 1\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{1 + x}} \leq 0:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-1}{x}}{-1 - x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.9% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{-1}{\left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right) \cdot \left(x \cdot \left(-1 - x\right)\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 36.9%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--36.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. clear-num36.9%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. pow1/236.9%

        \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      4. pow-flip36.9%

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

        \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      6. inv-pow36.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    10. Step-by-step derivation
      1. unpow-166.0%

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-3}}} \]
      10. metadata-eval67.3%

        \[\leadsto 0.5 \cdot \sqrt{{x}^{\color{blue}{\left(2 \cdot -1.5\right)}}} \]
      11. pow-sqr67.4%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-1.5} \cdot {x}^{-1.5}}} \]
      12. rem-sqrt-square100.0%

        \[\leadsto 0.5 \cdot \color{blue}{\left|{x}^{-1.5}\right|} \]
      13. rem-square-sqrt99.5%

        \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}}\right| \]
      14. fabs-sqr99.5%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}\right)} \]
      15. rem-square-sqrt100.0%

        \[\leadsto 0.5 \cdot \color{blue}{{x}^{-1.5}} \]
    11. 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 57.2%

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

        \[\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. clear-num57.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. pow1/257.7%

        \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      4. pow-flip57.7%

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

        \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      6. inv-pow57.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\color{blue}{\frac{1 \cdot \left(-\left(1 + x\right)\right) - x \cdot -1}{x \cdot \left(-\left(1 + x\right)\right)}}}} \]
    7. Step-by-step derivation
      1. *-lft-identity99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 3.2% accurate, 2.0× speedup?

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

\\
-\sqrt{\frac{1}{x}}
\end{array}
Derivation
  1. Initial program 37.9%

    \[\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-udef7.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. Step-by-step derivation
    1. distribute-lft-neg-in7.2%

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{{\left(e^{-0.5}\right)}^{\left(\mathsf{log1p}\left(x\right)\right)}} \]
  6. Simplified6.8%

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

    \[\leadsto \color{blue}{-1 \cdot \sqrt{\frac{1}{x}}} \]
  8. Step-by-step derivation
    1. mul-1-neg3.2%

      \[\leadsto \color{blue}{-\sqrt{\frac{1}{x}}} \]
  9. Simplified3.2%

    \[\leadsto \color{blue}{-\sqrt{\frac{1}{x}}} \]
  10. Final simplification3.2%

    \[\leadsto -\sqrt{\frac{1}{x}} \]
  11. Add Preprocessing

Alternative 4: 97.9% 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 37.9%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--37.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. clear-num38.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
    3. pow1/238.0%

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

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

      \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
    6. inv-pow38.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}} \]
    15. add-sqr-sqrt38.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
  10. Step-by-step derivation
    1. unpow-165.8%

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-3}}} \]
    10. metadata-eval67.0%

      \[\leadsto 0.5 \cdot \sqrt{{x}^{\color{blue}{\left(2 \cdot -1.5\right)}}} \]
    11. pow-sqr67.1%

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-1.5} \cdot {x}^{-1.5}}} \]
    12. rem-sqrt-square98.0%

      \[\leadsto 0.5 \cdot \color{blue}{\left|{x}^{-1.5}\right|} \]
    13. rem-square-sqrt97.5%

      \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}}\right| \]
    14. fabs-sqr97.5%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}\right)} \]
    15. rem-square-sqrt98.0%

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

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

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

Alternative 5: 2.5% accurate, 209.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
	return -1.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = -1.0d0
end function
public static double code(double x) {
	return -1.0;
}
def code(x):
	return -1.0
function code(x)
	return -1.0
end
function tmp = code(x)
	tmp = -1.0;
end
code[x_] := -1.0
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 37.9%

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

    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{1} \]
  4. Taylor expanded in x around inf 2.5%

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification2.5%

    \[\leadsto -1 \]
  6. Add Preprocessing

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

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

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