Average Error: 31.4 → 13.8
Time: 13.8s
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 -4.75486451228188590222826906220099481589 \cdot 10^{122}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -4.332313917220748901311195815363194649965 \cdot 10^{80}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le -9211266202426181632:\\ \;\;\;\;\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)}\\ \mathbf{elif}\;x \le 2.139551810604105186057739335770012586275 \cdot 10^{-153}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 7.373518315070099961643182713875384049377 \cdot 10^{127}:\\ \;\;\;\;\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)}\\ \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 -4.75486451228188590222826906220099481589 \cdot 10^{122}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -4.332313917220748901311195815363194649965 \cdot 10^{80}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le -9211266202426181632:\\
\;\;\;\;\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)}\\

\mathbf{elif}\;x \le 2.139551810604105186057739335770012586275 \cdot 10^{-153}:\\
\;\;\;\;-1\\

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

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

\end{array}
double f(double x, double y) {
        double r40616965 = x;
        double r40616966 = r40616965 * r40616965;
        double r40616967 = y;
        double r40616968 = 4.0;
        double r40616969 = r40616967 * r40616968;
        double r40616970 = r40616969 * r40616967;
        double r40616971 = r40616966 - r40616970;
        double r40616972 = r40616966 + r40616970;
        double r40616973 = r40616971 / r40616972;
        return r40616973;
}

double f(double x, double y) {
        double r40616974 = x;
        double r40616975 = -4.754864512281886e+122;
        bool r40616976 = r40616974 <= r40616975;
        double r40616977 = 1.0;
        double r40616978 = -4.332313917220749e+80;
        bool r40616979 = r40616974 <= r40616978;
        double r40616980 = -1.0;
        double r40616981 = -9.211266202426182e+18;
        bool r40616982 = r40616974 <= r40616981;
        double r40616983 = r40616974 * r40616974;
        double r40616984 = y;
        double r40616985 = 4.0;
        double r40616986 = r40616984 * r40616985;
        double r40616987 = r40616986 * r40616984;
        double r40616988 = r40616983 + r40616987;
        double r40616989 = r40616983 / r40616988;
        double r40616990 = r40616987 / r40616988;
        double r40616991 = r40616989 - r40616990;
        double r40616992 = r40616991 * r40616991;
        double r40616993 = r40616992 * r40616991;
        double r40616994 = cbrt(r40616993);
        double r40616995 = 2.1395518106041052e-153;
        bool r40616996 = r40616974 <= r40616995;
        double r40616997 = 7.3735183150701e+127;
        bool r40616998 = r40616974 <= r40616997;
        double r40616999 = r40616998 ? r40616994 : r40616977;
        double r40617000 = r40616996 ? r40616980 : r40616999;
        double r40617001 = r40616982 ? r40616994 : r40617000;
        double r40617002 = r40616979 ? r40616980 : r40617001;
        double r40617003 = r40616976 ? r40616977 : r40617002;
        return r40617003;
}

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.4
Target31.1
Herbie13.8
\[\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 < -4.754864512281886e+122 or 7.3735183150701e+127 < x

    1. Initial program 56.1

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

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

    if -4.754864512281886e+122 < x < -4.332313917220749e+80 or -9.211266202426182e+18 < x < 2.1395518106041052e-153

    1. Initial program 24.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 0 15.6

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

    if -4.332313917220749e+80 < x < -9.211266202426182e+18 or 2.1395518106041052e-153 < x < 7.3735183150701e+127

    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 div-sub15.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-cube15.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.75486451228188590222826906220099481589 \cdot 10^{122}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -4.332313917220748901311195815363194649965 \cdot 10^{80}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le -9211266202426181632:\\ \;\;\;\;\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)}\\ \mathbf{elif}\;x \le 2.139551810604105186057739335770012586275 \cdot 10^{-153}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 7.373518315070099961643182713875384049377 \cdot 10^{127}:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(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))))