Average Error: 31.3 → 12.6
Time: 2.0s
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 -8.1561596166685901 \cdot 10^{125}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -8.2517187188967945 \cdot 10^{-93}:\\ \;\;\;\;\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}\;x \le 1.70327835954175013 \cdot 10^{-103}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 9.5532984912586814 \cdot 10^{94}:\\ \;\;\;\;\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{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 -8.1561596166685901 \cdot 10^{125}:\\
\;\;\;\;1\\

\mathbf{elif}\;x \le -8.2517187188967945 \cdot 10^{-93}:\\
\;\;\;\;\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}\;x \le 1.70327835954175013 \cdot 10^{-103}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 9.5532984912586814 \cdot 10^{94}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;1\\

\end{array}
double f(double x, double y) {
        double r808017 = x;
        double r808018 = r808017 * r808017;
        double r808019 = y;
        double r808020 = 4.0;
        double r808021 = r808019 * r808020;
        double r808022 = r808021 * r808019;
        double r808023 = r808018 - r808022;
        double r808024 = r808018 + r808022;
        double r808025 = r808023 / r808024;
        return r808025;
}

double f(double x, double y) {
        double r808026 = x;
        double r808027 = -8.15615961666859e+125;
        bool r808028 = r808026 <= r808027;
        double r808029 = 1.0;
        double r808030 = -8.251718718896794e-93;
        bool r808031 = r808026 <= r808030;
        double r808032 = r808026 * r808026;
        double r808033 = y;
        double r808034 = 4.0;
        double r808035 = r808033 * r808034;
        double r808036 = r808035 * r808033;
        double r808037 = r808032 - r808036;
        double r808038 = r808032 + r808036;
        double r808039 = r808037 / r808038;
        double r808040 = 3.0;
        double r808041 = pow(r808039, r808040);
        double r808042 = cbrt(r808041);
        double r808043 = 1.7032783595417501e-103;
        bool r808044 = r808026 <= r808043;
        double r808045 = -1.0;
        double r808046 = 9.553298491258681e+94;
        bool r808047 = r808026 <= r808046;
        double r808048 = r808047 ? r808042 : r808029;
        double r808049 = r808044 ? r808045 : r808048;
        double r808050 = r808031 ? r808042 : r808049;
        double r808051 = r808028 ? r808029 : r808050;
        return r808051;
}

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.3
Target31.0
Herbie12.6
\[\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 < -8.15615961666859e+125 or 9.553298491258681e+94 < x

    1. Initial program 52.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 inf 10.4

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

    if -8.15615961666859e+125 < x < -8.251718718896794e-93 or 1.7032783595417501e-103 < x < 9.553298491258681e+94

    1. Initial program 15.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-cube42.4

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

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

      \[\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. Simplified15.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 -8.251718718896794e-93 < x < 1.7032783595417501e-103

    1. Initial program 27.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 11.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -8.1561596166685901 \cdot 10^{125}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -8.2517187188967945 \cdot 10^{-93}:\\ \;\;\;\;\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}\;x \le 1.70327835954175013 \cdot 10^{-103}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 9.5532984912586814 \cdot 10^{94}:\\ \;\;\;\;\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{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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