Average Error: 29.6 → 0.2
Time: 35.8s
Precision: binary64
Cost: 13248
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{1 + x} + \sqrt{x}}\]
\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));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Alternatives

Alternative 1
Error25.2
Cost26497
\[\begin{array}{l} \mathbf{if}\;\sqrt{1 + x} - \sqrt{x} \leq 0:\\ \;\;\;\;\frac{1}{1 + \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} - \sqrt{x}\\ \end{array}\]
Alternative 2
Error26.5
Cost6720
\[\frac{1}{1 + \sqrt{x}}\]
Alternative 3
Error30.9
Cost64
\[1\]

Error

Derivation

  1. Initial program 29.6

    \[\sqrt{x + 1} - \sqrt{x}\]
  2. Using strategy rm
  3. Applied flip--_binary64_141729.4

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

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity_binary64_14420.2

    \[\leadsto \frac{1}{\sqrt{x + 1} + \sqrt{\color{blue}{1 \cdot x}}}\]
  7. Applied sqrt-prod_binary64_14580.2

    \[\leadsto \frac{1}{\sqrt{x + 1} + \color{blue}{\sqrt{1} \cdot \sqrt{x}}}\]
  8. Applied *-un-lft-identity_binary64_14420.2

    \[\leadsto \frac{1}{\sqrt{\color{blue}{1 \cdot \left(x + 1\right)}} + \sqrt{1} \cdot \sqrt{x}}\]
  9. Applied sqrt-prod_binary64_14580.2

    \[\leadsto \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{x + 1}} + \sqrt{1} \cdot \sqrt{x}}\]
  10. Applied distribute-lft-out_binary64_13930.2

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

    \[\leadsto \frac{1}{\sqrt{1} \cdot \color{blue}{\left(\sqrt{1 + x} + \sqrt{x}\right)}}\]
  12. Using strategy rm
  13. Applied *-un-lft-identity_binary64_14420.2

    \[\leadsto \frac{1}{\sqrt{1} \cdot \left(\sqrt{1 + x} + \sqrt{\color{blue}{1 \cdot x}}\right)}\]
  14. Applied sqrt-prod_binary64_14580.2

    \[\leadsto \frac{1}{\sqrt{1} \cdot \left(\sqrt{1 + x} + \color{blue}{\sqrt{1} \cdot \sqrt{x}}\right)}\]
  15. Applied *-un-lft-identity_binary64_14420.2

    \[\leadsto \frac{1}{\sqrt{1} \cdot \left(\sqrt{\color{blue}{1 \cdot \left(1 + x\right)}} + \sqrt{1} \cdot \sqrt{x}\right)}\]
  16. Applied sqrt-prod_binary64_14580.2

    \[\leadsto \frac{1}{\sqrt{1} \cdot \left(\color{blue}{\sqrt{1} \cdot \sqrt{1 + x}} + \sqrt{1} \cdot \sqrt{x}\right)}\]
  17. Applied distribute-lft-out_binary64_13930.2

    \[\leadsto \frac{1}{\sqrt{1} \cdot \color{blue}{\left(\sqrt{1} \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)\right)}}\]
  18. Using strategy rm
  19. Applied pow1_binary64_15030.2

    \[\leadsto \frac{1}{\sqrt{1} \cdot \left(\sqrt{1} \cdot \left(\color{blue}{{\left(\sqrt{1 + x}\right)}^{1}} + \sqrt{x}\right)\right)}\]
  20. Simplified0.2

    \[\leadsto \color{blue}{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}\]
  21. Final simplification0.2

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

Reproduce

herbie shell --seed 2021014 
(FPCore (x)
  :name "2sqrt (example 3.1)"
  :precision binary64

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

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