Average Error: 31.8 → 12.9
Time: 11.4s
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 r37339184 = x;
        double r37339185 = r37339184 * r37339184;
        double r37339186 = y;
        double r37339187 = 4.0;
        double r37339188 = r37339186 * r37339187;
        double r37339189 = r37339188 * r37339186;
        double r37339190 = r37339185 - r37339189;
        double r37339191 = r37339185 + r37339189;
        double r37339192 = r37339190 / r37339191;
        return r37339192;
}

double f(double x, double y) {
        double r37339193 = x;
        double r37339194 = -1.6887213599031206e+100;
        bool r37339195 = r37339193 <= r37339194;
        double r37339196 = 1.0;
        double r37339197 = -7.394329418796279e-66;
        bool r37339198 = r37339193 <= r37339197;
        double r37339199 = r37339193 * r37339193;
        double r37339200 = y;
        double r37339201 = 4.0;
        double r37339202 = r37339200 * r37339201;
        double r37339203 = r37339202 * r37339200;
        double r37339204 = r37339203 + r37339199;
        double r37339205 = r37339199 / r37339204;
        double r37339206 = r37339203 / r37339204;
        double r37339207 = r37339206 * r37339206;
        double r37339208 = r37339207 * r37339206;
        double r37339209 = cbrt(r37339208);
        double r37339210 = r37339205 - r37339209;
        double r37339211 = 8.394176110344907e-193;
        bool r37339212 = r37339193 <= r37339211;
        double r37339213 = -1.0;
        double r37339214 = 5.30647809698798e+92;
        bool r37339215 = r37339193 <= r37339214;
        double r37339216 = exp(r37339206);
        double r37339217 = log(r37339216);
        double r37339218 = r37339205 - r37339217;
        double r37339219 = r37339215 ? r37339218 : r37339196;
        double r37339220 = r37339212 ? r37339213 : r37339219;
        double r37339221 = r37339198 ? r37339210 : r37339220;
        double r37339222 = r37339195 ? r37339196 : r37339221;
        return r37339222;
}

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))))