Average Error: 15.1 → 0.2
Time: 1.6s
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 r497222 = x;
        double r497223 = 2.0;
        double r497224 = r497222 * r497223;
        double r497225 = y;
        double r497226 = r497224 * r497225;
        double r497227 = r497222 - r497225;
        double r497228 = r497226 / r497227;
        return r497228;
}

double f(double x, double y) {
        double r497229 = x;
        double r497230 = -1.7373515760784264e-55;
        bool r497231 = r497229 <= r497230;
        double r497232 = 2.310154674201339e-42;
        bool r497233 = r497229 <= r497232;
        double r497234 = !r497233;
        bool r497235 = r497231 || r497234;
        double r497236 = y;
        double r497237 = r497229 - r497236;
        double r497238 = r497229 / r497237;
        double r497239 = 2.0;
        double r497240 = r497236 * r497239;
        double r497241 = r497238 * r497240;
        double r497242 = r497229 * r497239;
        double r497243 = r497237 / r497236;
        double r497244 = r497242 / r497243;
        double r497245 = r497235 ? r497241 : r497244;
        return r497245;
}

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