Average Error: 20.1 → 0.6
Time: 9.5s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
\[\frac{1}{\left(1 + x\right) \cdot \left(\sqrt{x} + x \cdot \sqrt{\frac{1}{1 + x}}\right)} \]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\left(1 + x\right) \cdot \left(\sqrt{x} + x \cdot \sqrt{\frac{1}{1 + x}}\right)}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (/ 1.0 (* (+ 1.0 x) (+ (sqrt x) (* x (sqrt (/ 1.0 (+ 1.0 x))))))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt(x + 1.0));
}
double code(double x) {
	return 1.0 / ((1.0 + x) * (sqrt(x) + (x * sqrt(1.0 / (1.0 + x)))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.1
Target0.6
Herbie0.6
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}} \]

Derivation

  1. Initial program 20.1

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Applied flip--_binary6420.1

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

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

    \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}} \]
  5. Applied frac-sub_binary6419.6

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(1 + x\right) - x \cdot 1}{x \cdot \left(1 + x\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}} \]
  6. Applied associate-/l/_binary6419.6

    \[\leadsto \color{blue}{\frac{1 \cdot \left(1 + x\right) - x \cdot 1}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right) \cdot \left(x \cdot \left(1 + x\right)\right)}} \]
  7. Simplified19.6

    \[\leadsto \frac{1 \cdot \left(1 + x\right) - x \cdot 1}{\color{blue}{\mathsf{fma}\left(x, x, x\right) \cdot \left(\sqrt{\frac{1}{1 + x}} + \frac{1}{\sqrt{x}}\right)}} \]
  8. Taylor expanded in x around 0 5.3

    \[\leadsto \frac{\color{blue}{1}}{\mathsf{fma}\left(x, x, x\right) \cdot \left(\sqrt{\frac{1}{1 + x}} + \frac{1}{\sqrt{x}}\right)} \]
  9. Applied clear-num_binary645.3

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x, x, x\right) \cdot \left(\sqrt{\frac{1}{1 + x}} + \frac{1}{\sqrt{x}}\right)}{1}}} \]
  10. Simplified0.6

    \[\leadsto \frac{1}{\color{blue}{\left(1 + x\right) \cdot \left(\sqrt{x} + x \cdot \sqrt{\frac{1}{1 + x}}\right)}} \]
  11. Final simplification0.6

    \[\leadsto \frac{1}{\left(1 + x\right) \cdot \left(\sqrt{x} + x \cdot \sqrt{\frac{1}{1 + x}}\right)} \]

Reproduce

herbie shell --seed 2022067 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

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

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