Average Error: 15.3 → 0.3
Time: 7.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.18485405558886704329803739258795392325 \cdot 10^{75} \lor \neg \left(x \le 221068044499626994233760128308481097728\right):\\ \;\;\;\;\frac{x}{x - y} \cdot \left(2 \cdot y\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 -3.18485405558886704329803739258795392325 \cdot 10^{75} \lor \neg \left(x \le 221068044499626994233760128308481097728\right):\\
\;\;\;\;\frac{x}{x - y} \cdot \left(2 \cdot y\right)\\

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

\end{array}
double f(double x, double y) {
        double r403213 = x;
        double r403214 = 2.0;
        double r403215 = r403213 * r403214;
        double r403216 = y;
        double r403217 = r403215 * r403216;
        double r403218 = r403213 - r403216;
        double r403219 = r403217 / r403218;
        return r403219;
}

double f(double x, double y) {
        double r403220 = x;
        double r403221 = -3.184854055588867e+75;
        bool r403222 = r403220 <= r403221;
        double r403223 = 2.21068044499627e+38;
        bool r403224 = r403220 <= r403223;
        double r403225 = !r403224;
        bool r403226 = r403222 || r403225;
        double r403227 = y;
        double r403228 = r403220 - r403227;
        double r403229 = r403220 / r403228;
        double r403230 = 2.0;
        double r403231 = r403230 * r403227;
        double r403232 = r403229 * r403231;
        double r403233 = r403220 * r403230;
        double r403234 = r403228 / r403227;
        double r403235 = r403233 / r403234;
        double r403236 = r403226 ? r403232 : r403235;
        return r403236;
}

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.3
Target0.3
Herbie0.3
\[\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 x < -3.184854055588867e+75 or 2.21068044499627e+38 < x

    1. Initial program 18.4

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

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

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

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

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

    if -3.184854055588867e+75 < x < 2.21068044499627e+38

    1. Initial program 13.1

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

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

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

Reproduce

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