Average Error: 14.2 → 0.8
Time: 8.7s
Precision: 64
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -57238629659.918236:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.0217193971332764 \cdot 10^{-140}:\\ \;\;\;\;\frac{2.0 \cdot x}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array}\]
\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -57238629659.918236:\\
\;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\

\mathbf{elif}\;x \le 1.0217193971332764 \cdot 10^{-140}:\\
\;\;\;\;\frac{2.0 \cdot x}{\frac{x - y}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r27226383 = x;
        double r27226384 = 2.0;
        double r27226385 = r27226383 * r27226384;
        double r27226386 = y;
        double r27226387 = r27226385 * r27226386;
        double r27226388 = r27226383 - r27226386;
        double r27226389 = r27226387 / r27226388;
        return r27226389;
}

double f(double x, double y) {
        double r27226390 = x;
        double r27226391 = -57238629659.918236;
        bool r27226392 = r27226390 <= r27226391;
        double r27226393 = 2.0;
        double r27226394 = r27226393 * r27226390;
        double r27226395 = y;
        double r27226396 = r27226390 - r27226395;
        double r27226397 = r27226394 / r27226396;
        double r27226398 = r27226397 * r27226395;
        double r27226399 = 1.0217193971332764e-140;
        bool r27226400 = r27226390 <= r27226399;
        double r27226401 = r27226396 / r27226395;
        double r27226402 = r27226394 / r27226401;
        double r27226403 = r27226400 ? r27226402 : r27226398;
        double r27226404 = r27226392 ? r27226398 : r27226403;
        return r27226404;
}

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.2
Target0.4
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \cdot 10^{+81}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \lt 8.364504563556443 \cdot 10^{+16}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -57238629659.918236 or 1.0217193971332764e-140 < x

    1. Initial program 13.3

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

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

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

    if -57238629659.918236 < x < 1.0217193971332764e-140

    1. Initial program 15.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -57238629659.918236:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \le 1.0217193971332764 \cdot 10^{-140}:\\ \;\;\;\;\frac{2.0 \cdot x}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array}\]

Reproduce

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