Average Error: 31.9 → 12.8
Time: 6.7s
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 \cdot x \le 1.51233920017420984 \cdot 10^{-184}:\\ \;\;\;\;\log \left(e^{-1}\right)\\ \mathbf{elif}\;x \cdot x \le 259753368901583.88:\\ \;\;\;\;\log \left(e^{\left(\sqrt{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}} + \sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \left(\sqrt{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}} - \sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)}\right)\\ \mathbf{elif}\;x \cdot x \le 4.9513109421031689 \cdot 10^{37}:\\ \;\;\;\;\log \left(e^{-1}\right)\\ \mathbf{elif}\;x \cdot x \le 1.4348180576052783 \cdot 10^{267}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\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 \cdot x \le 1.51233920017420984 \cdot 10^{-184}:\\
\;\;\;\;\log \left(e^{-1}\right)\\

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

\mathbf{elif}\;x \cdot x \le 4.9513109421031689 \cdot 10^{37}:\\
\;\;\;\;\log \left(e^{-1}\right)\\

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

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

\end{array}
double f(double x, double y) {
        double r4053 = x;
        double r4054 = r4053 * r4053;
        double r4055 = y;
        double r4056 = 4.0;
        double r4057 = r4055 * r4056;
        double r4058 = r4057 * r4055;
        double r4059 = r4054 - r4058;
        double r4060 = r4054 + r4058;
        double r4061 = r4059 / r4060;
        return r4061;
}

double f(double x, double y) {
        double r4062 = x;
        double r4063 = r4062 * r4062;
        double r4064 = 1.5123392001742098e-184;
        bool r4065 = r4063 <= r4064;
        double r4066 = 1.0;
        double r4067 = -r4066;
        double r4068 = exp(r4067);
        double r4069 = log(r4068);
        double r4070 = 259753368901583.88;
        bool r4071 = r4063 <= r4070;
        double r4072 = y;
        double r4073 = 4.0;
        double r4074 = r4072 * r4073;
        double r4075 = r4074 * r4072;
        double r4076 = r4063 + r4075;
        double r4077 = r4063 / r4076;
        double r4078 = sqrt(r4077);
        double r4079 = r4075 / r4076;
        double r4080 = sqrt(r4079);
        double r4081 = r4078 + r4080;
        double r4082 = r4078 - r4080;
        double r4083 = r4081 * r4082;
        double r4084 = exp(r4083);
        double r4085 = log(r4084);
        double r4086 = 4.951310942103169e+37;
        bool r4087 = r4063 <= r4086;
        double r4088 = 1.4348180576052783e+267;
        bool r4089 = r4063 <= r4088;
        double r4090 = r4063 - r4075;
        double r4091 = r4090 / r4076;
        double r4092 = exp(r4091);
        double r4093 = log(r4092);
        double r4094 = 1.0;
        double r4095 = r4089 ? r4093 : r4094;
        double r4096 = r4087 ? r4069 : r4095;
        double r4097 = r4071 ? r4085 : r4096;
        double r4098 = r4065 ? r4069 : r4097;
        return r4098;
}

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.9
Target31.6
Herbie12.8
\[\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 4 regimes
  2. if (* x x) < 1.5123392001742098e-184 or 259753368901583.88 < (* x x) < 4.951310942103169e+37

    1. Initial program 25.9

      \[\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-log-exp25.9

      \[\leadsto \color{blue}{\log \left(e^{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)}\]
    4. Using strategy rm
    5. Applied div-sub25.9

      \[\leadsto \log \left(e^{\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}}}\right)\]
    6. Taylor expanded around 0 11.9

      \[\leadsto \log \left(e^{\color{blue}{-1}}\right)\]

    if 1.5123392001742098e-184 < (* x x) < 259753368901583.88

    1. Initial program 16.1

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

      \[\leadsto \color{blue}{\log \left(e^{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)}\]
    4. Using strategy rm
    5. Applied div-sub16.1

      \[\leadsto \log \left(e^{\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}}}\right)\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt16.1

      \[\leadsto \log \left(e^{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y} - \color{blue}{\sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}}\right)\]
    8. Applied add-sqr-sqrt16.1

      \[\leadsto \log \left(e^{\color{blue}{\sqrt{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}}} - \sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\right)\]
    9. Applied difference-of-squares16.1

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

    if 4.951310942103169e+37 < (* x x) < 1.4348180576052783e+267

    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 add-log-exp16.5

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

    if 1.4348180576052783e+267 < (* x x)

    1. Initial program 58.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \le 1.51233920017420984 \cdot 10^{-184}:\\ \;\;\;\;\log \left(e^{-1}\right)\\ \mathbf{elif}\;x \cdot x \le 259753368901583.88:\\ \;\;\;\;\log \left(e^{\left(\sqrt{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}} + \sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right) \cdot \left(\sqrt{\frac{x \cdot x}{x \cdot x + \left(y \cdot 4\right) \cdot y}} - \sqrt{\frac{\left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)}\right)\\ \mathbf{elif}\;x \cdot x \le 4.9513109421031689 \cdot 10^{37}:\\ \;\;\;\;\log \left(e^{-1}\right)\\ \mathbf{elif}\;x \cdot x \le 1.4348180576052783 \cdot 10^{267}:\\ \;\;\;\;\log \left(e^{\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}}\right)\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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