2isqrt (example 3.6)

Percentage Accurate: 38.7% → 98.7%
Time: 13.0s
Alternatives: 3
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 3 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.7% 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.7% accurate, 1.0× speedup?

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

\\
\frac{\frac{0.5}{x} - \frac{0.375}{{x}^{2}}}{\sqrt{x}}
\end{array}
Derivation
  1. Initial program 43.2%

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

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

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

      \[\leadsto \frac{-1}{-\sqrt{x}} - \color{blue}{\frac{-1}{-\sqrt{x + 1}}} \]
    4. metadata-eval43.2%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, -\sqrt{1 + x}, -\left(-\sqrt{x}\right) \cdot -1\right)}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)}} \]
  5. Step-by-step derivation
    1. fma-undefine43.3%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right) + \left(-\left(-\sqrt{x}\right) \cdot -1\right)}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    2. distribute-rgt-neg-in43.3%

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-\left(-\sqrt{1 + x}\right)\right)} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    7. remove-double-neg43.3%

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    8. *-lft-identity43.3%

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

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    10. distribute-rgt-neg-out43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{-\left(-\sqrt{x}\right) \cdot \sqrt{1 + x}}} \]
    11. *-commutative43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{-\color{blue}{\sqrt{1 + x} \cdot \left(-\sqrt{x}\right)}} \]
    12. distribute-rgt-neg-in43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{\sqrt{1 + x} \cdot \left(-\left(-\sqrt{x}\right)\right)}} \]
    13. remove-double-neg43.3%

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

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

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

    \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{1}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}}{\sqrt{x}} \]
  8. Step-by-step derivation
    1. associate-*r/99.0%

      \[\leadsto \frac{\color{blue}{\frac{0.5 \cdot 1}{x}} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
    2. metadata-eval99.0%

      \[\leadsto \frac{\frac{\color{blue}{0.5}}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
    3. associate-*r/99.0%

      \[\leadsto \frac{\frac{0.5}{x} - \color{blue}{\frac{0.375 \cdot 1}{{x}^{2}}}}{\sqrt{x}} \]
    4. metadata-eval99.0%

      \[\leadsto \frac{\frac{0.5}{x} - \frac{\color{blue}{0.375}}{{x}^{2}}}{\sqrt{x}} \]
  9. Simplified99.0%

    \[\leadsto \frac{\color{blue}{\frac{0.5}{x} - \frac{0.375}{{x}^{2}}}}{\sqrt{x}} \]
  10. Final simplification99.0%

    \[\leadsto \frac{\frac{0.5}{x} - \frac{0.375}{{x}^{2}}}{\sqrt{x}} \]
  11. Add Preprocessing

Alternative 2: 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 43.2%

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

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

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

      \[\leadsto \frac{-1}{-\sqrt{x}} - \color{blue}{\frac{-1}{-\sqrt{x + 1}}} \]
    4. metadata-eval43.2%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, -\sqrt{1 + x}, -\left(-\sqrt{x}\right) \cdot -1\right)}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)}} \]
  5. Step-by-step derivation
    1. fma-undefine43.3%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right) + \left(-\left(-\sqrt{x}\right) \cdot -1\right)}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    2. distribute-rgt-neg-in43.3%

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-\left(-\sqrt{1 + x}\right)\right)} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    7. remove-double-neg43.3%

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    8. *-lft-identity43.3%

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

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    10. distribute-rgt-neg-out43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{-\left(-\sqrt{x}\right) \cdot \sqrt{1 + x}}} \]
    11. *-commutative43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{-\color{blue}{\sqrt{1 + x} \cdot \left(-\sqrt{x}\right)}} \]
    12. distribute-rgt-neg-in43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{\sqrt{1 + x} \cdot \left(-\left(-\sqrt{x}\right)\right)}} \]
    13. remove-double-neg43.3%

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

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

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

    \[\leadsto \frac{1 - \color{blue}{\left(1 - 0.5 \cdot \frac{1}{x}\right)}}{\sqrt{x}} \]
  8. Step-by-step derivation
    1. associate-*r/42.6%

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

      \[\leadsto \frac{1 - \left(1 - \frac{\color{blue}{0.5}}{x}\right)}{\sqrt{x}} \]
  9. Simplified42.6%

    \[\leadsto \frac{1 - \color{blue}{\left(1 - \frac{0.5}{x}\right)}}{\sqrt{x}} \]
  10. Step-by-step derivation
    1. associate--r-98.3%

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

      \[\leadsto \frac{\color{blue}{0} + \frac{0.5}{x}}{\sqrt{x}} \]
    3. +-lft-identity98.3%

      \[\leadsto \frac{\color{blue}{\frac{0.5}{x}}}{\sqrt{x}} \]
    4. *-un-lft-identity98.3%

      \[\leadsto \frac{\color{blue}{1 \cdot \frac{0.5}{x}}}{\sqrt{x}} \]
    5. add-sqr-sqrt98.1%

      \[\leadsto \frac{1 \cdot \frac{0.5}{x}}{\color{blue}{\sqrt{\sqrt{x}} \cdot \sqrt{\sqrt{x}}}} \]
    6. times-frac98.1%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{\sqrt{x}}} \cdot \frac{\frac{0.5}{x}}{\sqrt{\sqrt{x}}}} \]
    7. pow1/298.1%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{{x}^{0.5}}}} \cdot \frac{\frac{0.5}{x}}{\sqrt{\sqrt{x}}} \]
    8. sqrt-pow198.1%

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

      \[\leadsto \frac{1}{{x}^{\color{blue}{0.25}}} \cdot \frac{\frac{0.5}{x}}{\sqrt{\sqrt{x}}} \]
    10. pow1/298.1%

      \[\leadsto \frac{1}{{x}^{0.25}} \cdot \frac{\frac{0.5}{x}}{\sqrt{\color{blue}{{x}^{0.5}}}} \]
    11. sqrt-pow198.1%

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

      \[\leadsto \frac{1}{{x}^{0.25}} \cdot \frac{\frac{0.5}{x}}{{x}^{\color{blue}{0.25}}} \]
  11. Applied egg-rr98.1%

    \[\leadsto \color{blue}{\frac{1}{{x}^{0.25}} \cdot \frac{\frac{0.5}{x}}{{x}^{0.25}}} \]
  12. Step-by-step derivation
    1. associate-*l/98.0%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{\frac{0.5}{x}}{{x}^{0.25}}}{{x}^{0.25}}} \]
    2. *-lft-identity98.0%

      \[\leadsto \frac{\color{blue}{\frac{\frac{0.5}{x}}{{x}^{0.25}}}}{{x}^{0.25}} \]
    3. associate-/l/98.1%

      \[\leadsto \frac{\color{blue}{\frac{0.5}{{x}^{0.25} \cdot x}}}{{x}^{0.25}} \]
    4. pow-plus98.2%

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

      \[\leadsto \frac{\frac{0.5}{{x}^{\color{blue}{1.25}}}}{{x}^{0.25}} \]
  13. Simplified98.2%

    \[\leadsto \color{blue}{\frac{\frac{0.5}{{x}^{1.25}}}{{x}^{0.25}}} \]
  14. Step-by-step derivation
    1. associate-/l/97.3%

      \[\leadsto \color{blue}{\frac{0.5}{{x}^{0.25} \cdot {x}^{1.25}}} \]
    2. pow-prod-up97.4%

      \[\leadsto \frac{0.5}{\color{blue}{{x}^{\left(0.25 + 1.25\right)}}} \]
    3. metadata-eval97.4%

      \[\leadsto \frac{0.5}{{x}^{\color{blue}{1.5}}} \]
    4. metadata-eval97.4%

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

      \[\leadsto \frac{0.5}{\color{blue}{\frac{{x}^{1}}{{x}^{-0.5}}}} \]
    6. pow197.4%

      \[\leadsto \frac{0.5}{\frac{\color{blue}{x}}{{x}^{-0.5}}} \]
    7. associate-/l*98.4%

      \[\leadsto \color{blue}{\frac{0.5 \cdot {x}^{-0.5}}{x}} \]
    8. *-commutative98.4%

      \[\leadsto \frac{\color{blue}{{x}^{-0.5} \cdot 0.5}}{x} \]
    9. associate-*l/98.4%

      \[\leadsto \color{blue}{\frac{{x}^{-0.5}}{x} \cdot 0.5} \]
    10. pow198.4%

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{{x}^{1}}} \cdot 0.5 \]
    11. pow-div98.6%

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

      \[\leadsto {x}^{\color{blue}{-1.5}} \cdot 0.5 \]
  15. Applied egg-rr98.6%

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

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

