2isqrt (example 3.6)

Percentage Accurate: 38.6% → 99.6%
Time: 10.4s
Alternatives: 9
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 9 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.6% 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.6% accurate, 0.5× speedup?

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

\\
\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
Derivation
  1. Initial program 39.3%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity39.4%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \color{blue}{\mathsf{hypot}\left(\sqrt{x}, x\right)}} \]
  10. Applied egg-rr98.8%

    \[\leadsto \color{blue}{1 \cdot \frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(\sqrt{x}, x\right)}} \]
  11. Step-by-step derivation
    1. *-lft-identity98.8%

      \[\leadsto \color{blue}{\frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(\sqrt{x}, x\right)}} \]
    2. *-commutative98.8%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(\sqrt{x}, x\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}} \]
    3. associate-/r*99.7%

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}} \]
  12. Simplified99.7%

    \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}} \]
  13. Add Preprocessing

Alternative 2: 99.0% accurate, 1.0× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity39.4%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\color{blue}{-1 \cdot \left(x \cdot \left(-1 \cdot \frac{0.5 + 0.125 \cdot \frac{1}{x \cdot {\left(\sqrt{-1}\right)}^{2}}}{x} + {\left(\sqrt{-1}\right)}^{2}\right)\right)}} \]
  10. Step-by-step derivation
    1. mul-1-neg0.0%

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\left(-1 - \color{blue}{\frac{0.5 - \frac{0.125}{x}}{x}}\right) \cdot \left(-x\right)} \]
  15. Final simplification99.5%

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

Alternative 3: 98.7% accurate, 1.0× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity39.4%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.6% accurate, 1.0× speedup?

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

\\
\frac{\frac{1 - \frac{0.5}{x}}{x}}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
Derivation
  1. Initial program 39.3%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity39.4%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \color{blue}{\mathsf{hypot}\left(\sqrt{x}, x\right)}} \]
  10. Applied egg-rr98.8%

    \[\leadsto \color{blue}{1 \cdot \frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(\sqrt{x}, x\right)}} \]
  11. Step-by-step derivation
    1. *-lft-identity98.8%

      \[\leadsto \color{blue}{\frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(\sqrt{x}, x\right)}} \]
    2. *-commutative98.8%

      \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(\sqrt{x}, x\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}} \]
    3. associate-/r*99.7%

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}} \]
  12. Simplified99.7%

    \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{\sqrt{x} + \sqrt{1 + x}}} \]
  13. Taylor expanded in x around inf 99.0%

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5}{x}}{x}}}{\sqrt{x} + \sqrt{1 + x}} \]
  16. Add Preprocessing

Alternative 5: 97.8% accurate, 1.9× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity39.4%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.4%

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

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

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

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

    \[\leadsto \frac{\color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  6. Step-by-step derivation
    1. *-commutative84.3%

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{1}{x}} \cdot 0.5}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    2. unpow1/284.3%

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

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

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

      \[\leadsto \frac{\color{blue}{e^{\left(-\log x\right) \cdot 0.5}} \cdot 0.5}{\sqrt{x \cdot \left(1 + x\right)}} \]
    6. distribute-lft-neg-out81.4%

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

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

      \[\leadsto \frac{e^{\log x \cdot \color{blue}{-0.5}} \cdot 0.5}{\sqrt{x \cdot \left(1 + x\right)}} \]
    9. exp-to-pow84.3%

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

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

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

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

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

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

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

Alternative 6: 97.6% accurate, 2.0× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity39.4%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.4%

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

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

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

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

    \[\leadsto \frac{\color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  6. Step-by-step derivation
    1. *-commutative84.3%

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{1}{x}} \cdot 0.5}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    2. unpow1/284.3%

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

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

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

      \[\leadsto \frac{\color{blue}{e^{\left(-\log x\right) \cdot 0.5}} \cdot 0.5}{\sqrt{x \cdot \left(1 + x\right)}} \]
    6. distribute-lft-neg-out81.4%

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

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

      \[\leadsto \frac{e^{\log x \cdot \color{blue}{-0.5}} \cdot 0.5}{\sqrt{x \cdot \left(1 + x\right)}} \]
    9. exp-to-pow84.3%

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

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

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

    \[\leadsto \frac{0.5 \cdot {x}^{-0.5}}{x} \]
  10. Add Preprocessing

