Average Error: 15.0 → 7.2
Time: 2.6s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\left(x \cdot 2\right) \cdot \frac{y}{x - y}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\left(x \cdot 2\right) \cdot \frac{y}{x - y}
double f(double x, double y) {
        double r403829 = x;
        double r403830 = 2.0;
        double r403831 = r403829 * r403830;
        double r403832 = y;
        double r403833 = r403831 * r403832;
        double r403834 = r403829 - r403832;
        double r403835 = r403833 / r403834;
        return r403835;
}

double f(double x, double y) {
        double r403836 = x;
        double r403837 = 2.0;
        double r403838 = r403836 * r403837;
        double r403839 = y;
        double r403840 = r403836 - r403839;
        double r403841 = r403839 / r403840;
        double r403842 = r403838 * r403841;
        return r403842;
}

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
Herbie7.2
\[\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 3 regimes
  2. if y < -58561655122625.34

    1. Initial program 16.7

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity16.7

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

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

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

    if -58561655122625.34 < y < 9.150412211331254e-133

    1. Initial program 15.6

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

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

      \[\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(y \cdot 2\right)}\]

    if 9.150412211331254e-133 < y

    1. Initial program 13.3

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

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

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\frac{x}{y} - \frac{y}{y}}}\]
    6. Simplified1.7

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

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

Reproduce

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