Average Error: 14.9 → 0.8
Time: 32.0s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.396489445126898884348483928575845493119 \cdot 10^{-307}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.926138125589413867784897629846549013713 \cdot 10^{-93}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.396489445126898884348483928575845493119 \cdot 10^{-307}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.926138125589413867784897629846549013713 \cdot 10^{-93}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

\end{array}
double f(double x, double y) {
        double r29909009 = x;
        double r29909010 = 2.0;
        double r29909011 = r29909009 * r29909010;
        double r29909012 = y;
        double r29909013 = r29909011 * r29909012;
        double r29909014 = r29909009 - r29909012;
        double r29909015 = r29909013 / r29909014;
        return r29909015;
}

double f(double x, double y) {
        double r29909016 = x;
        double r29909017 = 2.0;
        double r29909018 = r29909016 * r29909017;
        double r29909019 = y;
        double r29909020 = r29909018 * r29909019;
        double r29909021 = r29909016 - r29909019;
        double r29909022 = r29909020 / r29909021;
        double r29909023 = -inf.0;
        bool r29909024 = r29909022 <= r29909023;
        double r29909025 = r29909021 / r29909019;
        double r29909026 = r29909018 / r29909025;
        double r29909027 = -1.3964894451268989e-307;
        bool r29909028 = r29909022 <= r29909027;
        double r29909029 = 0.0;
        bool r29909030 = r29909022 <= r29909029;
        double r29909031 = 1.926138125589414e-93;
        bool r29909032 = r29909022 <= r29909031;
        double r29909033 = r29909032 ? r29909022 : r29909026;
        double r29909034 = r29909030 ? r29909026 : r29909033;
        double r29909035 = r29909028 ? r29909022 : r29909034;
        double r29909036 = r29909024 ? r29909026 : r29909035;
        return r29909036;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.9
Target0.4
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;x \lt -1.721044263414944729490876394165887012892 \cdot 10^{81}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \lt 83645045635564432:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -inf.0 or -1.3964894451268989e-307 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 1.926138125589414e-93 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 37.0

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l*1.1

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]

    if -inf.0 < (/ (* (* x 2.0) y) (- x y)) < -1.3964894451268989e-307 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 1.926138125589414e-93

    1. Initial program 0.5

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.396489445126898884348483928575845493119 \cdot 10^{-307}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.926138125589413867784897629846549013713 \cdot 10^{-93}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))