Average Error: 31.3 → 13.1
Time: 10.0s
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 -3.678618962503878310745576389575152495213 \cdot 10^{116}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -8.91382032886151303081735495699643417157 \cdot 10^{-31}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(4 \cdot y\right) \cdot y}{\left(4 \cdot y\right) \cdot y + x \cdot x}\right)}^{3}}\\ \mathbf{elif}\;x \le 2.212351303084648640066472729364795186343 \cdot 10^{-67}:\\ \;\;\;\;\sqrt[3]{{-1}^{3}}\\ \mathbf{elif}\;x \le 3.163054238082631393165515878127431023232 \cdot 10^{87}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(4 \cdot y\right) \cdot y}{\left(4 \cdot y\right) \cdot y + x \cdot x}\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 -3.678618962503878310745576389575152495213 \cdot 10^{116}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \le 2.212351303084648640066472729364795186343 \cdot 10^{-67}:\\
\;\;\;\;\sqrt[3]{{-1}^{3}}\\

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

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

\end{array}
double f(double x, double y) {
        double r515154 = x;
        double r515155 = r515154 * r515154;
        double r515156 = y;
        double r515157 = 4.0;
        double r515158 = r515156 * r515157;
        double r515159 = r515158 * r515156;
        double r515160 = r515155 - r515159;
        double r515161 = r515155 + r515159;
        double r515162 = r515160 / r515161;
        return r515162;
}

double f(double x, double y) {
        double r515163 = x;
        double r515164 = -3.678618962503878e+116;
        bool r515165 = r515163 <= r515164;
        double r515166 = 1.0;
        double r515167 = -8.913820328861513e-31;
        bool r515168 = r515163 <= r515167;
        double r515169 = r515163 * r515163;
        double r515170 = 4.0;
        double r515171 = y;
        double r515172 = r515170 * r515171;
        double r515173 = r515172 * r515171;
        double r515174 = r515169 - r515173;
        double r515175 = r515173 + r515169;
        double r515176 = r515174 / r515175;
        double r515177 = 3.0;
        double r515178 = pow(r515176, r515177);
        double r515179 = cbrt(r515178);
        double r515180 = 2.2123513030846486e-67;
        bool r515181 = r515163 <= r515180;
        double r515182 = -1.0;
        double r515183 = pow(r515182, r515177);
        double r515184 = cbrt(r515183);
        double r515185 = 3.1630542380826314e+87;
        bool r515186 = r515163 <= r515185;
        double r515187 = r515186 ? r515179 : r515166;
        double r515188 = r515181 ? r515184 : r515187;
        double r515189 = r515168 ? r515179 : r515188;
        double r515190 = r515165 ? r515166 : r515189;
        return r515190;
}

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.0
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 3 regimes
  2. if x < -3.678618962503878e+116 or 3.1630542380826314e+87 < x

    1. Initial program 52.1

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Simplified52.1

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

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

    if -3.678618962503878e+116 < x < -8.913820328861513e-31 or 2.2123513030846486e-67 < x < 3.1630542380826314e+87

    1. Initial program 14.9

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Simplified14.9

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

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

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

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

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

    if -8.913820328861513e-31 < x < 2.2123513030846486e-67

    1. Initial program 24.8

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    2. Simplified24.8

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

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

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

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

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

      \[\leadsto \sqrt[3]{{\color{blue}{-1}}^{3}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification13.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.678618962503878310745576389575152495213 \cdot 10^{116}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -8.91382032886151303081735495699643417157 \cdot 10^{-31}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(4 \cdot y\right) \cdot y}{\left(4 \cdot y\right) \cdot y + x \cdot x}\right)}^{3}}\\ \mathbf{elif}\;x \le 2.212351303084648640066472729364795186343 \cdot 10^{-67}:\\ \;\;\;\;\sqrt[3]{{-1}^{3}}\\ \mathbf{elif}\;x \le 3.163054238082631393165515878127431023232 \cdot 10^{87}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(4 \cdot y\right) \cdot y}{\left(4 \cdot y\right) \cdot y + x \cdot x}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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

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

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