Average Error: 14.5 → 0.5
Time: 8.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} \le -1.2522597451573698 \cdot 10^{36}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.07282229195027374 \cdot 10^{-303}:\\ \;\;\;\;\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:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 7.9167156475250042 \cdot 10^{24}:\\ \;\;\;\;\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} \le -1.2522597451573698 \cdot 10^{36}:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.07282229195027374 \cdot 10^{-303}:\\
\;\;\;\;\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:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 7.9167156475250042 \cdot 10^{24}:\\
\;\;\;\;\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 r572221 = x;
        double r572222 = 2.0;
        double r572223 = r572221 * r572222;
        double r572224 = y;
        double r572225 = r572223 * r572224;
        double r572226 = r572221 - r572224;
        double r572227 = r572225 / r572226;
        return r572227;
}

double f(double x, double y) {
        double r572228 = x;
        double r572229 = 2.0;
        double r572230 = r572228 * r572229;
        double r572231 = y;
        double r572232 = r572230 * r572231;
        double r572233 = r572228 - r572231;
        double r572234 = r572232 / r572233;
        double r572235 = -1.2522597451573698e+36;
        bool r572236 = r572234 <= r572235;
        double r572237 = r572231 / r572233;
        double r572238 = r572230 * r572237;
        double r572239 = -1.0728222919502737e-303;
        bool r572240 = r572234 <= r572239;
        double r572241 = -0.0;
        bool r572242 = r572234 <= r572241;
        double r572243 = 7.916715647525004e+24;
        bool r572244 = r572234 <= r572243;
        double r572245 = r572233 / r572231;
        double r572246 = r572230 / r572245;
        double r572247 = r572244 ? r572234 : r572246;
        double r572248 = r572242 ? r572238 : r572247;
        double r572249 = r572240 ? r572234 : r572248;
        double r572250 = r572236 ? r572238 : r572249;
        return r572250;
}

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.5
Target0.3
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \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 3 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -1.2522597451573698e+36 or -1.0728222919502737e-303 < (/ (* (* x 2.0) y) (- x y)) < -0.0

    1. Initial program 48.6

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity48.6

      \[\leadsto \frac{\left(x \cdot 2\right) \cdot y}{\color{blue}{1 \cdot \left(x - y\right)}}\]
    4. Applied times-frac0.9

      \[\leadsto \color{blue}{\frac{x \cdot 2}{1} \cdot \frac{y}{x - y}}\]
    5. Simplified0.9

      \[\leadsto \color{blue}{\left(x \cdot 2\right)} \cdot \frac{y}{x - y}\]

    if -1.2522597451573698e+36 < (/ (* (* x 2.0) y) (- x y)) < -1.0728222919502737e-303 or -0.0 < (/ (* (* x 2.0) y) (- x y)) < 7.916715647525004e+24

    1. Initial program 0.5

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

    if 7.916715647525004e+24 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 37.6

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.2522597451573698 \cdot 10^{36}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.07282229195027374 \cdot 10^{-303}:\\ \;\;\;\;\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:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 7.9167156475250042 \cdot 10^{24}:\\ \;\;\;\;\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 2020043 +o rules:numerics
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

  (/ (* (* x 2) y) (- x y)))