Average Error: 29.9 → 0.2
Time: 3.8s
Precision: binary64
\[\sqrt{x + 1} - \sqrt{x} \]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right) \]
\sqrt{x + 1} - \sqrt{x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right)
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x)
 :precision binary64
 (expm1 (log1p (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))))
double code(double x) {
	return sqrt(x + 1.0) - sqrt(x);
}
double code(double x) {
	return expm1(log1p(1.0 / (sqrt(1.0 + x) + sqrt(x))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.9
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}} \]

Derivation

  1. Initial program 29.9

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Applied flip--_binary6429.7

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
  3. Simplified0.2

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
  4. Simplified0.2

    \[\leadsto \frac{1}{\color{blue}{\sqrt{1 + x} + \sqrt{x}}} \]
  5. Applied expm1-log1p-u_binary640.2

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right)} \]
  6. Final simplification0.2

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right) \]

Reproduce

herbie shell --seed 2021340 
(FPCore (x)
  :name "Main:bigenough3 from C"
  :precision binary64

  :herbie-target
  (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))

  (- (sqrt (+ x 1.0)) (sqrt x)))