Average Error: 20.3 → 0.0
Time: 17.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}\]
\[\frac{1}{\frac{\mathsf{hypot}\left(x, y\right)}{y + x}} \cdot \sqrt[3]{{\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)}\right)}^{3}}\]
\frac{\left(x - y\right) \cdot \left(x + y\right)}{x \cdot x + y \cdot y}
\frac{1}{\frac{\mathsf{hypot}\left(x, y\right)}{y + x}} \cdot \sqrt[3]{{\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)}\right)}^{3}}
double f(double x, double y) {
        double r47843 = x;
        double r47844 = y;
        double r47845 = r47843 - r47844;
        double r47846 = r47843 + r47844;
        double r47847 = r47845 * r47846;
        double r47848 = r47843 * r47843;
        double r47849 = r47844 * r47844;
        double r47850 = r47848 + r47849;
        double r47851 = r47847 / r47850;
        return r47851;
}

double f(double x, double y) {
        double r47852 = 1.0;
        double r47853 = x;
        double r47854 = y;
        double r47855 = hypot(r47853, r47854);
        double r47856 = r47854 + r47853;
        double r47857 = r47855 / r47856;
        double r47858 = r47852 / r47857;
        double r47859 = r47853 - r47854;
        double r47860 = r47859 / r47855;
        double r47861 = 3.0;
        double r47862 = pow(r47860, r47861);
        double r47863 = cbrt(r47862);
        double r47864 = r47858 * r47863;
        return r47864;
}

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

    \[\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.3

    \[\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 times-frac20.4

    \[\leadsto \color{blue}{\frac{x - y}{\sqrt{x \cdot x + y \cdot y}} \cdot \frac{x + y}{\sqrt{x \cdot x + y \cdot y}}}\]
  5. Simplified20.3

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

    \[\leadsto \frac{x - y}{\mathsf{hypot}\left(x, y\right)} \cdot \color{blue}{\frac{y + x}{\mathsf{hypot}\left(x, y\right)}}\]
  7. Using strategy rm
  8. Applied add-cbrt-cube32.4

    \[\leadsto \frac{x - y}{\color{blue}{\sqrt[3]{\left(\mathsf{hypot}\left(x, y\right) \cdot \mathsf{hypot}\left(x, y\right)\right) \cdot \mathsf{hypot}\left(x, y\right)}}} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\]
  9. Applied add-cbrt-cube32.3

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

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

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x - y}{\mathsf{hypot}\left(x, y\right)}\right)}^{3}}} \cdot \frac{y + x}{\mathsf{hypot}\left(x, y\right)}\]
  12. Using strategy rm
  13. Applied clear-num0.0

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

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

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(FPCore (x y)
  :name "Kahan p9 Example"
  :pre (and (< 0.0 x 1.0) (< y 1.0))

  :herbie-target
  (if (< 0.5 (fabs (/ x y)) 2.0) (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))) (- 1.0 (/ 2.0 (+ 1.0 (* (/ x y) (/ x y))))))

  (/ (* (- x y) (+ x y)) (+ (* x x) (* y y))))