Average Error: 32.2 → 12.7
Time: 8.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 \cdot x \le 3.770694955744929504807609661742897517559 \cdot 10^{-271}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 304197.817647762596607208251953125:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \cdot x \le 976096897772602877177495552:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 2.990743016037849587630975269854915303221 \cdot 10^{249}:\\ \;\;\;\;\frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{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}\;x \cdot x \le 3.770694955744929504807609661742897517559 \cdot 10^{-271}:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \le 304197.817647762596607208251953125:\\
\;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\

\mathbf{elif}\;x \cdot x \le 976096897772602877177495552:\\
\;\;\;\;-1\\

\mathbf{elif}\;x \cdot x \le 2.990743016037849587630975269854915303221 \cdot 10^{249}:\\
\;\;\;\;\frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\

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

\end{array}
double f(double x, double y) {
        double r474877 = x;
        double r474878 = r474877 * r474877;
        double r474879 = y;
        double r474880 = 4.0;
        double r474881 = r474879 * r474880;
        double r474882 = r474881 * r474879;
        double r474883 = r474878 - r474882;
        double r474884 = r474878 + r474882;
        double r474885 = r474883 / r474884;
        return r474885;
}

double f(double x, double y) {
        double r474886 = x;
        double r474887 = r474886 * r474886;
        double r474888 = 3.7706949557449295e-271;
        bool r474889 = r474887 <= r474888;
        double r474890 = -1.0;
        double r474891 = 304197.8176477626;
        bool r474892 = r474887 <= r474891;
        double r474893 = y;
        double r474894 = 4.0;
        double r474895 = r474893 * r474894;
        double r474896 = r474895 * r474893;
        double r474897 = r474887 - r474896;
        double r474898 = r474887 + r474896;
        double r474899 = r474897 / r474898;
        double r474900 = 9.760968977726029e+26;
        bool r474901 = r474887 <= r474900;
        double r474902 = 2.9907430160378496e+249;
        bool r474903 = r474887 <= r474902;
        double r474904 = cbrt(r474897);
        double r474905 = r474904 * r474904;
        double r474906 = cbrt(r474898);
        double r474907 = r474906 * r474906;
        double r474908 = r474905 / r474907;
        double r474909 = r474904 / r474906;
        double r474910 = r474908 * r474909;
        double r474911 = 1.0;
        double r474912 = r474903 ? r474910 : r474911;
        double r474913 = r474901 ? r474890 : r474912;
        double r474914 = r474892 ? r474899 : r474913;
        double r474915 = r474889 ? r474890 : r474914;
        return r474915;
}

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.2
Target31.8
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 4 regimes
  2. if (* x x) < 3.7706949557449295e-271 or 304197.8176477626 < (* x x) < 9.760968977726029e+26

    1. Initial program 28.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 11.0

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

    if 3.7706949557449295e-271 < (* x x) < 304197.8176477626

    1. Initial program 16.6

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

    if 9.760968977726029e+26 < (* x x) < 2.9907430160378496e+249

    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 add-cube-cbrt17.4

      \[\leadsto \frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{\color{blue}{\left(\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}}}\]
    4. Applied add-cube-cbrt16.5

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}\right) \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}}{\left(\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}\right) \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}}\]
    5. Applied times-frac16.5

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

    if 2.9907430160378496e+249 < (* x x)

    1. Initial program 56.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 inf 9.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot x \le 3.770694955744929504807609661742897517559 \cdot 10^{-271}:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 304197.817647762596607208251953125:\\ \;\;\;\;\frac{x \cdot x - \left(y \cdot 4\right) \cdot y}{x \cdot x + \left(y \cdot 4\right) \cdot y}\\ \mathbf{elif}\;x \cdot x \le 976096897772602877177495552:\\ \;\;\;\;-1\\ \mathbf{elif}\;x \cdot x \le 2.990743016037849587630975269854915303221 \cdot 10^{249}:\\ \;\;\;\;\frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y} \cdot \sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}} \cdot \frac{\sqrt[3]{x \cdot x - \left(y \cdot 4\right) \cdot y}}{\sqrt[3]{x \cdot x + \left(y \cdot 4\right) \cdot y}}\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array}\]

Reproduce

herbie shell --seed 2019297 
(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.974323384962678118) (- (/ (* 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))))