Average Error: 31.9 → 12.9
Time: 10.5s
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}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.530862185462861244589348861406538600327 \cdot 10^{-62}:\\ \;\;\;\;\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}\\ \mathbf{elif}\;x \le 1.637752758454048808996152623221730747955 \cdot 10^{-55}:\\ \;\;\;\;\sqrt[3]{-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}:\\ \;\;\;\;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}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -1.530862185462861244589348861406538600327 \cdot 10^{-62}:\\
\;\;\;\;\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}\\

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

\end{array}
double f(double x, double y) {
        double r454821 = x;
        double r454822 = r454821 * r454821;
        double r454823 = y;
        double r454824 = 4.0;
        double r454825 = r454823 * r454824;
        double r454826 = r454825 * r454823;
        double r454827 = r454822 - r454826;
        double r454828 = r454822 + r454826;
        double r454829 = r454827 / r454828;
        return r454829;
}

double f(double x, double y) {
        double r454830 = x;
        double r454831 = -1.2876568362185878e+137;
        bool r454832 = r454830 <= r454831;
        double r454833 = 1.0;
        double r454834 = -1.5308621854628612e-62;
        bool r454835 = r454830 <= r454834;
        double r454836 = r454830 * r454830;
        double r454837 = y;
        double r454838 = 4.0;
        double r454839 = r454837 * r454838;
        double r454840 = r454839 * r454837;
        double r454841 = r454836 + r454840;
        double r454842 = r454836 / r454841;
        double r454843 = r454840 / r454841;
        double r454844 = r454842 - r454843;
        double r454845 = 1.6377527584540488e-55;
        bool r454846 = r454830 <= r454845;
        double r454847 = -1.0;
        double r454848 = cbrt(r454847);
        double r454849 = 3.168622066814081e+74;
        bool r454850 = r454830 <= r454849;
        double r454851 = r454836 - r454840;
        double r454852 = r454851 / r454841;
        double r454853 = 3.0;
        double r454854 = pow(r454852, r454853);
        double r454855 = cbrt(r454854);
        double r454856 = r454850 ? r454855 : r454833;
        double r454857 = r454846 ? r454848 : r454856;
        double r454858 = r454835 ? r454844 : r454857;
        double r454859 = r454832 ? r454833 : r454858;
        return r454859;
}

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

    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 add-cbrt-cube52.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-cube52.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-undiv52.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. Simplified25.5

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

      \[\leadsto \sqrt[3]{\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}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.530862185462861244589348861406538600327 \cdot 10^{-62}:\\ \;\;\;\;\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}\\ \mathbf{elif}\;x \le 1.637752758454048808996152623221730747955 \cdot 10^{-55}:\\ \;\;\;\;\sqrt[3]{-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}:\\ \;\;\;\;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))))