Average Error: 19.8 → 0.1
Time: 21.7s
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}\]
\[\sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)} \cdot \left(\sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)} \cdot \sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)}\right)\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)} \cdot \left(\sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)} \cdot \sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)}\right)
double f(double x, double y) {
        double r1425260 = x;
        double r1425261 = y;
        double r1425262 = r1425260 - r1425261;
        double r1425263 = r1425260 + r1425261;
        double r1425264 = r1425262 * r1425263;
        double r1425265 = r1425260 * r1425260;
        double r1425266 = r1425261 * r1425261;
        double r1425267 = r1425265 + r1425266;
        double r1425268 = r1425264 / r1425267;
        return r1425268;
}

double f(double x, double y) {
        double r1425269 = 1.0;
        double r1425270 = y;
        double r1425271 = x;
        double r1425272 = hypot(r1425270, r1425271);
        double r1425273 = r1425269 / r1425272;
        double r1425274 = r1425270 + r1425271;
        double r1425275 = r1425274 / r1425272;
        double r1425276 = r1425271 - r1425270;
        double r1425277 = r1425275 * r1425276;
        double r1425278 = r1425273 * r1425277;
        double r1425279 = cbrt(r1425278);
        double r1425280 = r1425279 * r1425279;
        double r1425281 = r1425279 * r1425280;
        return r1425281;
}

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.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.8

    \[\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}\]
  2. Using strategy rm
  3. Applied clear-num19.8

    \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + y \cdot y}{\left(x - y\right) \cdot \left(x + y\right)}}}\]
  4. Simplified19.8

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(x, x, y \cdot y\right)}{x \cdot x - y \cdot y}}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity19.8

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

    \[\leadsto \frac{1}{\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 \cdot x - y \cdot y\right)}}\]
  8. Applied times-frac20.0

    \[\leadsto \frac{1}{\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 \cdot x - y \cdot y}}}\]
  9. Applied add-cube-cbrt20.0

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\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 \cdot x - y \cdot y}}\]
  10. Applied times-frac20.0

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

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

    \[\leadsto \frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \color{blue}{\left(\frac{1 \cdot \left(y + x\right)}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)}\]
  13. Using strategy rm
  14. Applied add-cube-cbrt0.1

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

    \[\leadsto \sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)} \cdot \left(\sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\right)} \cdot \sqrt[3]{\frac{1}{\mathsf{hypot}\left(y, x\right)} \cdot \left(\frac{y + x}{\mathsf{hypot}\left(y, x\right)} \cdot \left(x - y\right)\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))))