Average Error: 15.1 → 0.2
Time: 1.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.73735157607842638 \cdot 10^{-55} \lor \neg \left(x \le 2.31015467420133914 \cdot 10^{-42}\right):\\ \;\;\;\;\frac{x}{x - y} \cdot \left(y \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -1.73735157607842638 \cdot 10^{-55} \lor \neg \left(x \le 2.31015467420133914 \cdot 10^{-42}\right):\\
\;\;\;\;\frac{x}{x - y} \cdot \left(y \cdot 2\right)\\

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

\end{array}
double f(double x, double y) {
        double r487359 = x;
        double r487360 = 2.0;
        double r487361 = r487359 * r487360;
        double r487362 = y;
        double r487363 = r487361 * r487362;
        double r487364 = r487359 - r487362;
        double r487365 = r487363 / r487364;
        return r487365;
}

double f(double x, double y) {
        double r487366 = x;
        double r487367 = -1.7373515760784264e-55;
        bool r487368 = r487366 <= r487367;
        double r487369 = 2.310154674201339e-42;
        bool r487370 = r487366 <= r487369;
        double r487371 = !r487370;
        bool r487372 = r487368 || r487371;
        double r487373 = y;
        double r487374 = r487366 - r487373;
        double r487375 = r487366 / r487374;
        double r487376 = 2.0;
        double r487377 = r487373 * r487376;
        double r487378 = r487375 * r487377;
        double r487379 = r487366 * r487376;
        double r487380 = r487374 / r487373;
        double r487381 = r487379 / r487380;
        double r487382 = r487372 ? r487378 : r487381;
        return r487382;
}

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.2
\[\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 x < -1.7373515760784264e-55 or 2.310154674201339e-42 < x

    1. Initial program 13.7

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied div-inv13.4

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

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

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

    if -1.7373515760784264e-55 < x < 2.310154674201339e-42

    1. Initial program 17.0

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

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

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

Reproduce

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