Average Error: 14.7 → 6.8
Time: 4.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\frac{x}{x - y} \cdot \left(y \cdot 2\right)\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\frac{x}{x - y} \cdot \left(y \cdot 2\right)
double f(double x, double y) {
        double r341170 = x;
        double r341171 = 2.0;
        double r341172 = r341170 * r341171;
        double r341173 = y;
        double r341174 = r341172 * r341173;
        double r341175 = r341170 - r341173;
        double r341176 = r341174 / r341175;
        return r341176;
}

double f(double x, double y) {
        double r341177 = x;
        double r341178 = y;
        double r341179 = r341177 - r341178;
        double r341180 = r341177 / r341179;
        double r341181 = 2.0;
        double r341182 = r341178 * r341181;
        double r341183 = r341180 * r341182;
        return r341183;
}

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.7
Target0.3
Herbie6.8
\[\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 < -1037.4860351195955 or 2.7844692506363857e-21 < x

    1. Initial program 15.2

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

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

      \[\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.1

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

    if -1037.4860351195955 < x < 2.7844692506363857e-21

    1. Initial program 14.3

      \[\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 simplification6.8

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

Reproduce

herbie shell --seed 2019291 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

  (/ (* (* x 2) y) (- x y)))