Average Error: 32.2 → 12.8
Time: 9.8s
Precision: 64
\[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot x \le 2.757556978790064116743818529955834991566 \cdot 10^{-173}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.02761016817255949891811789914490538041 \cdot 10^{266}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \sqrt[3]{{\left(\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]
\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;x \cdot x \le 2.757556978790064116743818529955834991566 \cdot 10^{-173}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \le 1.02761016817255949891811789914490538041 \cdot 10^{266}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \sqrt[3]{{\left(\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\

\mathbf{else}:\\
\;\;\;\;1\\

\end{array}
double f(double x, double y) {
        double r444781 = x;
        double r444782 = r444781 * r444781;
        double r444783 = y;
        double r444784 = 4.0;
        double r444785 = r444783 * r444784;
        double r444786 = r444785 * r444783;
        double r444787 = r444782 - r444786;
        double r444788 = r444782 + r444786;
        double r444789 = r444787 / r444788;
        return r444789;
}

double f(double x, double y) {
        double r444790 = x;
        double r444791 = r444790 * r444790;
        double r444792 = 2.757556978790064e-173;
        bool r444793 = r444791 <= r444792;
        double r444794 = 1.0;
        double r444795 = -r444794;
        double r444796 = 1.0276101681725595e+266;
        bool r444797 = r444791 <= r444796;
        double r444798 = y;
        double r444799 = 4.0;
        double r444800 = r444798 * r444799;
        double r444801 = r444800 * r444798;
        double r444802 = r444791 + r444801;
        double r444803 = r444791 / r444802;
        double r444804 = r444801 / r444802;
        double r444805 = 3.0;
        double r444806 = pow(r444804, r444805);
        double r444807 = cbrt(r444806);
        double r444808 = r444803 - r444807;
        double r444809 = 1.0;
        double r444810 = r444797 ? r444808 : r444809;
        double r444811 = r444793 ? r444795 : r444810;
        return r444811;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original32.2
Target31.9
Herbie12.8
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y} \lt 0.9743233849626781184483093056769575923681:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot y\right) \cdot 4} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{x}{\sqrt{x \cdot x + \left(y \cdot y\right) \cdot 4}}\right)}^{2} - \frac{\left(y \cdot y\right) \cdot 4}{x \cdot x + \left(y \cdot y\right) \cdot 4}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* x x) < 2.757556978790064e-173

    1. Initial program 26.7

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Using strategy rm
    3. Applied div-sub26.7

      \[\leadsto \color{blue}{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]
    4. Taylor expanded around 0 12.0

      \[\leadsto \color{blue}{-1}\]

    if 2.757556978790064e-173 < (* x x) < 1.0276101681725595e+266

    1. Initial program 16.5

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

      \[\leadsto \color{blue}{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]
    4. Using strategy rm
    5. Applied add-cbrt-cube29.0

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot y}{\color{blue}{\sqrt[3]{\left(\left(x \cdot x + \left(y \cdot 4\right) \cdot y\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)}}}\]
    6. Applied add-cbrt-cube29.3

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot 4\right) \cdot \color{blue}{\sqrt[3]{\left(y \cdot y\right) \cdot y}}}{\sqrt[3]{\left(\left(x \cdot x + \left(y \cdot 4\right) \cdot y\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)}}\]
    7. Applied add-cbrt-cube29.3

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(y \cdot \color{blue}{\sqrt[3]{\left(4 \cdot 4\right) \cdot 4}}\right) \cdot \sqrt[3]{\left(y \cdot y\right) \cdot y}}{\sqrt[3]{\left(\left(x \cdot x + \left(y \cdot 4\right) \cdot y\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)}}\]
    8. Applied add-cbrt-cube29.3

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\left(\color{blue}{\sqrt[3]{\left(y \cdot y\right) \cdot y}} \cdot \sqrt[3]{\left(4 \cdot 4\right) \cdot 4}\right) \cdot \sqrt[3]{\left(y \cdot y\right) \cdot y}}{\sqrt[3]{\left(\left(x \cdot x + \left(y \cdot 4\right) \cdot y\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)}}\]
    9. Applied cbrt-unprod29.3

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\color{blue}{\sqrt[3]{\left(\left(y \cdot y\right) \cdot y\right) \cdot \left(\left(4 \cdot 4\right) \cdot 4\right)}} \cdot \sqrt[3]{\left(y \cdot y\right) \cdot y}}{\sqrt[3]{\left(\left(x \cdot x + \left(y \cdot 4\right) \cdot y\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)}}\]
    10. Applied cbrt-unprod30.5

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \frac{\color{blue}{\sqrt[3]{\left(\left(\left(y \cdot y\right) \cdot y\right) \cdot \left(\left(4 \cdot 4\right) \cdot 4\right)\right) \cdot \left(\left(y \cdot y\right) \cdot y\right)}}}{\sqrt[3]{\left(\left(x \cdot x + \left(y \cdot 4\right) \cdot y\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)}}\]
    11. Applied cbrt-undiv30.4

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \color{blue}{\sqrt[3]{\frac{\left(\left(\left(y \cdot y\right) \cdot y\right) \cdot \left(\left(4 \cdot 4\right) \cdot 4\right)\right) \cdot \left(\left(y \cdot y\right) \cdot y\right)}{\left(\left(x \cdot x + \left(y \cdot 4\right) \cdot y\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)\right) \cdot \left(x \cdot x + \left(y \cdot 4\right) \cdot y\right)}}}\]
    12. Simplified16.4

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \sqrt[3]{\color{blue}{{\left(\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}}\]

    if 1.0276101681725595e+266 < (* x x)

    1. Initial program 58.3

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Taylor expanded around inf 9.2

      \[\leadsto \color{blue}{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification12.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \le 2.757556978790064116743818529955834991566 \cdot 10^{-173}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.02761016817255949891811789914490538041 \cdot 10^{266}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \sqrt[3]{{\left(\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< (/ (- (* x x) (* (* y 4) y)) (+ (* x x) (* (* y 4) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4))) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4)))) 2) (/ (* (* y y) 4) (+ (* x x) (* (* y y) 4)))))

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