?

Percentage Accurate: 99.2% → 99.9%
Time: 4.5s
Precision: binary64
Cost: 13248

?

$-1000000000 \leq x \land x \leq 1000000000$
$\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 99.3%

$\sqrt{x + 1} - \sqrt{x}$
2. Applied egg-rr99.9%

$\leadsto \color{blue}{\left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}$
Step-by-step derivation
[Start]99.3 $\sqrt{x + 1} - \sqrt{x}$ $\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}$ $\color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}$ $\left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}$ $\left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}$
3. Simplified99.9%

$\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}$
Step-by-step derivation
[Start]99.9 $\left(\left(x + 1\right) - x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}$ $\color{blue}{\frac{\left(\left(x + 1\right) - x\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}}$ $\frac{\color{blue}{\left(x + 1\right) - x}}{\sqrt{x + 1} + \sqrt{x}}$ $\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \color{blue}{\left(-\left(-\sqrt{x}\right)\right)}}$ $\frac{\left(x + 1\right) - x}{\color{blue}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}}$ $\color{blue}{\frac{x + 1}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} - \frac{x}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}}$ $\frac{x + 1}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} - \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\frac{x + 1}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} - \frac{\color{blue}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{x}\right)}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\color{blue}{\frac{\left(x + 1\right) - \left(-\sqrt{x}\right) \cdot \left(-\sqrt{x}\right)}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}}$ $\frac{\left(x + 1\right) - \color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\frac{\color{blue}{\left(1 + x\right)} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\frac{\left(1 + x\right) - \color{blue}{x}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\frac{\color{blue}{1 + \left(x - x\right)}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\frac{1 + \color{blue}{0}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\frac{\color{blue}{1}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}$ $\frac{1}{\color{blue}{\sqrt{x + 1} + \left(-\left(-\sqrt{x}\right)\right)}}$
4. Final simplification99.9%

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

Alternatives

Alternative 1
Accuracy99.2%
Cost13120
$\sqrt{1 + x} - \sqrt{x}$
Alternative 2
Accuracy96.4%
Cost6848
$x \cdot 0.5 + \left(1 - \sqrt{x}\right)$
Alternative 3
Accuracy93.2%
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)))