Average Error: 32.0 → 12.2
Time: 3.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}\;x \le -6.4851444497691187 \cdot 10^{83}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -7.2767295738571386 \cdot 10^{-151}:\\ \;\;\;\;\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.52609343826535515 \cdot 10^{-130}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.21429121453061369 \cdot 10^{146}:\\ \;\;\;\;\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{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 -6.4851444497691187 \cdot 10^{83}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -7.2767295738571386 \cdot 10^{-151}:\\
\;\;\;\;\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.52609343826535515 \cdot 10^{-130}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 1.21429121453061369 \cdot 10^{146}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;1\\

\end{array}
double f(double x, double y) {
        double r639230 = x;
        double r639231 = r639230 * r639230;
        double r639232 = y;
        double r639233 = 4.0;
        double r639234 = r639232 * r639233;
        double r639235 = r639234 * r639232;
        double r639236 = r639231 - r639235;
        double r639237 = r639231 + r639235;
        double r639238 = r639236 / r639237;
        return r639238;
}

double f(double x, double y) {
        double r639239 = x;
        double r639240 = -6.485144449769119e+83;
        bool r639241 = r639239 <= r639240;
        double r639242 = 1.0;
        double r639243 = -7.276729573857139e-151;
        bool r639244 = r639239 <= r639243;
        double r639245 = r639239 * r639239;
        double r639246 = y;
        double r639247 = 4.0;
        double r639248 = r639246 * r639247;
        double r639249 = r639248 * r639246;
        double r639250 = r639245 + r639249;
        double r639251 = r639245 / r639250;
        double r639252 = r639249 / r639250;
        double r639253 = r639251 - r639252;
        double r639254 = 1.5260934382653551e-130;
        bool r639255 = r639239 <= r639254;
        double r639256 = 1.0;
        double r639257 = -r639256;
        double r639258 = 1.2142912145306137e+146;
        bool r639259 = r639239 <= r639258;
        double r639260 = r639259 ? r639253 : r639242;
        double r639261 = r639255 ? r639257 : r639260;
        double r639262 = r639244 ? r639253 : r639261;
        double r639263 = r639241 ? r639242 : r639262;
        return r639263;
}

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.0
Target31.7
Herbie12.2
\[\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 x < -6.485144449769119e+83 or 1.2142912145306137e+146 < x

    1. Initial program 55.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 10.5

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

    if -6.485144449769119e+83 < x < -7.276729573857139e-151 or 1.5260934382653551e-130 < x < 1.2142912145306137e+146

    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}\]
    2. Using strategy rm
    3. Applied div-sub16.0

      \[\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 -7.276729573857139e-151 < x < 1.5260934382653551e-130

    1. Initial program 29.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-sub29.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. Taylor expanded around 0 8.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.4851444497691187 \cdot 10^{83}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -7.2767295738571386 \cdot 10^{-151}:\\ \;\;\;\;\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.52609343826535515 \cdot 10^{-130}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.21429121453061369 \cdot 10^{146}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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