Average Error: 31.9 → 13.1
Time: 9.4s
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.037620220306589920571806417099506602023 \cdot 10^{149}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -5.301161031949812436014753866372397601436 \cdot 10^{-111}:\\ \;\;\;\;\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{elif}\;x \le 0.003134716524964163350541745955979422433302:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.042090748945731696259607097644535350077 \cdot 10^{130}:\\ \;\;\;\;\sqrt[3]{{\left(\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}\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 \le -2.037620220306589920571806417099506602023 \cdot 10^{149}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -5.301161031949812436014753866372397601436 \cdot 10^{-111}:\\
\;\;\;\;\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{elif}\;x \le 0.003134716524964163350541745955979422433302:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 1.042090748945731696259607097644535350077 \cdot 10^{130}:\\
\;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\

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

\end{array}
double f(double x, double y) {
        double r505101 = x;
        double r505102 = r505101 * r505101;
        double r505103 = y;
        double r505104 = 4.0;
        double r505105 = r505103 * r505104;
        double r505106 = r505105 * r505103;
        double r505107 = r505102 - r505106;
        double r505108 = r505102 + r505106;
        double r505109 = r505107 / r505108;
        return r505109;
}

double f(double x, double y) {
        double r505110 = x;
        double r505111 = -2.03762022030659e+149;
        bool r505112 = r505110 <= r505111;
        double r505113 = 1.0;
        double r505114 = -5.3011610319498124e-111;
        bool r505115 = r505110 <= r505114;
        double r505116 = r505110 * r505110;
        double r505117 = y;
        double r505118 = 4.0;
        double r505119 = r505117 * r505118;
        double r505120 = r505119 * r505117;
        double r505121 = r505116 + r505120;
        double r505122 = r505116 / r505121;
        double r505123 = r505120 / r505121;
        double r505124 = 3.0;
        double r505125 = pow(r505123, r505124);
        double r505126 = cbrt(r505125);
        double r505127 = r505122 - r505126;
        double r505128 = 0.0031347165249641634;
        bool r505129 = r505110 <= r505128;
        double r505130 = -1.0;
        double r505131 = 1.0420907489457317e+130;
        bool r505132 = r505110 <= r505131;
        double r505133 = r505122 - r505123;
        double r505134 = pow(r505133, r505124);
        double r505135 = cbrt(r505134);
        double r505136 = r505132 ? r505135 : r505113;
        double r505137 = r505129 ? r505130 : r505136;
        double r505138 = r505115 ? r505127 : r505137;
        double r505139 = r505112 ? r505113 : r505138;
        return r505139;
}

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.9
Target31.6
Herbie13.1
\[\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.03762022030659e+149 or 1.0420907489457317e+130 < x

    1. Initial program 59.5

      \[\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}\]

    if -2.03762022030659e+149 < x < -5.3011610319498124e-111

    1. Initial program 15.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 div-sub15.9

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

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

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

      \[\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-unprod32.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-undiv32.5

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

      \[\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 -5.3011610319498124e-111 < x < 0.0031347165249641634

    1. Initial program 24.7

      \[\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 13.6

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

    if 0.0031347165249641634 < x < 1.0420907489457317e+130

    1. Initial program 16.3

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

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

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\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}\right) \cdot \left(\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}\right)\right) \cdot \left(\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}\right)}}\]
    6. Simplified16.4

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\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}\right)}^{3}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification13.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.037620220306589920571806417099506602023 \cdot 10^{149}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -5.301161031949812436014753866372397601436 \cdot 10^{-111}:\\ \;\;\;\;\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{elif}\;x \le 0.003134716524964163350541745955979422433302:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.042090748945731696259607097644535350077 \cdot 10^{130}:\\ \;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2019294 
(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.974323384962678118) (- (/ (* 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))))