Average Error: 19.9 → 0.1
Time: 32.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}\]
\[\left(\sqrt[3]{\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(y, x\right)}} \cdot \sqrt[3]{\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(y, x\right)}}\right) \cdot \sqrt[3]{\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(y, x\right)}}\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\left(\sqrt[3]{\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(y, x\right)}} \cdot \sqrt[3]{\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(y, x\right)}}\right) \cdot \sqrt[3]{\frac{x - y}{\mathsf{hypot}\left(y, x\right)} \cdot \frac{x + y}{\mathsf{hypot}\left(y, x\right)}}
double f(double x, double y) {
        double r79217 = x;
        double r79218 = y;
        double r79219 = r79217 - r79218;
        double r79220 = r79217 + r79218;
        double r79221 = r79219 * r79220;
        double r79222 = r79217 * r79217;
        double r79223 = r79218 * r79218;
        double r79224 = r79222 + r79223;
        double r79225 = r79221 / r79224;
        return r79225;
}

double f(double x, double y) {
        double r79226 = x;
        double r79227 = y;
        double r79228 = r79226 - r79227;
        double r79229 = hypot(r79227, r79226);
        double r79230 = r79228 / r79229;
        double r79231 = r79226 + r79227;
        double r79232 = r79231 / r79229;
        double r79233 = r79230 * r79232;
        double r79234 = cbrt(r79233);
        double r79235 = r79234 * r79234;
        double r79236 = r79235 * r79234;
        return r79236;
}

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.9
Target0.1
Herbie0.1
\[\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.9

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

    \[\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-sqrt19.9

    \[\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-frac20.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. Simplified20.0

    \[\leadsto \color{blue}{\frac{x - y}{\mathsf{hypot}\left(y, x\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(y, x\right)} \cdot \color{blue}{\frac{x + y}{\mathsf{hypot}\left(y, x\right)}}\]
  8. Using strategy rm
  9. Applied add-cube-cbrt0.1

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

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

Reproduce

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