Average Error: 31.6 → 14.8
Time: 2.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.5681746261658627 \cdot 10^{-214}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 6.51230295658223255 \cdot 10^{-77}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \left(\sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 7.16324510776386085 \cdot 10^{31}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.7671028773181022 \cdot 10^{187}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \left(\sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 2.36943602155751907 \cdot 10^{227}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 9.4017814857528666 \cdot 10^{260}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \left(\sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)\\ \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}\;\left(y \cdot 4\right) \cdot y \le 6.5681746261658627 \cdot 10^{-214}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 7.16324510776386085 \cdot 10^{31}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 2.36943602155751907 \cdot 10^{227}:\\
\;\;\;\;1\\

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

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

\end{array}
double f(double x, double y) {
        double r716993 = x;
        double r716994 = r716993 * r716993;
        double r716995 = y;
        double r716996 = 4.0;
        double r716997 = r716995 * r716996;
        double r716998 = r716997 * r716995;
        double r716999 = r716994 - r716998;
        double r717000 = r716994 + r716998;
        double r717001 = r716999 / r717000;
        return r717001;
}

double f(double x, double y) {
        double r717002 = y;
        double r717003 = 4.0;
        double r717004 = r717002 * r717003;
        double r717005 = r717004 * r717002;
        double r717006 = 6.568174626165863e-214;
        bool r717007 = r717005 <= r717006;
        double r717008 = 1.0;
        double r717009 = 6.5123029565822326e-77;
        bool r717010 = r717005 <= r717009;
        double r717011 = x;
        double r717012 = r717011 * r717011;
        double r717013 = r717012 + r717005;
        double r717014 = r717012 / r717013;
        double r717015 = r717005 / r717013;
        double r717016 = cbrt(r717015);
        double r717017 = r717016 * r717016;
        double r717018 = r717017 * r717016;
        double r717019 = r717014 - r717018;
        double r717020 = exp(r717019);
        double r717021 = log(r717020);
        double r717022 = 7.163245107763861e+31;
        bool r717023 = r717005 <= r717022;
        double r717024 = 1.7671028773181022e+187;
        bool r717025 = r717005 <= r717024;
        double r717026 = 2.369436021557519e+227;
        bool r717027 = r717005 <= r717026;
        double r717028 = 9.401781485752867e+260;
        bool r717029 = r717005 <= r717028;
        double r717030 = -1.0;
        double r717031 = r717029 ? r717021 : r717030;
        double r717032 = r717027 ? r717008 : r717031;
        double r717033 = r717025 ? r717021 : r717032;
        double r717034 = r717023 ? r717008 : r717033;
        double r717035 = r717010 ? r717021 : r717034;
        double r717036 = r717007 ? r717008 : r717035;
        return r717036;
}

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
Herbie14.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.974323384962678118:\\ \;\;\;\;\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.568174626165863e-214 or 6.5123029565822326e-77 < (* (* y 4.0) y) < 7.163245107763861e+31 or 1.7671028773181022e+187 < (* (* y 4.0) y) < 2.369436021557519e+227

    1. Initial program 24.2

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

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

    if 6.568174626165863e-214 < (* (* y 4.0) y) < 6.5123029565822326e-77 or 7.163245107763861e+31 < (* (* y 4.0) y) < 1.7671028773181022e+187 or 2.369436021557519e+227 < (* (* y 4.0) y) < 9.401781485752867e+260

    1. Initial program 15.7

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

      \[\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-log-exp15.7

      \[\leadsto \frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \color{blue}{\log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)}\]
    6. Applied add-log-exp15.7

      \[\leadsto \color{blue}{\log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\]
    7. Applied diff-log15.7

      \[\leadsto \color{blue}{\log \left(\frac{e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}{e^{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)}\]
    8. Simplified15.7

      \[\leadsto \log \color{blue}{\left(e^{\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)}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt15.7

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

    if 9.401781485752867e+260 < (* (* y 4.0) y)

    1. Initial program 57.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 4\right) \cdot y \le 6.5681746261658627 \cdot 10^{-214}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 6.51230295658223255 \cdot 10^{-77}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \left(\sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 7.16324510776386085 \cdot 10^{31}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 1.7671028773181022 \cdot 10^{187}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \left(\sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 2.36943602155751907 \cdot 10^{227}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 9.4017814857528666 \cdot 10^{260}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \left(\sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \sqrt[3]{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

herbie shell --seed 2020024 
(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.9743233849626781) (- (/ (* 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))))