?

Average Accuracy: 68.5% → 99.6%
Time: 12.5s
Precision: binary64
Cost: 26240

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original68.5%
Target99.0%
Herbie99.6%
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}} \]

Derivation?

  1. Initial program 68.5%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Applied egg-rr91.7%

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}} \]
    Proof

    [Start]91.7

    \[ \frac{1 + \left(x - x\right)}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)} \]

    +-commutative [=>]91.7

    \[ \frac{\color{blue}{\left(x - x\right) + 1}}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)} \]

    +-inverses [=>]91.7

    \[ \frac{\color{blue}{0} + 1}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)} \]

    metadata-eval [=>]91.7

    \[ \frac{\color{blue}{1}}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)} \]

    +-commutative [=>]91.7

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

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

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}\right)} - 1} \]
  6. Simplified99.6%

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

    [Start]64.5

    \[ e^{\mathsf{log1p}\left(\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}\right)} - 1 \]

    expm1-def [=>]95.5

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}\right)\right)} \]

    expm1-log1p [=>]99.0

    \[ \color{blue}{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}} \]

    associate-/r* [=>]99.6

    \[ \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\sqrt{x} + \sqrt{1 + x}}} \]
  7. Final simplification99.6%

    \[\leadsto \frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\sqrt{x} + \sqrt{1 + x}} \]

Alternatives

Alternative 1
Accuracy99.4%
Cost13760
\[\frac{\frac{1}{x}}{\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} \]
Alternative 2
Accuracy98.7%
Cost13508
\[\begin{array}{l} \mathbf{if}\;x \leq 48000000:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}\\ \end{array} \]
Alternative 3
Accuracy99.3%
Cost13508
\[\begin{array}{l} \mathbf{if}\;x \leq 48000000:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{\sqrt{x} + \sqrt{1 + x}}\\ \end{array} \]
Alternative 4
Accuracy91.4%
Cost13380
\[\begin{array}{l} \mathbf{if}\;x \leq 35000000:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x + x \cdot x}}{\sqrt{\frac{1}{x}} \cdot 2}\\ \end{array} \]
Alternative 5
Accuracy90.6%
Cost7364
\[\begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;{x}^{-0.5} + \left(-1 + x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x + x \cdot x}}{\sqrt{\frac{1}{x}} \cdot 2}\\ \end{array} \]
Alternative 6
Accuracy68.0%
Cost7044
\[\begin{array}{l} \mathbf{if}\;x \leq 1.75:\\ \;\;\;\;{x}^{-0.5} + \left(-1 + x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot {x}^{-2}\\ \end{array} \]
Alternative 7
Accuracy66.3%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 1.6:\\ \;\;\;\;{x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot {x}^{-2}\\ \end{array} \]
Alternative 8
Accuracy67.7%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 0.92:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot {x}^{-2}\\ \end{array} \]
Alternative 9
Accuracy66.3%
Cost6660
\[\begin{array}{l} \mathbf{if}\;x \leq 1.6:\\ \;\;\;\;{x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{x \cdot x}\\ \end{array} \]
Alternative 10
Accuracy20.3%
Cost320
\[\frac{2}{x \cdot x} \]

Error

Reproduce?

herbie shell --seed 2023122 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

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

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