Average Error: 31.9 → 12.9
Time: 3.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 -1.287656836218587817843721098850935729447 \cdot 10^{137}:\\ \;\;\;\;\sqrt[3]{1}\\ \mathbf{elif}\;x \le \frac{-7090469231565941}{4.631683569492647816942839400347516314131 \cdot 10^{77}}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \le \frac{2207686351095}{1.347997333357531989733350754350981533682 \cdot 10^{67}}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le 3.168622066814080755323424526904394535226 \cdot 10^{74}:\\ \;\;\;\;\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{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 -1.287656836218587817843721098850935729447 \cdot 10^{137}:\\
\;\;\;\;\sqrt[3]{1}\\

\mathbf{elif}\;x \le \frac{-7090469231565941}{4.631683569492647816942839400347516314131 \cdot 10^{77}}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\

\mathbf{elif}\;x \le \frac{2207686351095}{1.347997333357531989733350754350981533682 \cdot 10^{67}}:\\
\;\;\;\;\frac{1}{-1}\\

\mathbf{elif}\;x \le 3.168622066814080755323424526904394535226 \cdot 10^{74}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;\sqrt[3]{1}\\

\end{array}
double f(double x, double y) {
        double r391986 = x;
        double r391987 = r391986 * r391986;
        double r391988 = y;
        double r391989 = 4.0;
        double r391990 = r391988 * r391989;
        double r391991 = r391990 * r391988;
        double r391992 = r391987 - r391991;
        double r391993 = r391987 + r391991;
        double r391994 = r391992 / r391993;
        return r391994;
}

double f(double x, double y) {
        double r391995 = x;
        double r391996 = -1.2876568362185878e+137;
        bool r391997 = r391995 <= r391996;
        double r391998 = 1.0;
        double r391999 = cbrt(r391998);
        double r392000 = -7090469231565941.0;
        double r392001 = 4.631683569492648e+77;
        double r392002 = r392000 / r392001;
        bool r392003 = r391995 <= r392002;
        double r392004 = r391995 * r391995;
        double r392005 = y;
        double r392006 = 4.0;
        double r392007 = r392005 * r392006;
        double r392008 = r392007 * r392005;
        double r392009 = r392004 + r392008;
        double r392010 = r392004 - r392008;
        double r392011 = r392009 / r392010;
        double r392012 = r391998 / r392011;
        double r392013 = 2207686351095.0;
        double r392014 = 1.347997333357532e+67;
        double r392015 = r392013 / r392014;
        bool r392016 = r391995 <= r392015;
        double r392017 = -1.0;
        double r392018 = r391998 / r392017;
        double r392019 = 3.168622066814081e+74;
        bool r392020 = r391995 <= r392019;
        double r392021 = r392010 / r392009;
        double r392022 = 3.0;
        double r392023 = pow(r392021, r392022);
        double r392024 = cbrt(r392023);
        double r392025 = r392020 ? r392024 : r391999;
        double r392026 = r392016 ? r392018 : r392025;
        double r392027 = r392003 ? r392012 : r392026;
        double r392028 = r391997 ? r391999 : r392027;
        return r392028;
}

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
Herbie12.9
\[\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 < -1.2876568362185878e+137 or 3.168622066814081e+74 < x

    1. Initial program 52.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 add-cbrt-cube63.6

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

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

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

    if -1.2876568362185878e+137 < x < -1.5308621854628612e-62

    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 clear-num15.9

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

    if -1.5308621854628612e-62 < x < 1.6377527584540488e-55

    1. Initial program 25.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 clear-num25.5

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

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

    if 1.6377527584540488e-55 < x < 3.168622066814081e+74

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

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

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

      \[\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}}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification12.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.287656836218587817843721098850935729447 \cdot 10^{137}:\\ \;\;\;\;\sqrt[3]{1}\\ \mathbf{elif}\;x \le \frac{-7090469231565941}{4.631683569492647816942839400347516314131 \cdot 10^{77}}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;x \le \frac{2207686351095}{1.347997333357531989733350754350981533682 \cdot 10^{67}}:\\ \;\;\;\;\frac{1}{-1}\\ \mathbf{elif}\;x \le 3.168622066814080755323424526904394535226 \cdot 10^{74}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;\sqrt[3]{1}\\ \end{array}\]

Reproduce

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