Average Error: 15.3 → 1.0
Time: 31.5s
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 -1.0121470746777099 \cdot 10^{-28}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -7.62356398916008339 \cdot 10^{-297} \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 2.66954870712999454 \cdot 10^{-55}:\\ \;\;\;\;\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 -1.0121470746777099 \cdot 10^{-28}:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -7.62356398916008339 \cdot 10^{-297} \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 2.66954870712999454 \cdot 10^{-55}:\\
\;\;\;\;\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 r428431 = x;
        double r428432 = 2.0;
        double r428433 = r428431 * r428432;
        double r428434 = y;
        double r428435 = r428433 * r428434;
        double r428436 = r428431 - r428434;
        double r428437 = r428435 / r428436;
        return r428437;
}

double f(double x, double y) {
        double r428438 = x;
        double r428439 = 2.0;
        double r428440 = r428438 * r428439;
        double r428441 = y;
        double r428442 = r428440 * r428441;
        double r428443 = r428438 - r428441;
        double r428444 = r428442 / r428443;
        double r428445 = -1.01214707467771e-28;
        bool r428446 = r428444 <= r428445;
        double r428447 = r428441 / r428443;
        double r428448 = r428440 * r428447;
        double r428449 = -7.623563989160083e-297;
        bool r428450 = r428444 <= r428449;
        double r428451 = 0.0;
        bool r428452 = r428444 <= r428451;
        double r428453 = !r428452;
        double r428454 = 2.6695487071299945e-55;
        bool r428455 = r428444 <= r428454;
        bool r428456 = r428453 && r428455;
        bool r428457 = r428450 || r428456;
        double r428458 = r428438 / r428441;
        double r428459 = 1.0;
        double r428460 = r428458 - r428459;
        double r428461 = r428440 / r428460;
        double r428462 = r428457 ? r428444 : r428461;
        double r428463 = r428446 ? r428448 : r428462;
        return r428463;
}

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.0
\[\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 3 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -1.01214707467771e-28

    1. Initial program 26.7

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

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

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

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

    if -1.01214707467771e-28 < (/ (* (* x 2.0) y) (- x y)) < -7.623563989160083e-297 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 2.6695487071299945e-55

    1. Initial program 6.1

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

    if -7.623563989160083e-297 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 2.6695487071299945e-55 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 31.4

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Simplified2.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.0121470746777099 \cdot 10^{-28}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -7.62356398916008339 \cdot 10^{-297} \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 2.66954870712999454 \cdot 10^{-55}:\\ \;\;\;\;\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 2019198 
(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)))