Average Error: 31.3 → 12.2
Time: 2.9s
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 \le -2.066866671709845106834464667975644144779 \cdot 10^{108}:\\ \;\;\;\;\sqrt[3]{1}\\ \mathbf{elif}\;x \le -2.230998781219390577135425493386152824928 \cdot 10^{-162}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\ \mathbf{elif}\;x \le 2.739971083136069155135586033947620050619 \cdot 10^{-139}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.407738559615817036187877086095189380323 \cdot 10^{109}:\\ \;\;\;\;\frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{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 \le -2.066866671709845106834464667975644144779 \cdot 10^{108}:\\
\;\;\;\;\sqrt[3]{1}\\

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

\mathbf{elif}\;x \le 2.739971083136069155135586033947620050619 \cdot 10^{-139}:\\
\;\;\;\;-1\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{1}\\

\end{array}
double f(double x, double y) {
        double r634502 = x;
        double r634503 = r634502 * r634502;
        double r634504 = y;
        double r634505 = 4.0;
        double r634506 = r634504 * r634505;
        double r634507 = r634506 * r634504;
        double r634508 = r634503 - r634507;
        double r634509 = r634503 + r634507;
        double r634510 = r634508 / r634509;
        return r634510;
}

double f(double x, double y) {
        double r634511 = x;
        double r634512 = -2.066866671709845e+108;
        bool r634513 = r634511 <= r634512;
        double r634514 = 1.0;
        double r634515 = cbrt(r634514);
        double r634516 = -2.2309987812193906e-162;
        bool r634517 = r634511 <= r634516;
        double r634518 = r634511 * r634511;
        double r634519 = y;
        double r634520 = 4.0;
        double r634521 = r634519 * r634520;
        double r634522 = r634521 * r634519;
        double r634523 = r634518 - r634522;
        double r634524 = r634518 + r634522;
        double r634525 = r634523 / r634524;
        double r634526 = 3.0;
        double r634527 = pow(r634525, r634526);
        double r634528 = cbrt(r634527);
        double r634529 = 2.739971083136069e-139;
        bool r634530 = r634511 <= r634529;
        double r634531 = -1.0;
        double r634532 = 1.407738559615817e+109;
        bool r634533 = r634511 <= r634532;
        double r634534 = cbrt(r634523);
        double r634535 = r634534 * r634534;
        double r634536 = cbrt(r634524);
        double r634537 = r634536 * r634536;
        double r634538 = r634535 / r634537;
        double r634539 = r634534 / r634536;
        double r634540 = r634538 * r634539;
        double r634541 = r634533 ? r634540 : r634515;
        double r634542 = r634530 ? r634531 : r634541;
        double r634543 = r634517 ? r634528 : r634542;
        double r634544 = r634513 ? r634515 : r634543;
        return r634544;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original31.3
Target31.1
Herbie12.2
\[\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 4 regimes
  2. if x < -2.066866671709845e+108 or 1.407738559615817e+109 < x

    1. Initial program 52.9

      \[\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 add-cbrt-cube63.7

      \[\leadsto \frac{x \cdot x - \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)}}}\]
    4. Applied add-cbrt-cube64.0

      \[\leadsto \frac{\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)}}}{\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)}}\]
    5. Applied cbrt-undiv64.0

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\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)}{\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. Simplified52.9

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}}\]
    7. Taylor expanded around inf 10.6

      \[\leadsto \sqrt[3]{\color{blue}{1}}\]

    if -2.066866671709845e+108 < x < -2.2309987812193906e-162

    1. Initial program 15.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 add-cbrt-cube43.8

      \[\leadsto \frac{x \cdot x - \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)}}}\]
    4. Applied add-cbrt-cube44.1

      \[\leadsto \frac{\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)}}}{\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)}}\]
    5. Applied cbrt-undiv44.1

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\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)}{\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. Simplified15.7

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

    if -2.2309987812193906e-162 < x < 2.739971083136069e-139

    1. Initial program 29.8

      \[\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 0 8.0

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

    if 2.739971083136069e-139 < x < 1.407738559615817e+109

    1. Initial program 16.1

      \[\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 add-cube-cbrt17.1

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification12.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.066866671709845106834464667975644144779 \cdot 10^{108}:\\ \;\;\;\;\sqrt[3]{1}\\ \mathbf{elif}\;x \le -2.230998781219390577135425493386152824928 \cdot 10^{-162}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\ \mathbf{elif}\;x \le 2.739971083136069155135586033947620050619 \cdot 10^{-139}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.407738559615817036187877086095189380323 \cdot 10^{109}:\\ \;\;\;\;\frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019356 
(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))))