Average Error: 14.9 → 1.6
Time: 29.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} - 1}\\ \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} - 1}\\

\end{array}
double f(double x, double y) {
        double r392018 = x;
        double r392019 = 2.0;
        double r392020 = r392018 * r392019;
        double r392021 = y;
        double r392022 = r392020 * r392021;
        double r392023 = r392018 - r392021;
        double r392024 = r392022 / r392023;
        return r392024;
}

double f(double x, double y) {
        double r392025 = x;
        double r392026 = 2.0;
        double r392027 = r392025 * r392026;
        double r392028 = y;
        double r392029 = r392027 * r392028;
        double r392030 = r392025 - r392028;
        double r392031 = r392029 / r392030;
        double r392032 = -4372471847897.569;
        bool r392033 = r392031 <= r392032;
        double r392034 = r392028 / r392030;
        double r392035 = r392027 * r392034;
        double r392036 = -1.8329199115535802e-294;
        bool r392037 = r392031 <= r392036;
        double r392038 = 3.567068191551729e-273;
        bool r392039 = r392031 <= r392038;
        double r392040 = !r392039;
        double r392041 = 8.696696788162455e-83;
        bool r392042 = r392031 <= r392041;
        bool r392043 = r392040 && r392042;
        bool r392044 = r392037 || r392043;
        double r392045 = r392025 / r392028;
        double r392046 = 1.0;
        double r392047 = r392045 - r392046;
        double r392048 = r392027 / r392047;
        double r392049 = r392044 ? r392031 : r392048;
        double r392050 = r392033 ? r392035 : r392049;
        return r392050;
}

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}}}\]
    4. Simplified3.5

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\frac{x}{y} - 1}}\]
  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} - 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019235 
(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)))