Average Error: 20.1 → 20.5
Time: 20.1s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\mathsf{fma}\left(\frac{1}{\sqrt{\sqrt[3]{x} \cdot \sqrt[3]{x}}}, \frac{1}{\sqrt{\sqrt[3]{x}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{-1}{\sqrt{\sqrt[3]{x + 1}}}\right) + \mathsf{fma}\left(\frac{-1}{\sqrt{\sqrt[3]{x + 1}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{1}{\sqrt{\sqrt[3]{x + 1}}}\right)\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\mathsf{fma}\left(\frac{1}{\sqrt{\sqrt[3]{x} \cdot \sqrt[3]{x}}}, \frac{1}{\sqrt{\sqrt[3]{x}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{-1}{\sqrt{\sqrt[3]{x + 1}}}\right) + \mathsf{fma}\left(\frac{-1}{\sqrt{\sqrt[3]{x + 1}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{1}{\sqrt{\sqrt[3]{x + 1}}}\right)
double f(double x) {
        double r3269634 = 1.0;
        double r3269635 = x;
        double r3269636 = sqrt(r3269635);
        double r3269637 = r3269634 / r3269636;
        double r3269638 = r3269635 + r3269634;
        double r3269639 = sqrt(r3269638);
        double r3269640 = r3269634 / r3269639;
        double r3269641 = r3269637 - r3269640;
        return r3269641;
}

double f(double x) {
        double r3269642 = 1.0;
        double r3269643 = x;
        double r3269644 = cbrt(r3269643);
        double r3269645 = r3269644 * r3269644;
        double r3269646 = sqrt(r3269645);
        double r3269647 = r3269642 / r3269646;
        double r3269648 = sqrt(r3269644);
        double r3269649 = r3269642 / r3269648;
        double r3269650 = r3269643 + r3269642;
        double r3269651 = cbrt(r3269650);
        double r3269652 = r3269651 * r3269651;
        double r3269653 = sqrt(r3269652);
        double r3269654 = r3269642 / r3269653;
        double r3269655 = -1.0;
        double r3269656 = sqrt(r3269651);
        double r3269657 = r3269655 / r3269656;
        double r3269658 = r3269654 * r3269657;
        double r3269659 = fma(r3269647, r3269649, r3269658);
        double r3269660 = r3269642 / r3269656;
        double r3269661 = r3269654 * r3269660;
        double r3269662 = fma(r3269657, r3269654, r3269661);
        double r3269663 = r3269659 + r3269662;
        return r3269663;
}

Error

Bits error versus x

Target

Original20.1
Target0.6
Herbie20.5
\[\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. Using strategy rm
  3. Applied add-cube-cbrt25.6

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

    \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \sqrt{\sqrt[3]{x + 1}}}}\]
  5. Applied add-sqr-sqrt25.9

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

    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1}}}}\]
  7. Applied add-cube-cbrt25.0

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

    \[\leadsto \frac{1}{\color{blue}{\sqrt{\sqrt[3]{x} \cdot \sqrt[3]{x}} \cdot \sqrt{\sqrt[3]{x}}}} - \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1}}}\]
  9. Applied *-un-lft-identity24.1

    \[\leadsto \frac{\color{blue}{1 \cdot 1}}{\sqrt{\sqrt[3]{x} \cdot \sqrt[3]{x}} \cdot \sqrt{\sqrt[3]{x}}} - \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1}}}\]
  10. Applied times-frac20.5

    \[\leadsto \color{blue}{\frac{1}{\sqrt{\sqrt[3]{x} \cdot \sqrt[3]{x}}} \cdot \frac{1}{\sqrt{\sqrt[3]{x}}}} - \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1}}}\]
  11. Applied prod-diff20.5

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{\sqrt[3]{x} \cdot \sqrt[3]{x}}}, \frac{1}{\sqrt{\sqrt[3]{x}}}, -\frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1}}} \cdot \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}\right) + \mathsf{fma}\left(-\frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1}}}, \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}, \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1}}} \cdot \frac{\sqrt{1}}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}\right)}\]
  12. Final simplification20.5

    \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt{\sqrt[3]{x} \cdot \sqrt[3]{x}}}, \frac{1}{\sqrt{\sqrt[3]{x}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{-1}{\sqrt{\sqrt[3]{x + 1}}}\right) + \mathsf{fma}\left(\frac{-1}{\sqrt{\sqrt[3]{x + 1}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}, \frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}} \cdot \frac{1}{\sqrt{\sqrt[3]{x + 1}}}\right)\]

Reproduce

herbie shell --seed 2019162 +o rules:numerics
(FPCore (x)
  :name "2isqrt (example 3.6)"

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

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