Average Error: 31.8 → 13.7
Time: 9.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}\;\left(y \cdot 4\right) \cdot y \le 9.27663531436287128381217661661906819086 \cdot 10^{-162}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.009231216679780664152274467083127477626 \cdot 10^{-87}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5.402861320094046622592646648226721464217 \cdot 10^{-40}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.240352669105307376499490012234923987962 \cdot 10^{217}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 4.382319121848211154873292476989384127398 \cdot 10^{246}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 3.584497782919759792357906382925128159173 \cdot 10^{266}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \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}\;\left(y \cdot 4\right) \cdot y \le 9.27663531436287128381217661661906819086 \cdot 10^{-162}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.009231216679780664152274467083127477626 \cdot 10^{-87}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5.402861320094046622592646648226721464217 \cdot 10^{-40}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.240352669105307376499490012234923987962 \cdot 10^{217}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 4.382319121848211154873292476989384127398 \cdot 10^{246}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 3.584497782919759792357906382925128159173 \cdot 10^{266}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\

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

\end{array}
double f(double x, double y) {
        double r532234 = x;
        double r532235 = r532234 * r532234;
        double r532236 = y;
        double r532237 = 4.0;
        double r532238 = r532236 * r532237;
        double r532239 = r532238 * r532236;
        double r532240 = r532235 - r532239;
        double r532241 = r532235 + r532239;
        double r532242 = r532240 / r532241;
        return r532242;
}

double f(double x, double y) {
        double r532243 = y;
        double r532244 = 4.0;
        double r532245 = r532243 * r532244;
        double r532246 = r532245 * r532243;
        double r532247 = 9.276635314362871e-162;
        bool r532248 = r532246 <= r532247;
        double r532249 = 1.0;
        double r532250 = 1.0092312166797807e-87;
        bool r532251 = r532246 <= r532250;
        double r532252 = x;
        double r532253 = r532252 * r532252;
        double r532254 = r532253 - r532246;
        double r532255 = r532253 + r532246;
        double r532256 = r532254 / r532255;
        double r532257 = 5.402861320094047e-40;
        bool r532258 = r532246 <= r532257;
        double r532259 = 1.2403526691053074e+217;
        bool r532260 = r532246 <= r532259;
        double r532261 = 4.382319121848211e+246;
        bool r532262 = r532246 <= r532261;
        double r532263 = 3.58449778291976e+266;
        bool r532264 = r532246 <= r532263;
        double r532265 = -1.0;
        double r532266 = r532264 ? r532256 : r532265;
        double r532267 = r532262 ? r532249 : r532266;
        double r532268 = r532260 ? r532256 : r532267;
        double r532269 = r532258 ? r532249 : r532268;
        double r532270 = r532251 ? r532256 : r532269;
        double r532271 = r532248 ? r532249 : r532270;
        return r532271;
}

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.8
Target31.5
Herbie13.7
\[\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 (* (* y 4.0) y) < 9.276635314362871e-162 or 1.0092312166797807e-87 < (* (* y 4.0) y) < 5.402861320094047e-40 or 1.2403526691053074e+217 < (* (* y 4.0) y) < 4.382319121848211e+246

    1. Initial program 24.2

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

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

    if 9.276635314362871e-162 < (* (* y 4.0) y) < 1.0092312166797807e-87 or 5.402861320094047e-40 < (* (* y 4.0) y) < 1.2403526691053074e+217 or 4.382319121848211e+246 < (* (* y 4.0) y) < 3.58449778291976e+266

    1. Initial program 16.0

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

    if 3.58449778291976e+266 < (* (* y 4.0) y)

    1. Initial program 58.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 8.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 4\right) \cdot y \le 9.27663531436287128381217661661906819086 \cdot 10^{-162}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.009231216679780664152274467083127477626 \cdot 10^{-87}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5.402861320094046622592646648226721464217 \cdot 10^{-40}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.240352669105307376499490012234923987962 \cdot 10^{217}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 4.382319121848211154873292476989384127398 \cdot 10^{246}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 3.584497782919759792357906382925128159173 \cdot 10^{266}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

herbie shell --seed 2019235 
(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))))