Average Error: 15.5 → 0.4
Time: 2.3s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.1116518480520122 \cdot 10^{66} \lor \neg \left(y \le 3.6268085031482395 \cdot 10^{-63}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -1.1116518480520122 \cdot 10^{66} \lor \neg \left(y \le 3.6268085031482395 \cdot 10^{-63}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r530602 = x;
        double r530603 = 2.0;
        double r530604 = r530602 * r530603;
        double r530605 = y;
        double r530606 = r530604 * r530605;
        double r530607 = r530602 - r530605;
        double r530608 = r530606 / r530607;
        return r530608;
}

double f(double x, double y) {
        double r530609 = y;
        double r530610 = -1.1116518480520122e+66;
        bool r530611 = r530609 <= r530610;
        double r530612 = 3.6268085031482395e-63;
        bool r530613 = r530609 <= r530612;
        double r530614 = !r530613;
        bool r530615 = r530611 || r530614;
        double r530616 = x;
        double r530617 = 2.0;
        double r530618 = r530616 * r530617;
        double r530619 = r530616 - r530609;
        double r530620 = r530619 / r530609;
        double r530621 = r530618 / r530620;
        double r530622 = r530618 / r530619;
        double r530623 = r530622 * r530609;
        double r530624 = r530615 ? r530621 : r530623;
        return r530624;
}

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.5
Target0.4
Herbie0.4
\[\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 y < -1.1116518480520122e+66 or 3.6268085031482395e-63 < y

    1. Initial program 16.5

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

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

    if -1.1116518480520122e+66 < y < 3.6268085031482395e-63

    1. Initial program 14.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.1116518480520122 \cdot 10^{66} \lor \neg \left(y \le 3.6268085031482395 \cdot 10^{-63}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2020083 +o rules:numerics
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

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