Average Error: 32.3 → 13.6
Time: 6.3s
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}\;y \le -7.71073899284975746 \cdot 10^{142}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -1.38415960656676321 \cdot 10^{-97}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\ \mathbf{elif}\;y \le 1.1196094733529732 \cdot 10^{-55}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 28161126.972837694:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\ \mathbf{elif}\;y \le 4.01162503157803517 \cdot 10^{38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 2.16201455188241352 \cdot 10^{107}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\ \mathbf{elif}\;y \le 4.36744780112662469 \cdot 10^{128}:\\ \;\;\;\;1\\ \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}\;y \le -7.71073899284975746 \cdot 10^{142}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \le -1.38415960656676321 \cdot 10^{-97}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\

\mathbf{elif}\;y \le 1.1196094733529732 \cdot 10^{-55}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \le 28161126.972837694:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\

\mathbf{elif}\;y \le 4.01162503157803517 \cdot 10^{38}:\\
\;\;\;\;1\\

\mathbf{elif}\;y \le 2.16201455188241352 \cdot 10^{107}:\\
\;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\

\mathbf{elif}\;y \le 4.36744780112662469 \cdot 10^{128}:\\
\;\;\;\;1\\

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

\end{array}
double f(double x, double y) {
        double r1414146 = x;
        double r1414147 = r1414146 * r1414146;
        double r1414148 = y;
        double r1414149 = 4.0;
        double r1414150 = r1414148 * r1414149;
        double r1414151 = r1414150 * r1414148;
        double r1414152 = r1414147 - r1414151;
        double r1414153 = r1414147 + r1414151;
        double r1414154 = r1414152 / r1414153;
        return r1414154;
}

double f(double x, double y) {
        double r1414155 = y;
        double r1414156 = -7.710738992849757e+142;
        bool r1414157 = r1414155 <= r1414156;
        double r1414158 = 1.0;
        double r1414159 = -r1414158;
        double r1414160 = -1.3841596065667632e-97;
        bool r1414161 = r1414155 <= r1414160;
        double r1414162 = x;
        double r1414163 = r1414162 * r1414162;
        double r1414164 = 4.0;
        double r1414165 = r1414155 * r1414164;
        double r1414166 = r1414165 * r1414155;
        double r1414167 = r1414163 + r1414166;
        double r1414168 = r1414163 / r1414167;
        double r1414169 = r1414166 / r1414167;
        double r1414170 = exp(r1414169);
        double r1414171 = log(r1414170);
        double r1414172 = r1414168 - r1414171;
        double r1414173 = 1.1196094733529732e-55;
        bool r1414174 = r1414155 <= r1414173;
        double r1414175 = 1.0;
        double r1414176 = 28161126.972837694;
        bool r1414177 = r1414155 <= r1414176;
        double r1414178 = 4.011625031578035e+38;
        bool r1414179 = r1414155 <= r1414178;
        double r1414180 = 2.1620145518824135e+107;
        bool r1414181 = r1414155 <= r1414180;
        double r1414182 = 4.367447801126625e+128;
        bool r1414183 = r1414155 <= r1414182;
        double r1414184 = r1414183 ? r1414175 : r1414159;
        double r1414185 = r1414181 ? r1414172 : r1414184;
        double r1414186 = r1414179 ? r1414175 : r1414185;
        double r1414187 = r1414177 ? r1414172 : r1414186;
        double r1414188 = r1414174 ? r1414175 : r1414187;
        double r1414189 = r1414161 ? r1414172 : r1414188;
        double r1414190 = r1414157 ? r1414159 : r1414189;
        return r1414190;
}

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.3
Target32.0
Herbie13.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.974323384962678118:\\ \;\;\;\;\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 y < -7.710738992849757e+142 or 4.367447801126625e+128 < y

    1. Initial program 59.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 div-sub59.1

      \[\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. Taylor expanded around 0 8.6

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

    if -7.710738992849757e+142 < y < -1.3841596065667632e-97 or 1.1196094733529732e-55 < y < 28161126.972837694 or 4.011625031578035e+38 < y < 2.1620145518824135e+107

    1. Initial program 16.7

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

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

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

    if -1.3841596065667632e-97 < y < 1.1196094733529732e-55 or 28161126.972837694 < y < 4.011625031578035e+38 or 2.1620145518824135e+107 < y < 4.367447801126625e+128

    1. Initial program 25.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -7.71073899284975746 \cdot 10^{142}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -1.38415960656676321 \cdot 10^{-97}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\ \mathbf{elif}\;y \le 1.1196094733529732 \cdot 10^{-55}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 28161126.972837694:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\ \mathbf{elif}\;y \le 4.01162503157803517 \cdot 10^{38}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 2.16201455188241352 \cdot 10^{107}:\\ \;\;\;\;\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\ \mathbf{elif}\;y \le 4.36744780112662469 \cdot 10^{128}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

herbie shell --seed 2020047 
(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.9743233849626781) (- (/ (* 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))))