Average Error: 32.1 → 13.5
Time: 2.5s
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 \le -4.00847790071649149 \cdot 10^{147}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -4.16780906636482433 \cdot 10^{-5}:\\ \;\;\;\;\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}}\\ \mathbf{elif}\;x \le 4.3335505177201293 \cdot 10^{-137}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 4.23767844119500403 \cdot 10^{65}:\\ \;\;\;\;\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}}\\ \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 \le -4.00847790071649149 \cdot 10^{147}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -4.16780906636482433 \cdot 10^{-5}:\\
\;\;\;\;\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}}\\

\mathbf{elif}\;x \le 4.3335505177201293 \cdot 10^{-137}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 4.23767844119500403 \cdot 10^{65}:\\
\;\;\;\;\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}}\\

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

\end{array}
double f(double x, double y) {
        double r620866 = x;
        double r620867 = r620866 * r620866;
        double r620868 = y;
        double r620869 = 4.0;
        double r620870 = r620868 * r620869;
        double r620871 = r620870 * r620868;
        double r620872 = r620867 - r620871;
        double r620873 = r620867 + r620871;
        double r620874 = r620872 / r620873;
        return r620874;
}

double f(double x, double y) {
        double r620875 = x;
        double r620876 = -4.0084779007164915e+147;
        bool r620877 = r620875 <= r620876;
        double r620878 = 1.0;
        double r620879 = -4.167809066364824e-05;
        bool r620880 = r620875 <= r620879;
        double r620881 = r620875 * r620875;
        double r620882 = y;
        double r620883 = 4.0;
        double r620884 = r620882 * r620883;
        double r620885 = r620884 * r620882;
        double r620886 = r620881 - r620885;
        double r620887 = r620881 + r620885;
        double r620888 = r620886 / r620887;
        double r620889 = cbrt(r620888);
        double r620890 = r620889 * r620889;
        double r620891 = r620890 * r620889;
        double r620892 = 4.333550517720129e-137;
        bool r620893 = r620875 <= r620892;
        double r620894 = -1.0;
        double r620895 = 4.237678441195004e+65;
        bool r620896 = r620875 <= r620895;
        double r620897 = r620896 ? r620891 : r620878;
        double r620898 = r620893 ? r620894 : r620897;
        double r620899 = r620880 ? r620891 : r620898;
        double r620900 = r620877 ? r620878 : r620899;
        return r620900;
}

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.1
Target31.7
Herbie13.5
\[\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 x < -4.0084779007164915e+147 or 4.237678441195004e+65 < x

    1. Initial program 53.3

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

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

    if -4.0084779007164915e+147 < x < -4.167809066364824e-05 or 4.333550517720129e-137 < x < 4.237678441195004e+65

    1. Initial program 16.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 add-cube-cbrt16.8

      \[\leadsto \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}}}\]

    if -4.167809066364824e-05 < x < 4.333550517720129e-137

    1. Initial program 25.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.00847790071649149 \cdot 10^{147}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -4.16780906636482433 \cdot 10^{-5}:\\ \;\;\;\;\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}}\\ \mathbf{elif}\;x \le 4.3335505177201293 \cdot 10^{-137}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 4.23767844119500403 \cdot 10^{65}:\\ \;\;\;\;\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}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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