Average Error: 30.3 → 0.2
Time: 50.3s
Precision: binary64
Cost: 13248
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{x} + \sqrt{1 + x}}\]
\sqrt{x + 1} - \sqrt{x}
\frac{1}{\sqrt{x} + \sqrt{1 + x}}
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
	return sqrt(x + 1.0) - sqrt(x);
}
double code(double x) {
	return 1.0 / (sqrt(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

Original30.3
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Alternatives

Alternative 1
Error25.7
Cost13441
\[\begin{array}{l} \mathbf{if}\;x \leq 4462433962459409.5:\\ \;\;\;\;\sqrt{1 + x} - \sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + \sqrt{x}}\\ \end{array}\]
Alternative 2
Error27.1
Cost6720
\[\frac{1}{1 + \sqrt{x}}\]
Alternative 3
Error31.7
Cost64
\[1\]

Error

Time

Derivation

  1. Initial program 30.3

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

    \[\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 inv-pow_binary64_18680.2

    \[\leadsto \color{blue}{{\left(\sqrt{x + 1} + \sqrt{x}\right)}^{-1}}\]
  7. Using strategy rm
  8. Applied *-un-lft-identity_binary64_17830.2

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

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

    \[\leadsto {\left(\sqrt{\color{blue}{1 \cdot \left(x + 1\right)}} + \sqrt{1} \cdot \sqrt{x}\right)}^{-1}\]
  11. Applied sqrt-prod_binary64_17990.2

    \[\leadsto {\left(\color{blue}{\sqrt{1} \cdot \sqrt{x + 1}} + \sqrt{1} \cdot \sqrt{x}\right)}^{-1}\]
  12. Applied distribute-lft-out_binary64_17340.2

    \[\leadsto {\color{blue}{\left(\sqrt{1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)\right)}}^{-1}\]
  13. Using strategy rm
  14. Applied unpow-1_binary64_18400.2

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

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

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

Reproduce

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