Average Error: 31.5 → 13.7
Time: 5.0s
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 1.192091757034716875562004260761946839377 \cdot 10^{-148}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5023037.11664885468780994415283203125:\\ \;\;\;\;\frac{x \cdot x - \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.299955378765698430754228883252507192043 \cdot 10^{56}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 7.178993365575064349423842969964358817229 \cdot 10^{117}:\\ \;\;\;\;\frac{x \cdot x - \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 1.326274821237603836714109292552910696965 \cdot 10^{134}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5.213367998754109189462840924333391286818 \cdot 10^{168}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \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 1.192091757034716875562004260761946839377 \cdot 10^{-148}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5023037.11664885468780994415283203125:\\
\;\;\;\;\frac{x \cdot x - \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.299955378765698430754228883252507192043 \cdot 10^{56}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 7.178993365575064349423842969964358817229 \cdot 10^{117}:\\
\;\;\;\;\frac{x \cdot x - \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 1.326274821237603836714109292552910696965 \cdot 10^{134}:\\
\;\;\;\;1\\

\mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5.213367998754109189462840924333391286818 \cdot 10^{168}:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\

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

\end{array}
double f(double x, double y) {
        double r443350 = x;
        double r443351 = r443350 * r443350;
        double r443352 = y;
        double r443353 = 4.0;
        double r443354 = r443352 * r443353;
        double r443355 = r443354 * r443352;
        double r443356 = r443351 - r443355;
        double r443357 = r443351 + r443355;
        double r443358 = r443356 / r443357;
        return r443358;
}

double f(double x, double y) {
        double r443359 = y;
        double r443360 = 4.0;
        double r443361 = r443359 * r443360;
        double r443362 = r443361 * r443359;
        double r443363 = 1.1920917570347169e-148;
        bool r443364 = r443362 <= r443363;
        double r443365 = 1.0;
        double r443366 = 5023037.116648855;
        bool r443367 = r443362 <= r443366;
        double r443368 = x;
        double r443369 = r443368 * r443368;
        double r443370 = r443369 - r443362;
        double r443371 = r443369 + r443362;
        double r443372 = r443370 / r443371;
        double r443373 = 2.2999553787656984e+56;
        bool r443374 = r443362 <= r443373;
        double r443375 = 7.178993365575064e+117;
        bool r443376 = r443362 <= r443375;
        double r443377 = 1.3262748212376038e+134;
        bool r443378 = r443362 <= r443377;
        double r443379 = 5.213367998754109e+168;
        bool r443380 = r443362 <= r443379;
        double r443381 = -1.0;
        double r443382 = r443380 ? r443372 : r443381;
        double r443383 = r443378 ? r443365 : r443382;
        double r443384 = r443376 ? r443372 : r443383;
        double r443385 = r443374 ? r443365 : r443384;
        double r443386 = r443367 ? r443372 : r443385;
        double r443387 = r443364 ? r443365 : r443386;
        return r443387;
}

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.5
Target31.2
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.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 3 regimes
  2. if (* (* y 4.0) y) < 1.1920917570347169e-148 or 5023037.116648855 < (* (* y 4.0) y) < 2.2999553787656984e+56 or 7.178993365575064e+117 < (* (* y 4.0) y) < 1.3262748212376038e+134

    1. Initial program 24.0

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

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

    if 1.1920917570347169e-148 < (* (* y 4.0) y) < 5023037.116648855 or 2.2999553787656984e+56 < (* (* y 4.0) y) < 7.178993365575064e+117 or 1.3262748212376038e+134 < (* (* y 4.0) y) < 5.213367998754109e+168

    1. Initial program 15.2

      \[\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\]

    if 5.213367998754109e+168 < (* (* y 4.0) y)

    1. Initial program 49.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 4\right) \cdot y \le 1.192091757034716875562004260761946839377 \cdot 10^{-148}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5023037.11664885468780994415283203125:\\ \;\;\;\;\frac{x \cdot x - \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.299955378765698430754228883252507192043 \cdot 10^{56}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 7.178993365575064349423842969964358817229 \cdot 10^{117}:\\ \;\;\;\;\frac{x \cdot x - \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 1.326274821237603836714109292552910696965 \cdot 10^{134}:\\ \;\;\;\;1\\ \mathbf{elif}\;\left(y \cdot 4\right) \cdot y \le 5.213367998754109189462840924333391286818 \cdot 10^{168}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array}\]

Reproduce

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