Average Error: 32.3 → 13.6
Time: 5.4s
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 r810215 = x;
        double r810216 = r810215 * r810215;
        double r810217 = y;
        double r810218 = 4.0;
        double r810219 = r810217 * r810218;
        double r810220 = r810219 * r810217;
        double r810221 = r810216 - r810220;
        double r810222 = r810216 + r810220;
        double r810223 = r810221 / r810222;
        return r810223;
}

double f(double x, double y) {
        double r810224 = y;
        double r810225 = -7.710738992849757e+142;
        bool r810226 = r810224 <= r810225;
        double r810227 = 1.0;
        double r810228 = -r810227;
        double r810229 = -1.3841596065667632e-97;
        bool r810230 = r810224 <= r810229;
        double r810231 = x;
        double r810232 = r810231 * r810231;
        double r810233 = 4.0;
        double r810234 = r810224 * r810233;
        double r810235 = r810234 * r810224;
        double r810236 = r810232 + r810235;
        double r810237 = r810232 / r810236;
        double r810238 = r810235 / r810236;
        double r810239 = exp(r810238);
        double r810240 = log(r810239);
        double r810241 = r810237 - r810240;
        double r810242 = 1.1196094733529732e-55;
        bool r810243 = r810224 <= r810242;
        double r810244 = 1.0;
        double r810245 = 28161126.972837694;
        bool r810246 = r810224 <= r810245;
        double r810247 = 4.011625031578035e+38;
        bool r810248 = r810224 <= r810247;
        double r810249 = 2.1620145518824135e+107;
        bool r810250 = r810224 <= r810249;
        double r810251 = 4.367447801126625e+128;
        bool r810252 = r810224 <= r810251;
        double r810253 = r810252 ? r810244 : r810228;
        double r810254 = r810250 ? r810241 : r810253;
        double r810255 = r810248 ? r810244 : r810254;
        double r810256 = r810246 ? r810241 : r810255;
        double r810257 = r810243 ? r810244 : r810256;
        double r810258 = r810230 ? r810241 : r810257;
        double r810259 = r810226 ? r810228 : r810258;
        return r810259;
}

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))))