Average Error: 32.2 → 12.6
Time: 9.7s
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.517398075841731978978804721327597516736 \cdot 10^{145}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -6.621300319852041212687540142873364646976 \cdot 10^{-102}:\\ \;\;\;\;\left(\sqrt[3]{\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}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\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 1.295898151448028641074794033905884537542 \cdot 10^{-152}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 6.052303689076668472383783695774322400393 \cdot 10^{95}:\\ \;\;\;\;\left(\sqrt[3]{\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}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\ \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 -1.517398075841731978978804721327597516736 \cdot 10^{145}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -6.621300319852041212687540142873364646976 \cdot 10^{-102}:\\
\;\;\;\;\left(\sqrt[3]{\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}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\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 1.295898151448028641074794033905884537542 \cdot 10^{-152}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 6.052303689076668472383783695774322400393 \cdot 10^{95}:\\
\;\;\;\;\left(\sqrt[3]{\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}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\

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

\end{array}
double f(double x, double y) {
        double r548144 = x;
        double r548145 = r548144 * r548144;
        double r548146 = y;
        double r548147 = 4.0;
        double r548148 = r548146 * r548147;
        double r548149 = r548148 * r548146;
        double r548150 = r548145 - r548149;
        double r548151 = r548145 + r548149;
        double r548152 = r548150 / r548151;
        return r548152;
}

double f(double x, double y) {
        double r548153 = x;
        double r548154 = -1.517398075841732e+145;
        bool r548155 = r548153 <= r548154;
        double r548156 = 1.0;
        double r548157 = -6.621300319852041e-102;
        bool r548158 = r548153 <= r548157;
        double r548159 = r548153 * r548153;
        double r548160 = y;
        double r548161 = 4.0;
        double r548162 = r548160 * r548161;
        double r548163 = r548162 * r548160;
        double r548164 = r548159 - r548163;
        double r548165 = cbrt(r548164);
        double r548166 = r548165 * r548165;
        double r548167 = r548159 + r548163;
        double r548168 = cbrt(r548167);
        double r548169 = r548168 * r548168;
        double r548170 = r548166 / r548169;
        double r548171 = r548165 / r548168;
        double r548172 = r548170 * r548171;
        double r548173 = cbrt(r548172);
        double r548174 = r548164 / r548167;
        double r548175 = cbrt(r548174);
        double r548176 = r548173 * r548175;
        double r548177 = r548176 * r548175;
        double r548178 = 1.2958981514480286e-152;
        bool r548179 = r548153 <= r548178;
        double r548180 = -1.0;
        double r548181 = 6.052303689076668e+95;
        bool r548182 = r548153 <= r548181;
        double r548183 = r548182 ? r548177 : r548156;
        double r548184 = r548179 ? r548180 : r548183;
        double r548185 = r548158 ? r548177 : r548184;
        double r548186 = r548155 ? r548156 : r548185;
        return r548186;
}

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.6
\[\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 < -1.517398075841732e+145 or 6.052303689076668e+95 < x

    1. Initial program 55.2

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

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

    if -1.517398075841732e+145 < x < -6.621300319852041e-102 or 1.2958981514480286e-152 < x < 6.052303689076668e+95

    1. Initial program 17.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 \color{blue}{\left(\sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt17.3

      \[\leadsto \left(\sqrt[3]{\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}}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]
    6. Applied add-cube-cbrt17.1

      \[\leadsto \left(\sqrt[3]{\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}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]
    7. Applied times-frac17.1

      \[\leadsto \left(\sqrt[3]{\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}}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]

    if -6.621300319852041e-102 < x < 1.2958981514480286e-152

    1. Initial program 28.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.517398075841731978978804721327597516736 \cdot 10^{145}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -6.621300319852041212687540142873364646976 \cdot 10^{-102}:\\ \;\;\;\;\left(\sqrt[3]{\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}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\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 1.295898151448028641074794033905884537542 \cdot 10^{-152}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 6.052303689076668472383783695774322400393 \cdot 10^{95}:\\ \;\;\;\;\left(\sqrt[3]{\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}}} \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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