Average Error: 32.2 → 12.8
Time: 2.9s
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 2.361346704065944689089216829566713485887 \cdot 10^{-173}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.93285633875459141678597998286665816515 \cdot 10^{264}:\\ \;\;\;\;\frac{\frac{\frac{1}{\sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}}{\sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}}{\sqrt[3]{\frac{x \cdot x + \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 2.361346704065944689089216829566713485887 \cdot 10^{-173}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \le 1.93285633875459141678597998286665816515 \cdot 10^{264}:\\
\;\;\;\;\frac{\frac{\frac{1}{\sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}}{\sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}}{\sqrt[3]{\frac{x \cdot x + \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 r738017 = x;
        double r738018 = r738017 * r738017;
        double r738019 = y;
        double r738020 = 4.0;
        double r738021 = r738019 * r738020;
        double r738022 = r738021 * r738019;
        double r738023 = r738018 - r738022;
        double r738024 = r738018 + r738022;
        double r738025 = r738023 / r738024;
        return r738025;
}

double f(double x, double y) {
        double r738026 = x;
        double r738027 = r738026 * r738026;
        double r738028 = 2.3613467040659447e-173;
        bool r738029 = r738027 <= r738028;
        double r738030 = -1.0;
        double r738031 = 1.9328563387545914e+264;
        bool r738032 = r738027 <= r738031;
        double r738033 = 1.0;
        double r738034 = y;
        double r738035 = 4.0;
        double r738036 = r738034 * r738035;
        double r738037 = r738036 * r738034;
        double r738038 = r738027 + r738037;
        double r738039 = r738027 - r738037;
        double r738040 = r738038 / r738039;
        double r738041 = cbrt(r738040);
        double r738042 = r738033 / r738041;
        double r738043 = r738042 / r738041;
        double r738044 = r738043 / r738041;
        double r738045 = r738032 ? r738044 : r738033;
        double r738046 = r738029 ? r738030 : r738045;
        return r738046;
}

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.2
Target31.9
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) < 2.3613467040659447e-173

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

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

    if 2.3613467040659447e-173 < (* x x) < 1.9328563387545914e+264

    1. Initial program 16.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 clear-num16.5

      \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt16.5

      \[\leadsto \frac{1}{\color{blue}{\left(\sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}}\]
    6. Applied associate-/r*16.5

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

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

    if 1.9328563387545914e+264 < (* x x)

    1. Initial program 58.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \le 2.361346704065944689089216829566713485887 \cdot 10^{-173}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 1.93285633875459141678597998286665816515 \cdot 10^{264}:\\ \;\;\;\;\frac{\frac{\frac{1}{\sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}}{\sqrt[3]{\frac{x \cdot x + \left(y \cdot 4\right) \cdot y}{x \cdot x - \left(y \cdot 4\right) \cdot y}}}}{\sqrt[3]{\frac{x \cdot x + \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 2019322 
(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))))