Average Error: 15.2 → 1.0
Time: 2.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 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -3.515249924146809120934447925843102277457 \cdot 10^{-302} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 4.988708106140496524747220520898956752625 \cdot 10^{-110}\right)\right)\right):\\ \;\;\;\;\frac{x \cdot 2}{1 \cdot \left(\frac{x}{y} - 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - 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 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -3.515249924146809120934447925843102277457 \cdot 10^{-302} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 4.988708106140496524747220520898956752625 \cdot 10^{-110}\right)\right)\right):\\
\;\;\;\;\frac{x \cdot 2}{1 \cdot \left(\frac{x}{y} - 1\right)}\\

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

\end{array}
double f(double x, double y) {
        double r464208 = x;
        double r464209 = 2.0;
        double r464210 = r464208 * r464209;
        double r464211 = y;
        double r464212 = r464210 * r464211;
        double r464213 = r464208 - r464211;
        double r464214 = r464212 / r464213;
        return r464214;
}

double f(double x, double y) {
        double r464215 = x;
        double r464216 = 2.0;
        double r464217 = r464215 * r464216;
        double r464218 = y;
        double r464219 = r464217 * r464218;
        double r464220 = r464215 - r464218;
        double r464221 = r464219 / r464220;
        double r464222 = -inf.0;
        bool r464223 = r464221 <= r464222;
        double r464224 = -3.515249924146809e-302;
        bool r464225 = r464221 <= r464224;
        double r464226 = -0.0;
        bool r464227 = r464221 <= r464226;
        double r464228 = 4.9887081061404965e-110;
        bool r464229 = r464221 <= r464228;
        double r464230 = !r464229;
        bool r464231 = r464227 || r464230;
        double r464232 = !r464231;
        bool r464233 = r464225 || r464232;
        double r464234 = !r464233;
        bool r464235 = r464223 || r464234;
        double r464236 = 1.0;
        double r464237 = r464215 / r464218;
        double r464238 = r464237 - r464236;
        double r464239 = r464236 * r464238;
        double r464240 = r464217 / r464239;
        double r464241 = r464235 ? r464240 : r464221;
        return r464241;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.2
Target0.4
Herbie1.0
\[\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 -3.515249924146809e-302 < (/ (* (* x 2.0) y) (- x y)) < -0.0 or 4.9887081061404965e-110 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 32.5

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity1.8

      \[\leadsto \frac{x \cdot 2}{\frac{x - y}{\color{blue}{1 \cdot y}}}\]
    6. Applied *-un-lft-identity1.8

      \[\leadsto \frac{x \cdot 2}{\frac{\color{blue}{1 \cdot \left(x - y\right)}}{1 \cdot y}}\]
    7. Applied times-frac1.8

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\frac{1}{1} \cdot \frac{x - y}{y}}}\]
    8. Simplified1.8

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

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

    if -inf.0 < (/ (* (* x 2.0) y) (- x y)) < -3.515249924146809e-302 or -0.0 < (/ (* (* x 2.0) y) (- x y)) < 4.9887081061404965e-110

    1. Initial program 5.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -3.515249924146809120934447925843102277457 \cdot 10^{-302} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.0 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 4.988708106140496524747220520898956752625 \cdot 10^{-110}\right)\right)\right):\\ \;\;\;\;\frac{x \cdot 2}{1 \cdot \left(\frac{x}{y} - 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019354 +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)))