Average Error: 19.8 → 0.0
Time: 38.9s
Precision: 64
\[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}\]
\[\log \left(e^{\frac{\left(y + x\right) \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}}{\mathsf{hypot}\left(y, x\right)}}\right)\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\log \left(e^{\frac{\left(y + x\right) \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}}{\mathsf{hypot}\left(y, x\right)}}\right)
double f(double x, double y) {
        double r2747763 = x;
        double r2747764 = y;
        double r2747765 = r2747763 - r2747764;
        double r2747766 = r2747763 + r2747764;
        double r2747767 = r2747765 * r2747766;
        double r2747768 = r2747763 * r2747763;
        double r2747769 = r2747764 * r2747764;
        double r2747770 = r2747768 + r2747769;
        double r2747771 = r2747767 / r2747770;
        return r2747771;
}

double f(double x, double y) {
        double r2747772 = y;
        double r2747773 = x;
        double r2747774 = r2747772 + r2747773;
        double r2747775 = r2747773 - r2747772;
        double r2747776 = hypot(r2747772, r2747773);
        double r2747777 = r2747775 / r2747776;
        double r2747778 = r2747774 * r2747777;
        double r2747779 = r2747778 / r2747776;
        double r2747780 = exp(r2747779);
        double r2747781 = log(r2747780);
        return r2747781;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.8
Target0.0
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 19.8

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

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

    \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(y, y, x \cdot x\right)}{\left(x + y\right) \cdot \left(x - y\right)}}}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt19.8

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

    \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}{x + y} \cdot \frac{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}{x - y}}}\]
  8. Applied add-cube-cbrt19.7

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}{x + y} \cdot \frac{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}{x - y}}\]
  9. Applied times-frac19.7

    \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}{x + y}} \cdot \frac{\sqrt[3]{1}}{\frac{\sqrt{\mathsf{fma}\left(y, y, x \cdot x\right)}}{x - y}}}\]
  10. Simplified19.7

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

    \[\leadsto \frac{x + y}{\mathsf{hypot}\left(y, x\right)} \cdot \color{blue}{\frac{x - y}{\mathsf{hypot}\left(y, x\right)}}\]
  12. Using strategy rm
  13. Applied associate-*l/0.0

    \[\leadsto \color{blue}{\frac{\left(x + y\right) \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}}{\mathsf{hypot}\left(y, x\right)}}\]
  14. Using strategy rm
  15. Applied add-log-exp0.0

    \[\leadsto \color{blue}{\log \left(e^{\frac{\left(x + y\right) \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}}{\mathsf{hypot}\left(y, x\right)}}\right)}\]
  16. Final simplification0.0

    \[\leadsto \log \left(e^{\frac{\left(y + x\right) \cdot \frac{x - y}{\mathsf{hypot}\left(y, x\right)}}{\mathsf{hypot}\left(y, x\right)}}\right)\]

Reproduce

herbie shell --seed 2019151 +o rules:numerics
(FPCore (x y)
  :name "Kahan p9 Example"
  :pre (and (< 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))))