Average Error: 31.7 → 12.8
Time: 18.7s
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 \cdot x \le 3.222607567780329196681560572143104577428 \cdot 10^{-289}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 6.835592550358748008281275435772541106955 \cdot 10^{96}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \cdot x \le 7.775826278762702186699010750865619056054 \cdot 10^{132}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.421420598341031269955175034568661498389 \cdot 10^{194}:\\ \;\;\;\;\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 \cdot x \le 3.222607567780329196681560572143104577428 \cdot 10^{-289}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;x \cdot x \le 7.775826278762702186699010750865619056054 \cdot 10^{132}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \le 1.421420598341031269955175034568661498389 \cdot 10^{194}:\\
\;\;\;\;\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 r28498283 = x;
        double r28498284 = r28498283 * r28498283;
        double r28498285 = y;
        double r28498286 = 4.0;
        double r28498287 = r28498285 * r28498286;
        double r28498288 = r28498287 * r28498285;
        double r28498289 = r28498284 - r28498288;
        double r28498290 = r28498284 + r28498288;
        double r28498291 = r28498289 / r28498290;
        return r28498291;
}

double f(double x, double y) {
        double r28498292 = x;
        double r28498293 = r28498292 * r28498292;
        double r28498294 = 3.222607567780329e-289;
        bool r28498295 = r28498293 <= r28498294;
        double r28498296 = -1.0;
        double r28498297 = 6.835592550358748e+96;
        bool r28498298 = r28498293 <= r28498297;
        double r28498299 = y;
        double r28498300 = 4.0;
        double r28498301 = r28498299 * r28498300;
        double r28498302 = r28498301 * r28498299;
        double r28498303 = r28498293 - r28498302;
        double r28498304 = r28498293 + r28498302;
        double r28498305 = r28498303 / r28498304;
        double r28498306 = 7.775826278762702e+132;
        bool r28498307 = r28498293 <= r28498306;
        double r28498308 = 1.4214205983410313e+194;
        bool r28498309 = r28498293 <= r28498308;
        double r28498310 = r28498293 / r28498304;
        double r28498311 = r28498302 / r28498304;
        double r28498312 = r28498310 - r28498311;
        double r28498313 = 1.0;
        double r28498314 = r28498309 ? r28498312 : r28498313;
        double r28498315 = r28498307 ? r28498296 : r28498314;
        double r28498316 = r28498298 ? r28498305 : r28498315;
        double r28498317 = r28498295 ? r28498296 : r28498316;
        return r28498317;
}

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.7
Target31.4
Herbie12.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 4 regimes
  2. if (* x x) < 3.222607567780329e-289 or 6.835592550358748e+96 < (* x x) < 7.775826278762702e+132

    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. Taylor expanded around 0 11.4

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

    if 3.222607567780329e-289 < (* x x) < 6.835592550358748e+96

    1. Initial program 15.7

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

    if 7.775826278762702e+132 < (* x x) < 1.4214205983410313e+194

    1. Initial program 17.5

      \[\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-sub17.5

      \[\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 1.4214205983410313e+194 < (* x x)

    1. Initial program 50.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \le 3.222607567780329196681560572143104577428 \cdot 10^{-289}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 6.835592550358748008281275435772541106955 \cdot 10^{96}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \cdot x \le 7.775826278762702186699010750865619056054 \cdot 10^{132}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.421420598341031269955175034568661498389 \cdot 10^{194}:\\ \;\;\;\;\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 2019168 
(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))))