Average Error: 14.7 → 0.4
Time: 3.6s
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 r626756 = x;
        double r626757 = 2.0;
        double r626758 = r626756 * r626757;
        double r626759 = y;
        double r626760 = r626758 * r626759;
        double r626761 = r626756 - r626759;
        double r626762 = r626760 / r626761;
        return r626762;
}

double f(double x, double y) {
        double r626763 = y;
        double r626764 = -1.8379060927151348e+37;
        bool r626765 = r626763 <= r626764;
        double r626766 = 2.535580169146477e-106;
        bool r626767 = r626763 <= r626766;
        double r626768 = !r626767;
        bool r626769 = r626765 || r626768;
        double r626770 = x;
        double r626771 = 2.0;
        double r626772 = r626770 * r626771;
        double r626773 = r626770 - r626763;
        double r626774 = r626763 / r626773;
        double r626775 = r626772 * r626774;
        double r626776 = r626772 / r626773;
        double r626777 = r626776 * r626763;
        double r626778 = r626769 ? r626775 : r626777;
        return r626778;
}

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 
(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)))