# ?

Average Error: 0.5 → 0.1
Time: 7.8s
Precision: binary64
Cost: 20416

# ?

$-1000000000 \leq x \land x \leq 1000000000$
$\sqrt{x + 1} - \sqrt{x}$
$\frac{1 + \left(\left(x + x\right) - \sqrt{x + x \cdot x}\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}$
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x)
:precision binary64
(/
(+ 1.0 (- (+ x x) (sqrt (+ x (* x x)))))
(+ (pow (+ 1.0 x) 1.5) (pow x 1.5))))
double code(double x) {
return sqrt((x + 1.0)) - sqrt(x);
}

double code(double x) {
return (1.0 + ((x + x) - sqrt((x + (x * x))))) / (pow((1.0 + x), 1.5) + pow(x, 1.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 = (1.0d0 + ((x + x) - sqrt((x + (x * x))))) / (((1.0d0 + x) ** 1.5d0) + (x ** 1.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 (1.0 + ((x + x) - Math.sqrt((x + (x * x))))) / (Math.pow((1.0 + x), 1.5) + Math.pow(x, 1.5));
}

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

def code(x):
return (1.0 + ((x + x) - math.sqrt((x + (x * x))))) / (math.pow((1.0 + x), 1.5) + math.pow(x, 1.5))

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

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

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

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

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

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

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

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


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 0.5

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

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

$\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}$
Proof
[Start]0.1 $\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}$ $\color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}}$ $\frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}}$ $\frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}}$ $\frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}}$ $\frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}}$ $\frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}$ $\frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}}$
4. Applied egg-rr0.1

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

$\leadsto \color{blue}{\frac{1 + \left(\left(x + x\right) - \sqrt{x + x \cdot x}\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}}$
Proof
[Start]0.1 $\frac{1}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}} \cdot 1 + \frac{1}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}} \cdot \left(\left(x + x\right) - \sqrt{x + x \cdot x}\right)$ $\color{blue}{\frac{1}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}} \cdot \left(1 + \left(\left(x + x\right) - \sqrt{x + x \cdot x}\right)\right)}$ $\frac{1}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}} \cdot \color{blue}{\left(\left(1 + \left(x + x\right)\right) - \sqrt{x + x \cdot x}\right)}$ $\color{blue}{\frac{1 \cdot \left(\left(1 + \left(x + x\right)\right) - \sqrt{x + x \cdot x}\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}}$ $\frac{\color{blue}{\frac{1}{1}} \cdot \left(\left(1 + \left(x + x\right)\right) - \sqrt{x + x \cdot x}\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}$ $\frac{\color{blue}{\frac{1}{\frac{1}{\left(1 + \left(x + x\right)\right) - \sqrt{x + x \cdot x}}}}}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}$ $\frac{\color{blue}{\left(1 + \left(x + x\right)\right) - \sqrt{x + x \cdot x}}}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}$ $\frac{\color{blue}{1 + \left(\left(x + x\right) - \sqrt{x + x \cdot x}\right)}}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}$
6. Final simplification0.1

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

# Alternatives

Alternative 1
Error0.1
Cost13248
$\frac{1}{\sqrt{1 + x} + \sqrt{x}}$
Alternative 2
Error0.5
Cost13120
$\sqrt{1 + x} - \sqrt{x}$
Alternative 3
Error2.3
Cost6848
$\left(1 - \sqrt{x}\right) + x \cdot 0.5$
Alternative 4
Error4.3
Cost64
$1$

# Reproduce?

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