Average Error: 15.4 → 7.1
Time: 7.4s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\frac{x \cdot 2}{x - y} \cdot y\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\frac{x \cdot 2}{x - y} \cdot y
double f(double x, double y) {
        double r411530 = x;
        double r411531 = 2.0;
        double r411532 = r411530 * r411531;
        double r411533 = y;
        double r411534 = r411532 * r411533;
        double r411535 = r411530 - r411533;
        double r411536 = r411534 / r411535;
        return r411536;
}

double f(double x, double y) {
        double r411537 = x;
        double r411538 = 2.0;
        double r411539 = r411537 * r411538;
        double r411540 = y;
        double r411541 = r411537 - r411540;
        double r411542 = r411539 / r411541;
        double r411543 = r411542 * r411540;
        return r411543;
}

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.4
Target0.3
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 3 regimes
  2. if y < -147574915232717.3

    1. Initial program 17.1

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

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

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

    if -147574915232717.3 < y < 8.418806030437594e+120

    1. Initial program 12.9

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.8

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y}\]

    if 8.418806030437594e+120 < y

    1. Initial program 22.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}}}\]
    4. Using strategy rm
    5. Applied add-cbrt-cube64.0

      \[\leadsto \frac{x \cdot 2}{\frac{x - y}{\color{blue}{\sqrt[3]{\left(y \cdot y\right) \cdot y}}}}\]
    6. Applied add-cbrt-cube64.0

      \[\leadsto \frac{x \cdot 2}{\frac{\color{blue}{\sqrt[3]{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}}}{\sqrt[3]{\left(y \cdot y\right) \cdot y}}}\]
    7. Applied cbrt-undiv64.0

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\sqrt[3]{\frac{\left(\left(x - y\right) \cdot \left(x - y\right)\right) \cdot \left(x - y\right)}{\left(y \cdot y\right) \cdot y}}}}\]
    8. Simplified1.9

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

    \[\leadsto \frac{x \cdot 2}{x - y} \cdot y\]

Reproduce

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