Average Error: 20.5 → 0.0
Time: 4.2s
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}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x + y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x - y}}\right)\right)\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x + y}{\mathsf{hypot}\left(x, y\right) \cdot \frac{\mathsf{hypot}\left(x, y\right)}{x - y}}\right)\right)
double f(double x, double y) {
        double r73271 = x;
        double r73272 = y;
        double r73273 = r73271 - r73272;
        double r73274 = r73271 + r73272;
        double r73275 = r73273 * r73274;
        double r73276 = r73271 * r73271;
        double r73277 = r73272 * r73272;
        double r73278 = r73276 + r73277;
        double r73279 = r73275 / r73278;
        return r73279;
}

double f(double x, double y) {
        double r73280 = x;
        double r73281 = y;
        double r73282 = r73280 + r73281;
        double r73283 = hypot(r73280, r73281);
        double r73284 = r73280 - r73281;
        double r73285 = r73283 / r73284;
        double r73286 = r73283 * r73285;
        double r73287 = r73282 / r73286;
        double r73288 = expm1(r73287);
        double r73289 = log1p(r73288);
        return r73289;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.5
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 20.5

    \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
  2. Using strategy rm
  3. Applied add-cbrt-cube47.0

    \[\leadsto \frac{\left(x - y\right) \cdot \left(x + y\right)}{\color{blue}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}}\]
  4. Applied add-cbrt-cube47.1

    \[\leadsto \frac{\left(x - y\right) \cdot \color{blue}{\sqrt[3]{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}\]
  5. Applied add-cbrt-cube47.2

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}} \cdot \sqrt[3]{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)}}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}\]
  6. Applied cbrt-unprod46.9

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)\right) \cdot \left(\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)\right)}}}{\sqrt[3]{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}\]
  7. Applied cbrt-undiv46.8

    \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)\right) \cdot \left(\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(x + y\right)\right)}{\left(\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x + y \cdot y\right)\right) \cdot \left(x \cdot x + y \cdot y\right)}}}\]
  8. Simplified20.5

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x + y}{\frac{\mathsf{fma}\left(x, x, y \cdot y\right)}{x - y}}\right)}^{3}}}\]
  9. Using strategy rm
  10. Applied log1p-expm1-u20.5

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt[3]{{\left(\frac{x + y}{\frac{\mathsf{fma}\left(x, x, y \cdot y\right)}{x - y}}\right)}^{3}}\right)\right)}\]
  11. Simplified20.6

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\frac{x + y}{\frac{\mathsf{fma}\left(x, x, y \cdot y\right)}{x - y}}\right)}\right)\]
  12. Using strategy rm
  13. Applied *-un-lft-identity20.6

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x + y}{\frac{\mathsf{fma}\left(x, x, y \cdot y\right)}{\color{blue}{1 \cdot \left(x - y\right)}}}\right)\right)\]
  14. Applied add-sqr-sqrt20.6

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x + y}{\frac{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)} \cdot \sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}}{1 \cdot \left(x - y\right)}}\right)\right)\]
  15. Applied times-frac20.5

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x + y}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}{1} \cdot \frac{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}{x - y}}}\right)\right)\]
  16. Simplified20.5

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

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

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

Reproduce

herbie shell --seed 2020065 +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))))