# ?

Average Error: 4.7 → 0.3
Time: 9.0s
Precision: binary64
Cost: 13504

# ?

$10^{-6} \leq x \land x \leq 1000000$
$\frac{1}{\sqrt{x + 1} - \sqrt{x}}$
$\frac{\sqrt{1 + x} + \sqrt{x}}{x + \left(1 - x\right)}$
(FPCore (x) :precision binary64 (/ 1.0 (- (sqrt (+ x 1.0)) (sqrt x))))
(FPCore (x)
:precision binary64
(/ (+ (sqrt (+ 1.0 x)) (sqrt x)) (+ x (- 1.0 x))))
double code(double x) {
return 1.0 / (sqrt((x + 1.0)) - sqrt(x));
}

double code(double x) {
return (sqrt((1.0 + x)) + sqrt(x)) / (x + (1.0 - x));
}

real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 / (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)) / (x + (1.0d0 - x))
end function

public static double code(double x) {
return 1.0 / (Math.sqrt((x + 1.0)) - Math.sqrt(x));
}

public static double code(double x) {
return (Math.sqrt((1.0 + x)) + Math.sqrt(x)) / (x + (1.0 - x));
}

def code(x):
return 1.0 / (math.sqrt((x + 1.0)) - math.sqrt(x))

def code(x):
return (math.sqrt((1.0 + x)) + math.sqrt(x)) / (x + (1.0 - x))

function code(x)
return Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) - sqrt(x)))
end

function code(x)
return Float64(Float64(sqrt(Float64(1.0 + x)) + sqrt(x)) / Float64(x + Float64(1.0 - x)))
end

function tmp = code(x)
tmp = 1.0 / (sqrt((x + 1.0)) - sqrt(x));
end

function tmp = code(x)
tmp = (sqrt((1.0 + x)) + sqrt(x)) / (x + (1.0 - x));
end

code[x_] := N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]],$MachinePrecision] - N[Sqrt[x], $MachinePrecision]),$MachinePrecision]), $MachinePrecision]  code[x_] := N[(N[(N[Sqrt[N[(1.0 + x),$MachinePrecision]], $MachinePrecision] + N[Sqrt[x],$MachinePrecision]), $MachinePrecision] / N[(x + N[(1.0 - x),$MachinePrecision]), $MachinePrecision]),$MachinePrecision]

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

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


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 4.7

$\frac{1}{\sqrt{x + 1} - \sqrt{x}}$
2. Applied egg-rr0.3

$\leadsto \color{blue}{\frac{1}{x + \left(1 - x\right)} \cdot \sqrt{x + 1} + \frac{1}{x + \left(1 - x\right)} \cdot \sqrt{x}}$
3. Simplified0.3

$\leadsto \color{blue}{\frac{\sqrt{1 + x} + \sqrt{x}}{x + \left(1 - x\right)}}$
Proof
[Start]0.3 $\frac{1}{x + \left(1 - x\right)} \cdot \sqrt{x + 1} + \frac{1}{x + \left(1 - x\right)} \cdot \sqrt{x}$ $\color{blue}{\frac{1}{x + \left(1 - x\right)} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}$ $\color{blue}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \frac{1}{x + \left(1 - x\right)}}$ $\color{blue}{\frac{\sqrt{x + 1} + \sqrt{x}}{1}} \cdot \frac{1}{x + \left(1 - x\right)}$ $\color{blue}{\frac{\sqrt{x + 1} + \sqrt{x}}{\frac{1}{\frac{1}{x + \left(1 - x\right)}}}}$ $\frac{\sqrt{\color{blue}{1 + x}} + \sqrt{x}}{\frac{1}{\frac{1}{x + \left(1 - x\right)}}}$ $\frac{\sqrt{1 + x} + \sqrt{x}}{\color{blue}{x + \left(1 - x\right)}}$
4. Final simplification0.3

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

# Alternatives

Alternative 1
Error0.3
Cost13376
$\frac{1}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}$
Alternative 2
Error4.7
Cost13248
$\frac{1}{\sqrt{1 + x} - \sqrt{x}}$
Alternative 3
Error41.1
Cost7232
$\frac{\sqrt{x} + \left(1 + x \cdot 0.5\right)}{x + \left(1 - x\right)}$
Alternative 4
Error42.5
Cost6976
$\frac{1}{\left(1 + x \cdot 0.5\right) - \sqrt{x}}$
Alternative 5
Error50.8
Cost64
$1$

# Reproduce?

herbie shell --seed 1
(FPCore (x)
:name "1 / (sqrt(x+1) - sqrt(x))"
:precision binary64
:pre (and (<= 1e-6 x) (<= x 1000000.0))
(/ 1.0 (- (sqrt (+ x 1.0)) (sqrt x))))