Average Error: 19.8 → 0.0
Time: 19.2s
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{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}}\right)\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\log \left(e^{\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(x, y\right)}}\right)
double f(double x, double y) {
        double r3385948 = x;
        double r3385949 = y;
        double r3385950 = r3385948 - r3385949;
        double r3385951 = r3385948 + r3385949;
        double r3385952 = r3385950 * r3385951;
        double r3385953 = r3385948 * r3385948;
        double r3385954 = r3385949 * r3385949;
        double r3385955 = r3385953 + r3385954;
        double r3385956 = r3385952 / r3385955;
        return r3385956;
}

double f(double x, double y) {
        double r3385957 = x;
        double r3385958 = y;
        double r3385959 = r3385957 - r3385958;
        double r3385960 = hypot(r3385957, r3385958);
        double r3385961 = r3385959 / r3385960;
        double r3385962 = r3385957 + r3385958;
        double r3385963 = r3385962 / r3385960;
        double r3385964 = r3385961 * r3385963;
        double r3385965 = exp(r3385964);
        double r3385966 = log(r3385965);
        return r3385966;
}

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(y + x\right)}{\mathsf{fma}\left(x, x, y \cdot y\right)}}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt19.8

    \[\leadsto \frac{\left(x - y\right) \cdot \left(y + x\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-frac19.9

    \[\leadsto \color{blue}{\frac{x - y}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}} \cdot \frac{y + x}{\sqrt{\mathsf{fma}\left(x, x, y \cdot y\right)}}}\]
  6. Using strategy rm
  7. Applied add-log-exp19.9

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

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

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

Reproduce

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