Average Error: 31.4 → 12.8
Time: 9.2s
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.77839364352374568196916187185312325383 \cdot 10^{-306}:\\ \;\;\;\;\sqrt[3]{{-1}^{3}}\\ \mathbf{elif}\;x \cdot x \le 1.980191050623079023019255468850286771049 \cdot 10^{-35}:\\ \;\;\;\;\frac{x}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{x}} - \frac{4 \cdot y}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{y}}\\ \mathbf{elif}\;x \cdot x \le 46369913269634036246010815144622292992:\\ \;\;\;\;\sqrt[3]{{-1}^{3}}\\ \mathbf{elif}\;x \cdot x \le 6.930492227353571361292600395069697176856 \cdot 10^{289}:\\ \;\;\;\;\frac{x}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{x}} - \frac{4 \cdot y}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{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.77839364352374568196916187185312325383 \cdot 10^{-306}:\\
\;\;\;\;\sqrt[3]{{-1}^{3}}\\

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

\mathbf{elif}\;x \cdot x \le 46369913269634036246010815144622292992:\\
\;\;\;\;\sqrt[3]{{-1}^{3}}\\

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

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

\end{array}
double f(double x, double y) {
        double r550423 = x;
        double r550424 = r550423 * r550423;
        double r550425 = y;
        double r550426 = 4.0;
        double r550427 = r550425 * r550426;
        double r550428 = r550427 * r550425;
        double r550429 = r550424 - r550428;
        double r550430 = r550424 + r550428;
        double r550431 = r550429 / r550430;
        return r550431;
}

double f(double x, double y) {
        double r550432 = x;
        double r550433 = r550432 * r550432;
        double r550434 = 3.7783936435237457e-306;
        bool r550435 = r550433 <= r550434;
        double r550436 = -1.0;
        double r550437 = 3.0;
        double r550438 = pow(r550436, r550437);
        double r550439 = cbrt(r550438);
        double r550440 = 1.980191050623079e-35;
        bool r550441 = r550433 <= r550440;
        double r550442 = y;
        double r550443 = 4.0;
        double r550444 = r550443 * r550442;
        double r550445 = r550442 * r550444;
        double r550446 = r550445 + r550433;
        double r550447 = r550446 / r550432;
        double r550448 = r550432 / r550447;
        double r550449 = r550446 / r550442;
        double r550450 = r550444 / r550449;
        double r550451 = r550448 - r550450;
        double r550452 = 4.636991326963404e+37;
        bool r550453 = r550433 <= r550452;
        double r550454 = 6.930492227353571e+289;
        bool r550455 = r550433 <= r550454;
        double r550456 = 1.0;
        double r550457 = r550455 ? r550451 : r550456;
        double r550458 = r550453 ? r550439 : r550457;
        double r550459 = r550441 ? r550451 : r550458;
        double r550460 = r550435 ? r550439 : r550459;
        return r550460;
}

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.4
Target31.1
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 3 regimes
  2. if (* x x) < 3.7783936435237457e-306 or 1.980191050623079e-35 < (* x x) < 4.636991326963404e+37

    1. Initial program 26.7

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

      \[\leadsto \color{blue}{\frac{x \cdot x - 4 \cdot \left(y \cdot y\right)}{x \cdot x + 4 \cdot \left(y \cdot y\right)}}\]
    3. Using strategy rm
    4. Applied add-cbrt-cube47.7

      \[\leadsto \frac{x \cdot x - 4 \cdot \left(y \cdot y\right)}{\color{blue}{\sqrt[3]{\left(\left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)}}}\]
    5. Applied add-cbrt-cube47.9

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)}}}{\sqrt[3]{\left(\left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)}}\]
    6. Applied cbrt-undiv47.9

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)}{\left(\left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)}}}\]
    7. Simplified26.7

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x \cdot x - \left(4 \cdot y\right) \cdot y}{x \cdot x + \left(4 \cdot y\right) \cdot y}\right)}^{3}}}\]
    8. Taylor expanded around 0 12.5

      \[\leadsto \sqrt[3]{{\color{blue}{-1}}^{3}}\]

    if 3.7783936435237457e-306 < (* x x) < 1.980191050623079e-35 or 4.636991326963404e+37 < (* x x) < 6.930492227353571e+289

    1. Initial program 15.9

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

      \[\leadsto \color{blue}{\frac{x \cdot x - 4 \cdot \left(y \cdot y\right)}{x \cdot x + 4 \cdot \left(y \cdot y\right)}}\]
    3. Using strategy rm
    4. Applied div-sub15.9

      \[\leadsto \color{blue}{\frac{x \cdot x}{x \cdot x + 4 \cdot \left(y \cdot y\right)} - \frac{4 \cdot \left(y \cdot y\right)}{x \cdot x + 4 \cdot \left(y \cdot y\right)}}\]
    5. Simplified15.9

      \[\leadsto \color{blue}{\frac{x}{\frac{x \cdot x + \left(4 \cdot y\right) \cdot y}{x}}} - \frac{4 \cdot \left(y \cdot y\right)}{x \cdot x + 4 \cdot \left(y \cdot y\right)}\]
    6. Simplified15.5

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

    if 6.930492227353571e+289 < (* x x)

    1. Initial program 61.2

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

      \[\leadsto \color{blue}{\frac{x \cdot x - 4 \cdot \left(y \cdot y\right)}{x \cdot x + 4 \cdot \left(y \cdot y\right)}}\]
    3. Using strategy rm
    4. Applied add-cbrt-cube63.9

      \[\leadsto \frac{x \cdot x - 4 \cdot \left(y \cdot y\right)}{\color{blue}{\sqrt[3]{\left(\left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)}}}\]
    5. Applied add-cbrt-cube64.0

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)}}}{\sqrt[3]{\left(\left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)}}\]
    6. Applied cbrt-undiv64.0

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x - 4 \cdot \left(y \cdot y\right)\right)}{\left(\left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)\right) \cdot \left(x \cdot x + 4 \cdot \left(y \cdot y\right)\right)}}}\]
    7. Simplified61.2

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\frac{x \cdot x - \left(4 \cdot y\right) \cdot y}{x \cdot x + \left(4 \cdot y\right) \cdot y}\right)}^{3}}}\]
    8. Taylor expanded around inf 9.0

      \[\leadsto \sqrt[3]{{\color{blue}{1}}^{3}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification12.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \le 3.77839364352374568196916187185312325383 \cdot 10^{-306}:\\ \;\;\;\;\sqrt[3]{{-1}^{3}}\\ \mathbf{elif}\;x \cdot x \le 1.980191050623079023019255468850286771049 \cdot 10^{-35}:\\ \;\;\;\;\frac{x}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{x}} - \frac{4 \cdot y}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{y}}\\ \mathbf{elif}\;x \cdot x \le 46369913269634036246010815144622292992:\\ \;\;\;\;\sqrt[3]{{-1}^{3}}\\ \mathbf{elif}\;x \cdot x \le 6.930492227353571361292600395069697176856 \cdot 10^{289}:\\ \;\;\;\;\frac{x}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{x}} - \frac{4 \cdot y}{\frac{y \cdot \left(4 \cdot y\right) + x \cdot x}{y}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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