Average Error: 31.2 → 13.9
Time: 12.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}\;y \le -4.758167358261969805068202523877348166337 \cdot 10^{148}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -1.63689029313189507811324572738338926855 \cdot 10^{-160}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x}} - \frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;y \le 1.575397687437991456648509198388754062127 \cdot 10^{-55}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 8.134021215145637850375061461407044861883 \cdot 10^{-38}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x}} - \frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;y \le 98355.24381927796639502048492431640625:\\ \;\;\;\;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 -4.758167358261969805068202523877348166337 \cdot 10^{148}:\\
\;\;\;\;-1\\

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

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

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

\mathbf{elif}\;y \le 98355.24381927796639502048492431640625:\\
\;\;\;\;1\\

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

\end{array}
double f(double x, double y) {
        double r469410 = x;
        double r469411 = r469410 * r469410;
        double r469412 = y;
        double r469413 = 4.0;
        double r469414 = r469412 * r469413;
        double r469415 = r469414 * r469412;
        double r469416 = r469411 - r469415;
        double r469417 = r469411 + r469415;
        double r469418 = r469416 / r469417;
        return r469418;
}

double f(double x, double y) {
        double r469419 = y;
        double r469420 = -4.75816735826197e+148;
        bool r469421 = r469419 <= r469420;
        double r469422 = 1.0;
        double r469423 = -r469422;
        double r469424 = -1.636890293131895e-160;
        bool r469425 = r469419 <= r469424;
        double r469426 = 1.0;
        double r469427 = x;
        double r469428 = r469427 * r469427;
        double r469429 = 4.0;
        double r469430 = r469419 * r469429;
        double r469431 = r469430 * r469419;
        double r469432 = r469428 + r469431;
        double r469433 = r469432 / r469428;
        double r469434 = r469426 / r469433;
        double r469435 = r469432 / r469431;
        double r469436 = r469426 / r469435;
        double r469437 = r469434 - r469436;
        double r469438 = 1.5753976874379915e-55;
        bool r469439 = r469419 <= r469438;
        double r469440 = 8.134021215145638e-38;
        bool r469441 = r469419 <= r469440;
        double r469442 = 98355.24381927797;
        bool r469443 = r469419 <= r469442;
        double r469444 = r469443 ? r469426 : r469423;
        double r469445 = r469441 ? r469437 : r469444;
        double r469446 = r469439 ? r469426 : r469445;
        double r469447 = r469425 ? r469437 : r469446;
        double r469448 = r469421 ? r469423 : r469447;
        return r469448;
}

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.2
Target30.9
Herbie13.9
\[\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.75816735826197e+148 or 98355.24381927797 < y

    1. Initial program 47.9

      \[\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-sub47.9

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

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

    if -4.75816735826197e+148 < y < -1.636890293131895e-160 or 1.5753976874379915e-55 < y < 8.134021215145638e-38

    1. Initial program 16.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-sub16.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. Using strategy rm
    5. Applied clear-num16.3

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y}}}\]
    6. Using strategy rm
    7. Applied clear-num16.3

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

    if -1.636890293131895e-160 < y < 1.5753976874379915e-55 or 8.134021215145638e-38 < y < 98355.24381927797

    1. Initial program 24.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.758167358261969805068202523877348166337 \cdot 10^{148}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -1.63689029313189507811324572738338926855 \cdot 10^{-160}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x}} - \frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;y \le 1.575397687437991456648509198388754062127 \cdot 10^{-55}:\\ \;\;\;\;1\\ \mathbf{elif}\;y \le 8.134021215145637850375061461407044861883 \cdot 10^{-38}:\\ \;\;\;\;\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x}} - \frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y}}\\ \mathbf{elif}\;y \le 98355.24381927796639502048492431640625:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

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