Average Error: 30.1 → 0.2
Time: 6.9s
Precision: binary64
Cost: 13248
$-1.79 \cdot 10^{+308} \leq x \land x \leq 1.79 \cdot 10^{+308}$
$\sqrt{x + 1} - \sqrt{x}$
$\frac{1}{\sqrt{1 + x} + \sqrt{x}}$
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))
double code(double x) {
return sqrt((x + 1.0)) - sqrt(x);
}

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

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

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

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

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

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

function tmp = code(x)
tmp = 1.0 / (sqrt((1.0 + x)) + 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[Sqrt[N[(1.0 + x), $MachinePrecision]],$MachinePrecision] + N[Sqrt[x], $MachinePrecision]),$MachinePrecision]), \$MachinePrecision]

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

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


# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 30.1

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

$\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{\sqrt{x + 1} + \sqrt{x}}}$
3. Taylor expanded in x around 0 0.2

$\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}$
4. Final simplification0.2

$\leadsto \frac{1}{\sqrt{1 + x} + \sqrt{x}}$

# Alternatives

Alternative 1
Error0.3
Cost26308
$\begin{array}{l} t_0 := \sqrt{1 + x} - \sqrt{x}\\ \mathbf{if}\;t_0 \leq 4 \cdot 10^{-5}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array}$
Alternative 2
Error1.0
Cost6980
$\begin{array}{l} \mathbf{if}\;x \leq 0.0007865835300043417:\\ \;\;\;\;1 + \left(x \cdot 0.5 - \sqrt{x}\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \end{array}$
Alternative 3
Error2.1
Cost6852
$\begin{array}{l} \mathbf{if}\;x \leq 0.0007865835300043417:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \end{array}$
Alternative 4
Error31.3
Cost64
$1$

# Reproduce

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