Average Error: 15.3 → 0.1
Time: 30.6s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -73036423.040567547 \lor \neg \left(y \le 2.86811390672079895 \cdot 10^{31}\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - 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 -73036423.040567547 \lor \neg \left(y \le 2.86811390672079895 \cdot 10^{31}\right):\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r332676 = x;
        double r332677 = 2.0;
        double r332678 = r332676 * r332677;
        double r332679 = y;
        double r332680 = r332678 * r332679;
        double r332681 = r332676 - r332679;
        double r332682 = r332680 / r332681;
        return r332682;
}

double f(double x, double y) {
        double r332683 = y;
        double r332684 = -73036423.04056755;
        bool r332685 = r332683 <= r332684;
        double r332686 = 2.868113906720799e+31;
        bool r332687 = r332683 <= r332686;
        double r332688 = !r332687;
        bool r332689 = r332685 || r332688;
        double r332690 = x;
        double r332691 = 2.0;
        double r332692 = r332690 * r332691;
        double r332693 = r332690 - r332683;
        double r332694 = r332683 / r332693;
        double r332695 = r332692 * r332694;
        double r332696 = r332692 / r332693;
        double r332697 = r332696 * r332683;
        double r332698 = r332689 ? r332695 : r332697;
        return r332698;
}

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
Herbie0.1
\[\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 < -73036423.04056755 or 2.868113906720799e+31 < y

    1. Initial program 17.1

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

      \[\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 -73036423.04056755 < y < 2.868113906720799e+31

    1. Initial program 13.7

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

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

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

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

Reproduce

herbie shell --seed 2019198 +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)))