Average Error: 15.2 → 1.0
Time: 2.1s
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 r587682 = x;
        double r587683 = 2.0;
        double r587684 = r587682 * r587683;
        double r587685 = y;
        double r587686 = r587684 * r587685;
        double r587687 = r587682 - r587685;
        double r587688 = r587686 / r587687;
        return r587688;
}

double f(double x, double y) {
        double r587689 = x;
        double r587690 = 2.0;
        double r587691 = r587689 * r587690;
        double r587692 = y;
        double r587693 = r587691 * r587692;
        double r587694 = r587689 - r587692;
        double r587695 = r587693 / r587694;
        double r587696 = -inf.0;
        bool r587697 = r587695 <= r587696;
        double r587698 = -3.515249924146809e-302;
        bool r587699 = r587695 <= r587698;
        double r587700 = -0.0;
        bool r587701 = r587695 <= r587700;
        double r587702 = 4.9887081061404965e-110;
        bool r587703 = r587695 <= r587702;
        double r587704 = !r587703;
        bool r587705 = r587701 || r587704;
        double r587706 = !r587705;
        bool r587707 = r587699 || r587706;
        double r587708 = !r587707;
        bool r587709 = r587697 || r587708;
        double r587710 = 1.0;
        double r587711 = r587689 / r587692;
        double r587712 = r587711 - r587710;
        double r587713 = r587710 * r587712;
        double r587714 = r587691 / r587713;
        double r587715 = r587709 ? r587714 : r587695;
        return r587715;
}

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 
(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)))