?

Average Accuracy: 69.4% → 99.6%
Time: 13.0s
Precision: binary64
Cost: 26240

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation?

  1. Initial program 69.4%

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

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

    [Start]69.4

    \[ \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]

    frac-sub [=>]69.4

    \[ \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]

    clear-num [=>]69.4

    \[ \color{blue}{\frac{1}{\frac{\sqrt{x} \cdot \sqrt{x + 1}}{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}}} \]

    sqrt-unprod [=>]69.4

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

    +-commutative [=>]69.4

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

    *-un-lft-identity [<=]69.4

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

    *-rgt-identity [=>]69.4

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

    +-commutative [=>]69.4

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

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

    [Start]69.4

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

    associate-/r/ [=>]69.4

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

    associate-*l/ [=>]69.4

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

    *-lft-identity [=>]69.4

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

    +-commutative [=>]69.4

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

    distribute-lft-in [=>]69.4

    \[ \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot x + x \cdot 1}}} \]

    *-rgt-identity [=>]69.4

    \[ \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot x + \color{blue}{x}}} \]

    unpow1 [<=]69.4

    \[ \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot x + \color{blue}{{x}^{1}}}} \]

    sqr-pow [=>]69.4

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

    metadata-eval [=>]69.4

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

    exp-to-pow [<=]66.6

    \[ \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot x + \color{blue}{e^{\log x \cdot 0.5}} \cdot {x}^{\left(\frac{1}{2}\right)}}} \]

    metadata-eval [=>]66.6

    \[ \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot x + e^{\log x \cdot 0.5} \cdot {x}^{\color{blue}{0.5}}}} \]

    exp-to-pow [<=]65.9

    \[ \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot x + e^{\log x \cdot 0.5} \cdot \color{blue}{e^{\log x \cdot 0.5}}}} \]

    hypot-def [=>]65.9

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

    exp-to-pow [=>]69.4

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

    unpow1/2 [=>]69.4

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

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

    [Start]69.4

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

    flip-- [=>]69.7

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

    div-inv [=>]69.7

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

    add-sqr-sqrt [<=]61.8

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

    add-sqr-sqrt [<=]70.4

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

    associate--l+ [=>]99.6

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

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

    [Start]99.6

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

    +-inverses [=>]99.6

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

    metadata-eval [=>]99.6

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

    *-lft-identity [=>]99.6

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

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

Alternatives

Alternative 1
Accuracy99.4%
Cost27460
\[\begin{array}{l} t_0 := \sqrt{1 + x}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\ \;\;\;\;\frac{\frac{1}{t_0 + \sqrt{x}}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1 + \left(x - x\right)}{x}}{1 + x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\ \end{array} \]
Alternative 2
Accuracy99.2%
Cost26820
\[\begin{array}{l} t_0 := \sqrt{1 + x}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 10^{-19}:\\ \;\;\;\;\frac{\frac{1}{t_0 + \sqrt{x}}}{x}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
Alternative 3
Accuracy83.0%
Cost26692
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-19}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
Alternative 4
Accuracy99.0%
Cost26240
\[\frac{1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
Alternative 5
Accuracy82.4%
Cost13316
\[\begin{array}{l} \mathbf{if}\;x \leq 1.7:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\ \end{array} \]
Alternative 6
Accuracy67.5%
Cost7296
\[\frac{\frac{1}{x} - \frac{1}{1 + x}}{1 + {x}^{-0.5}} \]
Alternative 7
Accuracy51.2%
Cost6912
\[{x}^{-0.5} + \left(-1 - x \cdot -0.5\right) \]
Alternative 8
Accuracy52.5%
Cost6912
\[\frac{1}{x \cdot \left(1 + {x}^{-0.5}\right)} \]
Alternative 9
Accuracy52.5%
Cost6912
\[\frac{\frac{1}{x}}{1 + {x}^{-0.5}} \]
Alternative 10
Accuracy52.1%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 0.8:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5}\\ \end{array} \]
Alternative 11
Accuracy50.7%
Cost6528
\[{x}^{-0.5} \]
Alternative 12
Accuracy1.9%
Cost64
\[-1 \]

Error

Reproduce?

herbie shell --seed 2023147 
(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)))))