Average Error: 15.0 → 0.6
Time: 1.6s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.47596719439230232 \cdot 10^{122} \lor \neg \left(x \le 67448507228.817856\right):\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \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.47596719439230232 \cdot 10^{122} \lor \neg \left(x \le 67448507228.817856\right):\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

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

\end{array}
double f(double x, double y) {
        double r531035 = x;
        double r531036 = 2.0;
        double r531037 = r531035 * r531036;
        double r531038 = y;
        double r531039 = r531037 * r531038;
        double r531040 = r531035 - r531038;
        double r531041 = r531039 / r531040;
        return r531041;
}

double f(double x, double y) {
        double r531042 = x;
        double r531043 = -3.475967194392302e+122;
        bool r531044 = r531042 <= r531043;
        double r531045 = 67448507228.817856;
        bool r531046 = r531042 <= r531045;
        double r531047 = !r531046;
        bool r531048 = r531044 || r531047;
        double r531049 = 2.0;
        double r531050 = r531042 * r531049;
        double r531051 = y;
        double r531052 = r531042 - r531051;
        double r531053 = r531050 / r531052;
        double r531054 = r531053 * r531051;
        double r531055 = r531052 / r531051;
        double r531056 = r531050 / r531055;
        double r531057 = r531048 ? r531054 : r531056;
        return r531057;
}

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.0
Target0.3
Herbie0.6
\[\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 < -3.475967194392302e+122 or 67448507228.817856 < x

    1. Initial program 19.2

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

      \[\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}\]

    if -3.475967194392302e+122 < x < 67448507228.817856

    1. Initial program 12.3

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

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

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

Reproduce

herbie shell --seed 2020021 
(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)))