?

Average Accuracy: 53.4% → 99.7%
Time: 9.7s
Precision: binary64
Cost: 13504

?

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

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original53.4%
Target99.8%
Herbie99.7%
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}} \]

Derivation?

  1. Initial program 53.4%

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

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

    [Start]53.4

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

    flip-- [=>]53.7

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

    clear-num [=>]53.7

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

    add-sqr-sqrt [<=]53.9

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

    add-sqr-sqrt [<=]54.4

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

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

    [Start]54.4

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

    expm1-log1p-u [=>]54.4

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

    expm1-udef [=>]54.4

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

    log1p-udef [=>]54.4

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

    add-exp-log [<=]54.4

    \[ \frac{1}{\frac{\left(\color{blue}{\left(1 + \sqrt{x + 1}\right)} - 1\right) + \sqrt{x}}{\left(x + 1\right) - x}} \]
  4. Taylor expanded in x around 0 99.7%

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

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

Alternatives

Alternative 1
Accuracy99.5%
Cost13252
\[\begin{array}{l} \mathbf{if}\;x \leq 66000000:\\ \;\;\;\;\sqrt{1 + x} - \sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-0.5}\\ \end{array} \]
Alternative 2
Accuracy99.8%
Cost13248
\[\frac{1}{\sqrt{1 + x} + \sqrt{x}} \]
Alternative 3
Accuracy98.5%
Cost6980
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;1 + \left(x \cdot 0.5 - \sqrt{x}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-0.5}\\ \end{array} \]
Alternative 4
Accuracy98.0%
Cost6852
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{1}{1 + \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-0.5}\\ \end{array} \]
Alternative 5
Accuracy96.9%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 0.25:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-0.5}\\ \end{array} \]
Alternative 6
Accuracy51.3%
Cost64
\[1 \]

Error

Reproduce?

herbie shell --seed 2023147 
(FPCore (x)
  :name "2sqrt (example 3.1)"
  :precision binary64

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

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