Average Error: 19.4 → 0.4
Time: 15.2s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1 \cdot 1}{x}}{1} \cdot \frac{\frac{1}{x + 1}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\frac{1 \cdot 1}{x}}{1} \cdot \frac{\frac{1}{x + 1}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}
double f(double x) {
        double r129990 = 1.0;
        double r129991 = x;
        double r129992 = sqrt(r129991);
        double r129993 = r129990 / r129992;
        double r129994 = r129991 + r129990;
        double r129995 = sqrt(r129994);
        double r129996 = r129990 / r129995;
        double r129997 = r129993 - r129996;
        return r129997;
}

double f(double x) {
        double r129998 = 1.0;
        double r129999 = r129998 * r129998;
        double r130000 = x;
        double r130001 = r129999 / r130000;
        double r130002 = r130001 / r129998;
        double r130003 = r130000 + r129998;
        double r130004 = r129998 / r130003;
        double r130005 = 1.0;
        double r130006 = sqrt(r130000);
        double r130007 = r130005 / r130006;
        double r130008 = sqrt(r130003);
        double r130009 = r130005 / r130008;
        double r130010 = r130007 + r130009;
        double r130011 = r130004 / r130010;
        double r130012 = r130002 * r130011;
        return r130012;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 19.4

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

    \[\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}}}}\]
  4. Using strategy rm
  5. Applied frac-times24.6

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

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

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

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

    \[\leadsto \frac{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\color{blue}{x \cdot \left(x + 1\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  10. Taylor expanded around 0 5.6

    \[\leadsto \frac{\frac{\left(1 \cdot 1\right) \cdot \color{blue}{1}}{x \cdot \left(x + 1\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  11. Using strategy rm
  12. Applied div-inv5.6

    \[\leadsto \frac{\frac{\left(1 \cdot 1\right) \cdot 1}{x \cdot \left(x + 1\right)}}{\frac{1}{\sqrt{x}} + \color{blue}{1 \cdot \frac{1}{\sqrt{x + 1}}}}\]
  13. Applied div-inv5.6

    \[\leadsto \frac{\frac{\left(1 \cdot 1\right) \cdot 1}{x \cdot \left(x + 1\right)}}{\color{blue}{1 \cdot \frac{1}{\sqrt{x}}} + 1 \cdot \frac{1}{\sqrt{x + 1}}}\]
  14. Applied distribute-lft-out5.6

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

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

    \[\leadsto \color{blue}{\frac{\frac{1 \cdot 1}{x}}{1} \cdot \frac{\frac{1}{x + 1}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
  17. Final simplification0.4

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

Reproduce

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

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

  (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))