Average Error: 14.9 → 0.8
Time: 33.7s
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 r20659835 = x;
        double r20659836 = 2.0;
        double r20659837 = r20659835 * r20659836;
        double r20659838 = y;
        double r20659839 = r20659837 * r20659838;
        double r20659840 = r20659835 - r20659838;
        double r20659841 = r20659839 / r20659840;
        return r20659841;
}

double f(double x, double y) {
        double r20659842 = x;
        double r20659843 = 2.0;
        double r20659844 = r20659842 * r20659843;
        double r20659845 = y;
        double r20659846 = r20659844 * r20659845;
        double r20659847 = r20659842 - r20659845;
        double r20659848 = r20659846 / r20659847;
        double r20659849 = -inf.0;
        bool r20659850 = r20659848 <= r20659849;
        double r20659851 = r20659847 / r20659845;
        double r20659852 = r20659844 / r20659851;
        double r20659853 = -1.3964894451268989e-307;
        bool r20659854 = r20659848 <= r20659853;
        double r20659855 = 0.0;
        bool r20659856 = r20659848 <= r20659855;
        double r20659857 = 1.926138125589414e-93;
        bool r20659858 = r20659848 <= r20659857;
        double r20659859 = r20659858 ? r20659848 : r20659852;
        double r20659860 = r20659856 ? r20659852 : r20659859;
        double r20659861 = r20659854 ? r20659848 : r20659860;
        double r20659862 = r20659850 ? r20659852 : r20659861;
        return r20659862;
}

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 +o rules:numerics
(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)))