Average Error: 15.3 → 0.3
Time: 29.3s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.678200599830845516946512912055678313986 \cdot 10^{53} \lor \neg \left(x \le 3.181619446512529125094192620739909077175 \cdot 10^{-59}\right):\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{\frac{x - y}{y}}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -1.678200599830845516946512912055678313986 \cdot 10^{53} \lor \neg \left(x \le 3.181619446512529125094192620739909077175 \cdot 10^{-59}\right):\\
\;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\

\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{\frac{x - y}{y}}\\

\end{array}
double f(double x, double y) {
        double r421608 = x;
        double r421609 = 2.0;
        double r421610 = r421608 * r421609;
        double r421611 = y;
        double r421612 = r421610 * r421611;
        double r421613 = r421608 - r421611;
        double r421614 = r421612 / r421613;
        return r421614;
}

double f(double x, double y) {
        double r421615 = x;
        double r421616 = -1.6782005998308455e+53;
        bool r421617 = r421615 <= r421616;
        double r421618 = 3.181619446512529e-59;
        bool r421619 = r421615 <= r421618;
        double r421620 = !r421619;
        bool r421621 = r421617 || r421620;
        double r421622 = 2.0;
        double r421623 = r421622 * r421615;
        double r421624 = y;
        double r421625 = r421615 - r421624;
        double r421626 = r421623 / r421625;
        double r421627 = r421626 * r421624;
        double r421628 = r421625 / r421624;
        double r421629 = r421623 / r421628;
        double r421630 = r421621 ? r421627 : r421629;
        return r421630;
}

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.4
Herbie0.3
\[\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 2 regimes
  2. if x < -1.6782005998308455e+53 or 3.181619446512529e-59 < x

    1. Initial program 16.0

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    3. Using strategy rm
    4. Applied associate-/r/0.4

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y}\]

    if -1.6782005998308455e+53 < x < 3.181619446512529e-59

    1. Initial program 14.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.678200599830845516946512912055678313986 \cdot 10^{53} \lor \neg \left(x \le 3.181619446512529125094192620739909077175 \cdot 10^{-59}\right):\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{2 \cdot x}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(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)))