Average Error: 14.9 → 1.6
Time: 34.4s
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 -4372471847897.56884765625:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.832919911553580188326823033307050859672 \cdot 10^{-294} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.567068191551728953705595025476108263083 \cdot 10^{-273}\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 8.696696788162455358371963434366603594975 \cdot 10^{-83}:\\ \;\;\;\;\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 -4372471847897.56884765625:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.832919911553580188326823033307050859672 \cdot 10^{-294} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.567068191551728953705595025476108263083 \cdot 10^{-273}\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 8.696696788162455358371963434366603594975 \cdot 10^{-83}:\\
\;\;\;\;\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 r990784 = x;
        double r990785 = 2.0;
        double r990786 = r990784 * r990785;
        double r990787 = y;
        double r990788 = r990786 * r990787;
        double r990789 = r990784 - r990787;
        double r990790 = r990788 / r990789;
        return r990790;
}

double f(double x, double y) {
        double r990791 = x;
        double r990792 = 2.0;
        double r990793 = r990791 * r990792;
        double r990794 = y;
        double r990795 = r990793 * r990794;
        double r990796 = r990791 - r990794;
        double r990797 = r990795 / r990796;
        double r990798 = -4372471847897.569;
        bool r990799 = r990797 <= r990798;
        double r990800 = r990794 / r990796;
        double r990801 = r990793 * r990800;
        double r990802 = -1.8329199115535802e-294;
        bool r990803 = r990797 <= r990802;
        double r990804 = 3.567068191551729e-273;
        bool r990805 = r990797 <= r990804;
        double r990806 = !r990805;
        double r990807 = 8.696696788162455e-83;
        bool r990808 = r990797 <= r990807;
        bool r990809 = r990806 && r990808;
        bool r990810 = r990803 || r990809;
        double r990811 = r990796 / r990794;
        double r990812 = r990793 / r990811;
        double r990813 = r990810 ? r990797 : r990812;
        double r990814 = r990799 ? r990801 : r990813;
        return r990814;
}

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.9
Target0.3
Herbie1.6
\[\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 3 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -4372471847897.569

    1. Initial program 35.6

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

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

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

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

    if -4372471847897.569 < (/ (* (* x 2.0) y) (- x y)) < -1.8329199115535802e-294 or 3.567068191551729e-273 < (/ (* (* x 2.0) y) (- x y)) < 8.696696788162455e-83

    1. Initial program 0.7

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

    if -1.8329199115535802e-294 < (/ (* (* x 2.0) y) (- x y)) < 3.567068191551729e-273 or 8.696696788162455e-83 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 29.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4372471847897.56884765625:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.832919911553580188326823033307050859672 \cdot 10^{-294} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.567068191551728953705595025476108263083 \cdot 10^{-273}\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 8.696696788162455358371963434366603594975 \cdot 10^{-83}:\\ \;\;\;\;\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 2019235 +o rules:numerics
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

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