Average Error: 30.4 → 0.2
Time: 11.6s
Precision: 64
$\sqrt{x} - \sqrt{x + 1}$
$\frac{-1}{\sqrt{x + 1} + \sqrt{x}}$
\sqrt{x} - \sqrt{x + 1}
\frac{-1}{\sqrt{x + 1} + \sqrt{x}}
double f(double x) {
double r57621351 = x;
double r57621352 = sqrt(r57621351);
double r57621353 = 1.0;
double r57621354 = r57621351 + r57621353;
double r57621355 = sqrt(r57621354);
double r57621356 = r57621352 - r57621355;
return r57621356;
}


double f(double x) {
double r57621357 = -1.0;
double r57621358 = x;
double r57621359 = 1.0;
double r57621360 = r57621358 + r57621359;
double r57621361 = sqrt(r57621360);
double r57621362 = sqrt(r57621358);
double r57621363 = r57621361 + r57621362;
double r57621364 = r57621357 / r57621363;
return r57621364;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 30.4

$\sqrt{x} - \sqrt{x + 1}$
2. Using strategy rm
3. Applied flip--30.2

$\leadsto \color{blue}{\frac{\sqrt{x} \cdot \sqrt{x} - \sqrt{x + 1} \cdot \sqrt{x + 1}}{\sqrt{x} + \sqrt{x + 1}}}$
4. Simplified0.2

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

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

# Reproduce

herbie shell --seed 1
(FPCore (x)
:name "sqrt(x)-sqrt(x+1)"
(- (sqrt x) (sqrt (+ x 1))))