Average Error: 31.9 → 14.4
Time: 3.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}\;y \le -2.091774049465234070950313649530598571567 \cdot 10^{107}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -2.565171579910276069385014717654736976365 \cdot 10^{-142}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\ \mathbf{elif}\;y \le 4.023717811960942306961026932150879285621 \cdot 10^{-14}:\\ \;\;\;\;\sqrt[3]{{1}^{3}}\\ \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 -2.091774049465234070950313649530598571567 \cdot 10^{107}:\\
\;\;\;\;-1\\

\mathbf{elif}\;y \le -2.565171579910276069385014717654736976365 \cdot 10^{-142}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\

\mathbf{elif}\;y \le 4.023717811960942306961026932150879285621 \cdot 10^{-14}:\\
\;\;\;\;\sqrt[3]{{1}^{3}}\\

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

\end{array}
double f(double x, double y) {
        double r479893 = x;
        double r479894 = r479893 * r479893;
        double r479895 = y;
        double r479896 = 4.0;
        double r479897 = r479895 * r479896;
        double r479898 = r479897 * r479895;
        double r479899 = r479894 - r479898;
        double r479900 = r479894 + r479898;
        double r479901 = r479899 / r479900;
        return r479901;
}

double f(double x, double y) {
        double r479902 = y;
        double r479903 = -2.091774049465234e+107;
        bool r479904 = r479902 <= r479903;
        double r479905 = -1.0;
        double r479906 = -2.565171579910276e-142;
        bool r479907 = r479902 <= r479906;
        double r479908 = x;
        double r479909 = r479908 * r479908;
        double r479910 = 4.0;
        double r479911 = r479902 * r479910;
        double r479912 = r479911 * r479902;
        double r479913 = r479909 - r479912;
        double r479914 = r479909 + r479912;
        double r479915 = r479913 / r479914;
        double r479916 = 3.0;
        double r479917 = pow(r479915, r479916);
        double r479918 = cbrt(r479917);
        double r479919 = 4.023717811960942e-14;
        bool r479920 = r479902 <= r479919;
        double r479921 = 1.0;
        double r479922 = pow(r479921, r479916);
        double r479923 = cbrt(r479922);
        double r479924 = r479920 ? r479923 : r479905;
        double r479925 = r479907 ? r479918 : r479924;
        double r479926 = r479904 ? r479905 : r479925;
        return r479926;
}

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.9
Target31.6
Herbie14.4
\[\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 < -2.091774049465234e+107 or 4.023717811960942e-14 < y

    1. Initial program 44.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 0 14.4

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

    if -2.091774049465234e+107 < y < -2.565171579910276e-142

    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 add-cbrt-cube44.6

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

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

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

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

    if -2.565171579910276e-142 < y < 4.023717811960942e-14

    1. Initial program 26.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 add-cbrt-cube50.9

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.091774049465234070950313649530598571567 \cdot 10^{107}:\\ \;\;\;\;-1\\ \mathbf{elif}\;y \le -2.565171579910276069385014717654736976365 \cdot 10^{-142}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}}\\ \mathbf{elif}\;y \le 4.023717811960942306961026932150879285621 \cdot 10^{-14}:\\ \;\;\;\;\sqrt[3]{{1}^{3}}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

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