Average Error: 31.6 → 12.8
Time: 8.3s
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 6.010110955400427711290288737724765706272 \cdot 10^{-319}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.549630575373215400330647286125311139548 \cdot 10^{-272}:\\ \;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 8.384919188504056437881495846608147200526 \cdot 10^{-205}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.230641633292964574763409282421415265643 \cdot 10^{201}:\\ \;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(-1\right)}^{3}}\\ \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 6.010110955400427711290288737724765706272 \cdot 10^{-319}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.549630575373215400330647286125311139548 \cdot 10^{-272}:\\
\;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\

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

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.230641633292964574763409282421415265643 \cdot 10^{201}:\\
\;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{\left(-1\right)}^{3}}\\

\end{array}
double f(double x, double y) {
        double r511614 = x;
        double r511615 = r511614 * r511614;
        double r511616 = y;
        double r511617 = 4.0;
        double r511618 = r511616 * r511617;
        double r511619 = r511618 * r511616;
        double r511620 = r511615 - r511619;
        double r511621 = r511615 + r511619;
        double r511622 = r511620 / r511621;
        return r511622;
}

double f(double x, double y) {
        double r511623 = y;
        double r511624 = 4.0;
        double r511625 = r511623 * r511624;
        double r511626 = r511625 * r511623;
        double r511627 = 6.0101109554004e-319;
        bool r511628 = r511626 <= r511627;
        double r511629 = 1.0;
        double r511630 = 1.5496305753732154e-272;
        bool r511631 = r511626 <= r511630;
        double r511632 = x;
        double r511633 = r511632 * r511632;
        double r511634 = r511633 + r511626;
        double r511635 = r511633 / r511634;
        double r511636 = r511626 / r511634;
        double r511637 = r511635 - r511636;
        double r511638 = 3.0;
        double r511639 = pow(r511637, r511638);
        double r511640 = cbrt(r511639);
        double r511641 = 8.384919188504056e-205;
        bool r511642 = r511626 <= r511641;
        double r511643 = 1.2306416332929646e+201;
        bool r511644 = r511626 <= r511643;
        double r511645 = 1.0;
        double r511646 = -r511645;
        double r511647 = pow(r511646, r511638);
        double r511648 = cbrt(r511647);
        double r511649 = r511644 ? r511640 : r511648;
        double r511650 = r511642 ? r511629 : r511649;
        double r511651 = r511631 ? r511640 : r511650;
        double r511652 = r511628 ? r511629 : r511651;
        return r511652;
}

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.6
Target31.3
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 (* (* y 4.0) y) < 6.0101109554004e-319 or 1.5496305753732154e-272 < (* (* y 4.0) y) < 8.384919188504056e-205

    1. Initial program 28.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 9.9

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

    if 6.0101109554004e-319 < (* (* y 4.0) y) < 1.5496305753732154e-272 or 8.384919188504056e-205 < (* (* y 4.0) y) < 1.2306416332929646e+201

    1. Initial program 16.2

      \[\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.2

      \[\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 add-cbrt-cube16.2

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\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}\right) \cdot \left(\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}\right)\right) \cdot \left(\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}\right)}}\]
    6. Simplified16.2

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\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}\right)}^{3}}}\]

    if 1.2306416332929646e+201 < (* (* y 4.0) y)

    1. Initial program 51.8

      \[\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-sub51.8

      \[\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 add-cbrt-cube51.8

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\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}\right) \cdot \left(\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}\right)\right) \cdot \left(\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}\right)}}\]
    6. Simplified51.8

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\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}\right)}^{3}}}\]
    7. Taylor expanded around 0 11.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 4\right) \cdot y \le 6.010110955400427711290288737724765706272 \cdot 10^{-319}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.549630575373215400330647286125311139548 \cdot 10^{-272}:\\ \;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 8.384919188504056437881495846608147200526 \cdot 10^{-205}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.230641633292964574763409282421415265643 \cdot 10^{201}:\\ \;\;\;\;\sqrt[3]{{\left(\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}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(-1\right)}^{3}}\\ \end{array}\]

Reproduce

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