?

Average Accuracy: 54.1% → 99.6%
Time: 9.2s
Precision: binary64
Cost: 26048

?

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

Error?

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original54.1%
Target99.7%
Herbie99.6%
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}} \]

Derivation?

  1. Initial program 56.1%

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Applied egg-rr57.8%

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

    [Start]56.1

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

    flip-- [=>]57.1

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

    div-inv [=>]57.1

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

    add-sqr-sqrt [<=]57.0

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

    add-sqr-sqrt [<=]57.8

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    Proof

    [Start]57.8

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

    *-commutative [=>]57.8

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

    associate-/r/ [<=]57.8

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

    +-commutative [=>]57.8

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

    associate--l+ [=>]99.8

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

    +-inverses [=>]99.8

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

    metadata-eval [=>]99.8

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

    /-rgt-identity [=>]99.8

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

    +-commutative [=>]99.8

    \[ \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
  4. Applied egg-rr99.8%

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

    [Start]99.8

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

    inv-pow [=>]99.8

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

    sqr-pow [=>]99.6

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

    pow-prod-down [=>]99.8

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

    pow2 [=>]99.8

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

    metadata-eval [=>]99.8

    \[ {\left({\left(\sqrt{1 + x} + \sqrt{x}\right)}^{2}\right)}^{\color{blue}{-0.5}} \]
  5. Final simplification99.8%

    \[\leadsto {\left({\left(\sqrt{1 + x} + \sqrt{x}\right)}^{2}\right)}^{-0.5} \]

Alternatives

Alternative 1
Accuracy99.5%
Cost26308
\[\begin{array}{l} t_0 := \sqrt{1 + x} - \sqrt{x}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{-5}:\\ \;\;\;\;{x}^{-0.5} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Accuracy99.7%
Cost13248
\[\frac{1}{\sqrt{1 + x} + \sqrt{x}} \]
Alternative 3
Accuracy96.8%
Cost7172
\[\begin{array}{l} \mathbf{if}\;x \leq 1.8:\\ \;\;\;\;\left(1 + \frac{1}{1 + {x}^{1.5}}\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot 0.5\\ \end{array} \]
Alternative 4
Accuracy96.8%
Cost6916
\[\begin{array}{l} \mathbf{if}\;x \leq 1.8:\\ \;\;\;\;\frac{1}{1 + {x}^{1.5}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot 0.5\\ \end{array} \]
Alternative 5
Accuracy96.8%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 0.25:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot 0.5\\ \end{array} \]
Alternative 6
Accuracy51.9%
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023160 
(FPCore (x)
  :name "Main:bigenough3 from C"
  :precision binary64

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

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