Average Error: 15.1 → 0.1
Time: 2.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -163097.3914422508678399026393890380859375 \lor \neg \left(y \le 8.194716042463525833527836867452398528298 \cdot 10^{-21}\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 -163097.3914422508678399026393890380859375 \lor \neg \left(y \le 8.194716042463525833527836867452398528298 \cdot 10^{-21}\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 r653414 = x;
        double r653415 = 2.0;
        double r653416 = r653414 * r653415;
        double r653417 = y;
        double r653418 = r653416 * r653417;
        double r653419 = r653414 - r653417;
        double r653420 = r653418 / r653419;
        return r653420;
}

double f(double x, double y) {
        double r653421 = y;
        double r653422 = -163097.39144225087;
        bool r653423 = r653421 <= r653422;
        double r653424 = 8.194716042463526e-21;
        bool r653425 = r653421 <= r653424;
        double r653426 = !r653425;
        bool r653427 = r653423 || r653426;
        double r653428 = x;
        double r653429 = 2.0;
        double r653430 = r653428 * r653429;
        double r653431 = r653428 - r653421;
        double r653432 = r653421 / r653431;
        double r653433 = r653430 * r653432;
        double r653434 = r653430 / r653431;
        double r653435 = r653434 * r653421;
        double r653436 = r653427 ? r653433 : r653435;
        return r653436;
}

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.1
Target0.4
Herbie0.1
\[\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 y < -163097.39144225087 or 8.194716042463526e-21 < y

    1. Initial program 16.5

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

      \[\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 -163097.39144225087 < y < 8.194716042463526e-21

    1. Initial program 13.7

      \[\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.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 -163097.3914422508678399026393890380859375 \lor \neg \left(y \le 8.194716042463525833527836867452398528298 \cdot 10^{-21}\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 2019353 
(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)))