Alternative 3: 5.6% 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 43.2%

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

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

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

      \[\leadsto \frac{-1}{-\sqrt{x}} - \color{blue}{\frac{-1}{-\sqrt{x + 1}}} \]
    4. metadata-eval43.2%

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-1, -\sqrt{1 + x}, -\left(-\sqrt{x}\right) \cdot -1\right)}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)}} \]
  5. Step-by-step derivation
    1. fma-undefine43.3%

      \[\leadsto \frac{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right) + \left(-\left(-\sqrt{x}\right) \cdot -1\right)}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    2. distribute-rgt-neg-in43.3%

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(-\left(-\sqrt{1 + x}\right)\right)} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    7. remove-double-neg43.3%

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    8. *-lft-identity43.3%

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

      \[\leadsto \frac{\color{blue}{\sqrt{1 + x}} - \sqrt{x}}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{1 + x}\right)} \]
    10. distribute-rgt-neg-out43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{-\left(-\sqrt{x}\right) \cdot \sqrt{1 + x}}} \]
    11. *-commutative43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{-\color{blue}{\sqrt{1 + x} \cdot \left(-\sqrt{x}\right)}} \]
    12. distribute-rgt-neg-in43.3%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{\sqrt{1 + x} \cdot \left(-\left(-\sqrt{x}\right)\right)}} \]
    13. remove-double-neg43.3%

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

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

    \[\leadsto \color{blue}{\frac{1 - \frac{\sqrt{x}}{\sqrt{1 + x}}}{\sqrt{x}}} \]
  7. Taylor expanded in x around 0 5.5%

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \]
  8. Step-by-step derivation
    1. add05.5%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} + 0} \]
    2. inv-pow5.5%

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

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

      \[\leadsto {x}^{\color{blue}{-0.5}} + 0 \]
  9. Applied egg-rr5.5%

    \[\leadsto \color{blue}{{x}^{-0.5} + 0} \]
  10. Step-by-step derivation
    1. add05.5%

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

    \[\leadsto \color{blue}{{x}^{-0.5}} \]
  12. Final simplification5.5%

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

Developer target: 98.3% 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 2024034 
(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)))))