Average Error: 31.8 → 15.1
Time: 1.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}\;\left(y \cdot 4\right) \cdot y \le 5.5059358999267487 \cdot 10^{-179}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 6.0996771267235233 \cdot 10^{98}:\\ \;\;\;\;\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}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 2.69891227082106497 \cdot 10^{230}:\\ \;\;\;\;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}\;\left(y \cdot 4\right) \cdot y \le 5.5059358999267487 \cdot 10^{-179}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 6.0996771267235233 \cdot 10^{98}:\\
\;\;\;\;\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}\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 2.69891227082106497 \cdot 10^{230}:\\
\;\;\;\;1\\

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

\end{array}
double f(double x, double y) {
        double r668325 = x;
        double r668326 = r668325 * r668325;
        double r668327 = y;
        double r668328 = 4.0;
        double r668329 = r668327 * r668328;
        double r668330 = r668329 * r668327;
        double r668331 = r668326 - r668330;
        double r668332 = r668326 + r668330;
        double r668333 = r668331 / r668332;
        return r668333;
}

double f(double x, double y) {
        double r668334 = y;
        double r668335 = 4.0;
        double r668336 = r668334 * r668335;
        double r668337 = r668336 * r668334;
        double r668338 = 5.505935899926749e-179;
        bool r668339 = r668337 <= r668338;
        double r668340 = 1.0;
        double r668341 = 6.099677126723523e+98;
        bool r668342 = r668337 <= r668341;
        double r668343 = x;
        double r668344 = r668343 * r668343;
        double r668345 = r668344 + r668337;
        double r668346 = r668344 / r668345;
        double r668347 = r668337 / r668345;
        double r668348 = r668346 - r668347;
        double r668349 = 2.698912270821065e+230;
        bool r668350 = r668337 <= r668349;
        double r668351 = 1.0;
        double r668352 = -r668351;
        double r668353 = r668350 ? r668340 : r668352;
        double r668354 = r668342 ? r668348 : r668353;
        double r668355 = r668339 ? r668340 : r668354;
        return r668355;
}

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
Herbie15.1
\[\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 (* (* y 4.0) y) < 5.505935899926749e-179 or 6.099677126723523e+98 < (* (* y 4.0) y) < 2.698912270821065e+230

    1. Initial program 23.8

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

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

    if 5.505935899926749e-179 < (* (* y 4.0) y) < 6.099677126723523e+98

    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}}\]

    if 2.698912270821065e+230 < (* (* y 4.0) y)

    1. Initial program 53.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 div-sub53.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 4\right) \cdot y \le 5.5059358999267487 \cdot 10^{-179}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 6.0996771267235233 \cdot 10^{98}:\\ \;\;\;\;\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}\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 2.69891227082106497 \cdot 10^{230}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

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