Average Error: 20.4 → 0.0
Time: 7.6s
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}\]
\[\log \left(e^{\frac{\frac{x - y}{\mathsf{hypot}\left(x, y\right)}}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}}\right)\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\log \left(e^{\frac{\frac{x - y}{\mathsf{hypot}\left(x, y\right)}}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}}\right)
double f(double x, double y) {
        double r104425 = x;
        double r104426 = y;
        double r104427 = r104425 - r104426;
        double r104428 = r104425 + r104426;
        double r104429 = r104427 * r104428;
        double r104430 = r104425 * r104425;
        double r104431 = r104426 * r104426;
        double r104432 = r104430 + r104431;
        double r104433 = r104429 / r104432;
        return r104433;
}

double f(double x, double y) {
        double r104434 = x;
        double r104435 = y;
        double r104436 = r104434 - r104435;
        double r104437 = hypot(r104434, r104435);
        double r104438 = r104436 / r104437;
        double r104439 = r104434 + r104435;
        double r104440 = r104437 / r104439;
        double r104441 = r104438 / r104440;
        double r104442 = exp(r104441);
        double r104443 = log(r104442);
        return r104443;
}

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.4
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 20.4

    \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt20.4

    \[\leadsto \frac{\left(x - y\right) \cdot \left(x + y\right)}{\color{blue}{\sqrt{x \cdot x + y \cdot y} \cdot \sqrt{x \cdot x + y \cdot y}}}\]
  4. Applied associate-/r*20.4

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

    \[\leadsto \frac{\color{blue}{\frac{x - y}{\frac{\mathsf{hypot}\left(x, y\right)}{x + y}}}}{\sqrt{x \cdot x + y \cdot y}}\]
  6. Using strategy rm
  7. Applied associate-/r/20.5

    \[\leadsto \frac{\color{blue}{\frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \left(x + y\right)}}{\sqrt{x \cdot x + y \cdot y}}\]
  8. Applied associate-/l*20.5

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

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

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

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

Reproduce

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