Average Error: 15.3 → 7.1
Time: 3.2s
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 r319100 = x;
        double r319101 = 2.0;
        double r319102 = r319100 * r319101;
        double r319103 = y;
        double r319104 = r319102 * r319103;
        double r319105 = r319100 - r319103;
        double r319106 = r319104 / r319105;
        return r319106;
}

double f(double x, double y) {
        double r319107 = x;
        double r319108 = y;
        double r319109 = r319107 - r319108;
        double r319110 = r319107 / r319109;
        double r319111 = 2.0;
        double r319112 = r319108 * r319111;
        double r319113 = r319110 * r319112;
        return r319113;
}

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.4
Herbie7.1
\[\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 < -9.265176501060394e-08 or 1.3808383341677658e+61 < x

    1. Initial program 17.4

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

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

      \[\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 -9.265176501060394e-08 < x < 1.3808383341677658e+61

    1. Initial program 13.5

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

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

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

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

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

Reproduce

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