Average Error: 14.7 → 0.4
Time: 3.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.8379060927151348 \cdot 10^{37} \lor \neg \left(y \le 2.53558016914647718 \cdot 10^{-106}\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 -1.8379060927151348 \cdot 10^{37} \lor \neg \left(y \le 2.53558016914647718 \cdot 10^{-106}\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 r499969 = x;
        double r499970 = 2.0;
        double r499971 = r499969 * r499970;
        double r499972 = y;
        double r499973 = r499971 * r499972;
        double r499974 = r499969 - r499972;
        double r499975 = r499973 / r499974;
        return r499975;
}

double f(double x, double y) {
        double r499976 = y;
        double r499977 = -1.8379060927151348e+37;
        bool r499978 = r499976 <= r499977;
        double r499979 = 2.535580169146477e-106;
        bool r499980 = r499976 <= r499979;
        double r499981 = !r499980;
        bool r499982 = r499978 || r499981;
        double r499983 = x;
        double r499984 = 2.0;
        double r499985 = r499983 * r499984;
        double r499986 = r499983 - r499976;
        double r499987 = r499976 / r499986;
        double r499988 = r499985 * r499987;
        double r499989 = r499985 / r499986;
        double r499990 = r499989 * r499976;
        double r499991 = r499982 ? r499988 : r499990;
        return r499991;
}

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.7
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.8379060927151348e+37 or 2.535580169146477e-106 < y

    1. Initial program 14.6

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

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

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

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

    if -1.8379060927151348e+37 < y < 2.535580169146477e-106

    1. Initial program 15.0

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

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

      \[\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.8379060927151348 \cdot 10^{37} \lor \neg \left(y \le 2.53558016914647718 \cdot 10^{-106}\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 2020045 +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)))