Alternative 7: 37.0% accurate, 2.0× speedup?

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

\\
{\left(x \cdot x\right)}^{-0.25}
\end{array}
Derivation
  1. Initial program 39.3%

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  4. Step-by-step derivation
    1. pow1/25.6%

      \[\leadsto \color{blue}{{\left(\frac{1}{x}\right)}^{0.5}} \]
    2. inv-pow5.6%

      \[\leadsto {\color{blue}{\left({x}^{-1}\right)}}^{0.5} \]
    3. pow-pow5.6%

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

      \[\leadsto {x}^{\color{blue}{-0.5}} \]
    5. sqr-pow5.6%

      \[\leadsto \color{blue}{{x}^{\left(\frac{-0.5}{2}\right)} \cdot {x}^{\left(\frac{-0.5}{2}\right)}} \]
    6. pow-prod-down38.2%

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

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

      \[\leadsto {\left({x}^{2}\right)}^{\color{blue}{-0.25}} \]
  5. Applied egg-rr38.2%

    \[\leadsto \color{blue}{{\left({x}^{2}\right)}^{-0.25}} \]
  6. Step-by-step derivation
    1. unpow238.2%

      \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{-0.25} \]
  7. Applied egg-rr38.2%

    \[\leadsto {\color{blue}{\left(x \cdot x\right)}}^{-0.25} \]
  8. Add Preprocessing

Alternative 8: 37.8% accurate, 17.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.4 \cdot 10^{+153}:\\
\;\;\;\;\frac{0.5}{x}\\

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


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

    1. Initial program 8.8%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity9.0%

        \[\leadsto \frac{\color{blue}{\sqrt{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      3. +-commutative9.0%

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity9.0%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{1}{x}} \cdot 0.5}}{\sqrt{x \cdot \left(1 + x\right)}} \]
      2. unpow1/296.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{x}} \]

    if 6.4000000000000003e153 < x

    1. Initial program 70.2%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity70.2%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{1}{x}} \cdot 0.5}}{\sqrt{x \cdot \left(1 + x\right)}} \]
      2. unpow1/271.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{x}} \]
    9. Step-by-step derivation
      1. expm1-log1p-u7.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{0.5}{x}\right)\right)} \]
      2. log1p-define70.2%

        \[\leadsto \mathsf{expm1}\left(\color{blue}{\log \left(1 + \frac{0.5}{x}\right)}\right) \]
      3. expm1-undefine70.2%

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

        \[\leadsto \color{blue}{\left(1 + \frac{0.5}{x}\right)} - 1 \]
    10. Applied egg-rr70.2%

      \[\leadsto \color{blue}{\left(1 + \frac{0.5}{x}\right) - 1} \]
    11. Step-by-step derivation
      1. associate--l+70.2%

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

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

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

Alternative 9: 7.9% accurate, 69.7× speedup?

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

\\
\frac{0.5}{x}
\end{array}
Derivation
  1. Initial program 39.3%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity39.4%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.4%

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

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

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

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

    \[\leadsto \frac{\color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  6. Step-by-step derivation
    1. *-commutative84.3%

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{1}{x}} \cdot 0.5}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    2. unpow1/284.3%

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

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

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

      \[\leadsto \frac{\color{blue}{e^{\left(-\log x\right) \cdot 0.5}} \cdot 0.5}{\sqrt{x \cdot \left(1 + x\right)}} \]
    6. distribute-lft-neg-out81.4%

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

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

      \[\leadsto \frac{e^{\log x \cdot \color{blue}{-0.5}} \cdot 0.5}{\sqrt{x \cdot \left(1 + x\right)}} \]
    9. exp-to-pow84.3%

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

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

    \[\leadsto \color{blue}{\frac{0.5}{x}} \]
  9. Add Preprocessing

Developer Target 1: 98.4% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024113 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64
  :pre (and (> x 1.0) (< x 1e+308))

  :alt
  (! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))

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