Average Error: 32.0 → 12.7
Time: 9.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}\;x \le -4.844506481309793477015811086474695118347 \cdot 10^{101}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.397641845173585116448266999843103588536 \cdot 10^{-80}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\\ \mathbf{elif}\;x \le 2.301536498063311661306861828114408368058 \cdot 10^{-123}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.131938965300101620603311598271655945714 \cdot 10^{-12}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\\ \mathbf{elif}\;x \le 3063448176040838:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.353386120696897430440169718838837769249 \cdot 10^{95}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\\ \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 -4.844506481309793477015811086474695118347 \cdot 10^{101}:\\
\;\;\;\;1\\

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

\mathbf{elif}\;x \le 2.301536498063311661306861828114408368058 \cdot 10^{-123}:\\
\;\;\;\;-1\\

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

\mathbf{elif}\;x \le 3063448176040838:\\
\;\;\;\;-1\\

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

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

\end{array}
double f(double x, double y) {
        double r30295983 = x;
        double r30295984 = r30295983 * r30295983;
        double r30295985 = y;
        double r30295986 = 4.0;
        double r30295987 = r30295985 * r30295986;
        double r30295988 = r30295987 * r30295985;
        double r30295989 = r30295984 - r30295988;
        double r30295990 = r30295984 + r30295988;
        double r30295991 = r30295989 / r30295990;
        return r30295991;
}

double f(double x, double y) {
        double r30295992 = x;
        double r30295993 = -4.8445064813097935e+101;
        bool r30295994 = r30295992 <= r30295993;
        double r30295995 = 1.0;
        double r30295996 = -1.3976418451735851e-80;
        bool r30295997 = r30295992 <= r30295996;
        double r30295998 = r30295992 * r30295992;
        double r30295999 = y;
        double r30296000 = 4.0;
        double r30296001 = r30295999 * r30296000;
        double r30296002 = r30296001 * r30295999;
        double r30296003 = r30295998 - r30296002;
        double r30296004 = r30296002 + r30295998;
        double r30296005 = r30296003 / r30296004;
        double r30296006 = 2.3015364980633117e-123;
        bool r30296007 = r30295992 <= r30296006;
        double r30296008 = -1.0;
        double r30296009 = 1.1319389653001016e-12;
        bool r30296010 = r30295992 <= r30296009;
        double r30296011 = 3063448176040838.0;
        bool r30296012 = r30295992 <= r30296011;
        double r30296013 = 1.3533861206968974e+95;
        bool r30296014 = r30295992 <= r30296013;
        double r30296015 = r30296014 ? r30296005 : r30295995;
        double r30296016 = r30296012 ? r30296008 : r30296015;
        double r30296017 = r30296010 ? r30296005 : r30296016;
        double r30296018 = r30296007 ? r30296008 : r30296017;
        double r30296019 = r30295997 ? r30296005 : r30296018;
        double r30296020 = r30295994 ? r30295995 : r30296019;
        return r30296020;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original32.0
Target31.7
Herbie12.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 x < -4.8445064813097935e+101 or 1.3533861206968974e+95 < x

    1. Initial program 51.7

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

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

    if -4.8445064813097935e+101 < x < -1.3976418451735851e-80 or 2.3015364980633117e-123 < x < 1.1319389653001016e-12 or 3063448176040838.0 < x < 1.3533861206968974e+95

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

    if -1.3976418451735851e-80 < x < 2.3015364980633117e-123 or 1.1319389653001016e-12 < x < 3063448176040838.0

    1. Initial program 26.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 0 12.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.844506481309793477015811086474695118347 \cdot 10^{101}:\\ \;\;\;\;1\\ \mathbf{elif}\;x \le -1.397641845173585116448266999843103588536 \cdot 10^{-80}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\\ \mathbf{elif}\;x \le 2.301536498063311661306861828114408368058 \cdot 10^{-123}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.131938965300101620603311598271655945714 \cdot 10^{-12}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\\ \mathbf{elif}\;x \le 3063448176040838:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \le 1.353386120696897430440169718838837769249 \cdot 10^{95}:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\left(y \cdot 4\right) \cdot y + x \cdot x}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

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