Average Error: 31.8 → 12.9
Time: 9.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}\;x \le -1.688721359903120564949235071844216306814 \cdot 10^{100}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -7.394329418796278633272453346909757071051 \cdot 10^{-66}:\\ \;\;\;\;\frac{x \cdot x}{\left(y \cdot 4\right) \cdot y + x \cdot x} - \sqrt[3]{\left(\frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x} \cdot \frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\right) \cdot \frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}}\\ \mathbf{elif}\;x \le 8.394176110344906536659390600257739023023 \cdot 10^{-193}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 5.306478096987979835000926393717769469618 \cdot 10^{92}:\\ \;\;\;\;\frac{x \cdot x}{\left(y \cdot 4\right) \cdot y + x \cdot x} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}}\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}\;x \le -1.688721359903120564949235071844216306814 \cdot 10^{100}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \le 8.394176110344906536659390600257739023023 \cdot 10^{-193}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \le 5.306478096987979835000926393717769469618 \cdot 10^{92}:\\
\;\;\;\;\frac{x \cdot x}{\left(y \cdot 4\right) \cdot y + x \cdot x} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}}\right)\\

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

\end{array}
double f(double x, double y) {
        double r17009592 = x;
        double r17009593 = r17009592 * r17009592;
        double r17009594 = y;
        double r17009595 = 4.0;
        double r17009596 = r17009594 * r17009595;
        double r17009597 = r17009596 * r17009594;
        double r17009598 = r17009593 - r17009597;
        double r17009599 = r17009593 + r17009597;
        double r17009600 = r17009598 / r17009599;
        return r17009600;
}

double f(double x, double y) {
        double r17009601 = x;
        double r17009602 = -1.6887213599031206e+100;
        bool r17009603 = r17009601 <= r17009602;
        double r17009604 = 1.0;
        double r17009605 = -7.394329418796279e-66;
        bool r17009606 = r17009601 <= r17009605;
        double r17009607 = r17009601 * r17009601;
        double r17009608 = y;
        double r17009609 = 4.0;
        double r17009610 = r17009608 * r17009609;
        double r17009611 = r17009610 * r17009608;
        double r17009612 = r17009611 + r17009607;
        double r17009613 = r17009607 / r17009612;
        double r17009614 = r17009611 / r17009612;
        double r17009615 = r17009614 * r17009614;
        double r17009616 = r17009615 * r17009614;
        double r17009617 = cbrt(r17009616);
        double r17009618 = r17009613 - r17009617;
        double r17009619 = 8.394176110344907e-193;
        bool r17009620 = r17009601 <= r17009619;
        double r17009621 = -1.0;
        double r17009622 = 5.30647809698798e+92;
        bool r17009623 = r17009601 <= r17009622;
        double r17009624 = exp(r17009614);
        double r17009625 = log(r17009624);
        double r17009626 = r17009613 - r17009625;
        double r17009627 = r17009623 ? r17009626 : r17009604;
        double r17009628 = r17009620 ? r17009621 : r17009627;
        double r17009629 = r17009606 ? r17009618 : r17009628;
        double r17009630 = r17009603 ? r17009604 : r17009629;
        return r17009630;
}

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.8
Target31.5
Herbie12.9
\[\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 4 regimes
  2. if x < -1.6887213599031206e+100 or 5.30647809698798e+92 < x

    1. Initial program 50.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 11.0

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

    if -1.6887213599031206e+100 < x < -7.394329418796279e-66

    1. Initial program 16.4

      \[\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-sub16.4

      \[\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-cube16.4

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

    if -7.394329418796279e-66 < x < 8.394176110344907e-193

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

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

    if 8.394176110344907e-193 < x < 5.30647809698798e+92

    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 div-sub16.5

      \[\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-exp16.5

      \[\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)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification12.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.688721359903120564949235071844216306814 \cdot 10^{100}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -7.394329418796278633272453346909757071051 \cdot 10^{-66}:\\ \;\;\;\;\frac{x \cdot x}{\left(y \cdot 4\right) \cdot y + x \cdot x} - \sqrt[3]{\left(\frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x} \cdot \frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\right) \cdot \frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}}\\ \mathbf{elif}\;x \le 8.394176110344906536659390600257739023023 \cdot 10^{-193}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 5.306478096987979835000926393717769469618 \cdot 10^{92}:\\ \;\;\;\;\frac{x \cdot x}{\left(y \cdot 4\right) \cdot y + x \cdot x} - \log \left(e^{\frac{\left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}}\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 
(FPCore (x y)
  :name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"

  :herbie-target
  (if (< (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))) 0.9743233849626781) (- (/ (* x x) (+ (* x x) (* (* y y) 4.0))) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))) (- (pow (/ x (sqrt (+ (* x x) (* (* y y) 4.0)))) 2.0) (/ (* (* y y) 4.0) (+ (* x x) (* (* y y) 4.0)))))

  (/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))