Average Error: 32.0 → 13.7
Time: 2.6s
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 -6.8846914672875272 \cdot 10^{72}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.2844298549447538 \cdot 10^{-86}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le -8.3083357206087974 \cdot 10^{-129}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le -1.48545386734228277 \cdot 10^{-159}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 3.6325524534615799 \cdot 10^{-162}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 2.53810326883758562 \cdot 10^{50}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 1.5780354646094017 \cdot 10^{73}:\\ \;\;\;\;-1\\ \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 -6.8846914672875272 \cdot 10^{72}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \le -8.3083357206087974 \cdot 10^{-129}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;x \le 3.6325524534615799 \cdot 10^{-162}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;x \le 1.5780354646094017 \cdot 10^{73}:\\
\;\;\;\;-1\\

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

\end{array}
double f(double x, double y) {
        double r610263 = x;
        double r610264 = r610263 * r610263;
        double r610265 = y;
        double r610266 = 4.0;
        double r610267 = r610265 * r610266;
        double r610268 = r610267 * r610265;
        double r610269 = r610264 - r610268;
        double r610270 = r610264 + r610268;
        double r610271 = r610269 / r610270;
        return r610271;
}

double f(double x, double y) {
        double r610272 = x;
        double r610273 = -6.884691467287527e+72;
        bool r610274 = r610272 <= r610273;
        double r610275 = 1.0;
        double r610276 = -1.2844298549447538e-86;
        bool r610277 = r610272 <= r610276;
        double r610278 = r610272 * r610272;
        double r610279 = y;
        double r610280 = 4.0;
        double r610281 = r610279 * r610280;
        double r610282 = r610281 * r610279;
        double r610283 = r610278 + r610282;
        double r610284 = r610278 / r610283;
        double r610285 = 3.0;
        double r610286 = pow(r610284, r610285);
        double r610287 = cbrt(r610286);
        double r610288 = r610282 / r610283;
        double r610289 = r610287 - r610288;
        double r610290 = -8.308335720608797e-129;
        bool r610291 = r610272 <= r610290;
        double r610292 = 1.0;
        double r610293 = -r610292;
        double r610294 = -1.4854538673422828e-159;
        bool r610295 = r610272 <= r610294;
        double r610296 = 3.63255245346158e-162;
        bool r610297 = r610272 <= r610296;
        double r610298 = 2.5381032688375856e+50;
        bool r610299 = r610272 <= r610298;
        double r610300 = 1.5780354646094017e+73;
        bool r610301 = r610272 <= r610300;
        double r610302 = r610301 ? r610293 : r610275;
        double r610303 = r610299 ? r610289 : r610302;
        double r610304 = r610297 ? r610293 : r610303;
        double r610305 = r610295 ? r610289 : r610304;
        double r610306 = r610291 ? r610293 : r610305;
        double r610307 = r610277 ? r610289 : r610306;
        double r610308 = r610274 ? r610275 : r610307;
        return r610308;
}

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.0
Target31.7
Herbie13.7
\[\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 < -6.884691467287527e+72 or 1.5780354646094017e+73 < x

    1. Initial program 47.9

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

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

    if -6.884691467287527e+72 < x < -1.2844298549447538e-86 or -8.308335720608797e-129 < x < -1.4854538673422828e-159 or 3.63255245346158e-162 < x < 2.5381032688375856e+50

    1. Initial program 15.6

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

      \[\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-cbrt-cube29.2

      \[\leadsto \frac{x \cdot x}{\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)}}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    6. Applied add-cbrt-cube29.2

      \[\leadsto \frac{x \cdot \color{blue}{\sqrt[3]{\left(x \cdot x\right) \cdot x}}}{\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)}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    7. Applied add-cbrt-cube29.3

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(x \cdot x\right) \cdot x}} \cdot \sqrt[3]{\left(x \cdot x\right) \cdot x}}{\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)}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    8. Applied cbrt-unprod29.5

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\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)}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    9. Applied cbrt-undiv29.5

      \[\leadsto \color{blue}{\sqrt[3]{\frac{\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\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)}}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]
    10. Simplified15.6

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

    if -1.2844298549447538e-86 < x < -8.308335720608797e-129 or -1.4854538673422828e-159 < x < 3.63255245346158e-162 or 2.5381032688375856e+50 < x < 1.5780354646094017e+73

    1. Initial program 29.3

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

      \[\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. Taylor expanded around 0 11.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.8846914672875272 \cdot 10^{72}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.2844298549447538 \cdot 10^{-86}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le -8.3083357206087974 \cdot 10^{-129}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le -1.48545386734228277 \cdot 10^{-159}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 3.6325524534615799 \cdot 10^{-162}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 2.53810326883758562 \cdot 10^{50}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}\right)}^{3}} - \frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \le 1.5780354646094017 \cdot 10^{73}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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