Average Error: 21.0 → 0.0
Time: 7.5s
Precision: 64
\[0.0 \lt x \lt 1 \land y \lt 1\]
\[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
\[\sqrt[3]{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}\right)\right)\right)}^{3}}\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\sqrt[3]{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}\right)\right)\right)}^{3}}
double f(double x, double y) {
        double r67920 = x;
        double r67921 = y;
        double r67922 = r67920 - r67921;
        double r67923 = r67920 + r67921;
        double r67924 = r67922 * r67923;
        double r67925 = r67920 * r67920;
        double r67926 = r67921 * r67921;
        double r67927 = r67925 + r67926;
        double r67928 = r67924 / r67927;
        return r67928;
}

double f(double x, double y) {
        double r67929 = x;
        double r67930 = y;
        double r67931 = r67929 - r67930;
        double r67932 = hypot(r67929, r67930);
        double r67933 = r67931 / r67932;
        double r67934 = r67929 + r67930;
        double r67935 = r67934 / r67932;
        double r67936 = r67933 * r67935;
        double r67937 = expm1(r67936);
        double r67938 = log1p(r67937);
        double r67939 = 3.0;
        double r67940 = pow(r67938, r67939);
        double r67941 = cbrt(r67940);
        return r67941;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original21.0
Target0.1
Herbie0.0
\[\begin{array}{l} \mathbf{if}\;0.5 \lt \left|\frac{x}{y}\right| \lt 2:\\ \;\;\;\;\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{2}{1 + \frac{x}{y} \cdot \frac{x}{y}}\\ \end{array}\]

Derivation

  1. Initial program 21.0

    \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
  2. Simplified21.0

    \[\leadsto \color{blue}{\frac{\left(x - y\right) \cdot \left(x + y\right)}{\mathsf{fma}\left(x, x, y \cdot y\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt21.0

    \[\leadsto \frac{\left(x - y\right) \cdot \left(x + y\right)}{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}}\]
  5. Applied times-frac21.0

    \[\leadsto \color{blue}{\frac{x - y}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}} \cdot \frac{x + y}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}}\]
  6. Simplified21.0

    \[\leadsto \color{blue}{\frac{x - y}{\mathsf{hypot}\left(x, y\right)}} \cdot \frac{x + y}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}\]
  7. Simplified0.0

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \color{blue}{\frac{x + y}{\mathsf{hypot}\left(x, y\right)}}\]
  8. Using strategy rm
  9. Applied add-cbrt-cube32.8

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\color{blue}{\sqrt[3]{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}}\]
  10. Applied add-cbrt-cube32.6

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{\color{blue}{\sqrt[3]{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}{\sqrt[3]{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}\]
  11. Applied cbrt-undiv32.6

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \color{blue}{\sqrt[3]{\frac{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}}\]
  12. Applied add-cbrt-cube33.3

    \[\leadsto \frac{x - y}{\color{blue}{\sqrt[3]{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}} \cdot \sqrt[3]{\frac{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}\]
  13. Applied add-cbrt-cube32.6

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}}}{\sqrt[3]{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}} \cdot \sqrt[3]{\frac{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}\]
  14. Applied cbrt-undiv32.6

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}} \cdot \sqrt[3]{\frac{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}\]
  15. Applied cbrt-unprod32.6

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)} \cdot \frac{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}}\]
  16. Simplified0.0

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}\right)}^{3}}}\]
  17. Using strategy rm
  18. Applied log1p-expm1-u0.0

    \[\leadsto \sqrt[3]{{\color{blue}{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}\right)\right)\right)}}^{3}}\]
  19. Final simplification0.0

    \[\leadsto \sqrt[3]{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}\right)\right)\right)}^{3}}\]

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x y)
  :name "Kahan p9 Example"
  :precision binary64
  :pre (and (< 0.0 x 1) (< y 1))

  :herbie-target
  (if (< 0.5 (fabs (/ x y)) 2) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1 (/ 2 (+ 1 (* (/ x y) (/ x y))))))

  (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))