Average Error: 19.9 → 0.3
Time: 1.4min
Precision: binary64
Cost: 1024
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{x + \sqrt{x} \cdot \sqrt{1 + x}}}{\sqrt{1 + x}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\frac{1}{x + \sqrt{x} \cdot \sqrt{1 + x}}}{\sqrt{1 + x}}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (/ (/ 1.0 (+ x (* (sqrt x) (sqrt (+ 1.0 x))))) (sqrt (+ 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 / (x + (sqrt(x) * sqrt(1.0 + x)))) / sqrt(1.0 + x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.9
Target0.6
Herbie0.3
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]
Alternative 1
Accuracy0.4
Cost1088
\[\frac{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{1 + x} \cdot \sqrt{x}}\]
Alternative 2
Accuracy0.4
Cost1216
\[\frac{1}{\sqrt{1 + x} + \sqrt{x}} \cdot \frac{1}{\sqrt{1 + x} \cdot \sqrt{x}}\]
Alternative 3
Accuracy1.2
Cost2304
\[\frac{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt[3]{\sqrt{1 + x} \cdot \sqrt{x}} \cdot \left(\sqrt[3]{\sqrt{1 + x} \cdot \sqrt{x}} \cdot \sqrt[3]{\sqrt{1 + x} \cdot \sqrt{x}}\right)}\]
Alternative 4
Accuracy5.4
Cost1024
\[\frac{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}}\]
Alternative 5
Accuracy19.9
Cost960
\[\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x} \cdot \sqrt{x}}\]
Alternative 6
Accuracy19.9
Cost1600
\[\frac{\sqrt{\sqrt{1 + x} - \sqrt{x}}}{\sqrt{x}} \cdot \frac{\sqrt{\sqrt{1 + x} - \sqrt{x}}}{\sqrt{1 + x}}\]
Alternative 7
Accuracy51.4
Cost832
\[\log \left(e^{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}}}\right)\]

Derivation

  1. Initial program 19.9

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied frac-sub_binary64_213319.9

    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  4. Simplified19.9

    \[\leadsto \frac{\color{blue}{\sqrt{1 + x} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  5. Simplified19.9

    \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{\sqrt{x} \cdot \sqrt{1 + x}}}\]
  6. Using strategy rm
  7. Applied flip--_binary64_209919.7

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

    \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{x} \cdot \sqrt{1 + x}}\]
  9. Using strategy rm
  10. Applied associate-/r*_binary64_20680.4

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

    \[\leadsto \frac{\color{blue}{\frac{1}{x + \sqrt{x} \cdot \sqrt{x + 1}}}}{\sqrt{1 + x}}\]
  12. Using strategy rm
  13. Applied *-un-lft-identity_binary64_21240.3

    \[\leadsto \frac{\frac{1}{x + \sqrt{\color{blue}{1 \cdot x}} \cdot \sqrt{x + 1}}}{\sqrt{1 + x}}\]
  14. Applied sqrt-prod_binary64_21400.3

    \[\leadsto \frac{\frac{1}{x + \color{blue}{\left(\sqrt{1} \cdot \sqrt{x}\right)} \cdot \sqrt{x + 1}}}{\sqrt{1 + x}}\]
  15. Applied associate-*l*_binary64_20650.3

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

    \[\leadsto \frac{\frac{1}{x + \sqrt{x} \cdot \sqrt{1 + x}}}{\sqrt{1 + x}}\]

Reproduce

herbie shell --seed 2020322 
(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)))))