Average Error: 15.3 → 1.1
Time: 45.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 -4.54363279240194972 \cdot 10^{-14} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.19346764491759707 \cdot 10^{-289} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.20242368809351357 \cdot 10^{-77}\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} \le -4.54363279240194972 \cdot 10^{-14} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.19346764491759707 \cdot 10^{-289} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.20242368809351357 \cdot 10^{-77}\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 r391753 = x;
        double r391754 = 2.0;
        double r391755 = r391753 * r391754;
        double r391756 = y;
        double r391757 = r391755 * r391756;
        double r391758 = r391753 - r391756;
        double r391759 = r391757 / r391758;
        return r391759;
}

double f(double x, double y) {
        double r391760 = x;
        double r391761 = 2.0;
        double r391762 = r391760 * r391761;
        double r391763 = y;
        double r391764 = r391762 * r391763;
        double r391765 = r391760 - r391763;
        double r391766 = r391764 / r391765;
        double r391767 = -4.54363279240195e-14;
        bool r391768 = r391766 <= r391767;
        double r391769 = -4.193467644917597e-289;
        bool r391770 = r391766 <= r391769;
        double r391771 = 0.0;
        bool r391772 = r391766 <= r391771;
        double r391773 = !r391772;
        double r391774 = 1.2024236880935136e-77;
        bool r391775 = r391766 <= r391774;
        bool r391776 = r391773 && r391775;
        bool r391777 = r391770 || r391776;
        double r391778 = !r391777;
        bool r391779 = r391768 || r391778;
        double r391780 = r391763 / r391765;
        double r391781 = r391762 * r391780;
        double r391782 = r391779 ? r391781 : r391766;
        return r391782;
}

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.3
Target0.3
Herbie1.1
\[\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)) < -4.54363279240195e-14 or -4.193467644917597e-289 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 1.2024236880935136e-77 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 28.8

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

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

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

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

    if -4.54363279240195e-14 < (/ (* (* x 2.0) y) (- x y)) < -4.193467644917597e-289 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 1.2024236880935136e-77

    1. Initial program 6.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.54363279240194972 \cdot 10^{-14} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.19346764491759707 \cdot 10^{-289} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.20242368809351357 \cdot 10^{-77}\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 2019199 
(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)))