Average Error: 15.1 → 0.9
Time: 2.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 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.4108510848905031 \cdot 10^{-307} \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 7.98976594251477736 \cdot 10^{-110}\right)\right)\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \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 -1.4108510848905031 \cdot 10^{-307} \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 7.98976594251477736 \cdot 10^{-110}\right)\right)\right):\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r524710 = x;
        double r524711 = 2.0;
        double r524712 = r524710 * r524711;
        double r524713 = y;
        double r524714 = r524712 * r524713;
        double r524715 = r524710 - r524713;
        double r524716 = r524714 / r524715;
        return r524716;
}

double f(double x, double y) {
        double r524717 = x;
        double r524718 = 2.0;
        double r524719 = r524717 * r524718;
        double r524720 = y;
        double r524721 = r524719 * r524720;
        double r524722 = r524717 - r524720;
        double r524723 = r524721 / r524722;
        double r524724 = -inf.0;
        bool r524725 = r524723 <= r524724;
        double r524726 = -1.410851084890503e-307;
        bool r524727 = r524723 <= r524726;
        double r524728 = -0.0;
        bool r524729 = r524723 <= r524728;
        double r524730 = 7.989765942514777e-110;
        bool r524731 = r524723 <= r524730;
        double r524732 = !r524731;
        bool r524733 = r524729 || r524732;
        double r524734 = !r524733;
        bool r524735 = r524727 || r524734;
        double r524736 = !r524735;
        bool r524737 = r524725 || r524736;
        double r524738 = r524720 / r524722;
        double r524739 = r524719 * r524738;
        double r524740 = r524737 ? r524739 : r524723;
        return r524740;
}

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.1
Target0.4
Herbie0.9
\[\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 2 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -inf.0 or -1.410851084890503e-307 < (/ (* (* x 2.0) y) (- x y)) < -0.0 or 7.989765942514777e-110 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 35.8

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

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

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

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

    if -inf.0 < (/ (* (* x 2.0) y) (- x y)) < -1.410851084890503e-307 or -0.0 < (/ (* (* x 2.0) y) (- x y)) < 7.989765942514777e-110

    1. Initial program 0.7

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

    \[\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 -1.4108510848905031 \cdot 10^{-307} \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 7.98976594251477736 \cdot 10^{-110}\right)\right)\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

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