Average Error: 15.2 → 7.0
Time: 7.4s
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 r432013 = x;
        double r432014 = 2.0;
        double r432015 = r432013 * r432014;
        double r432016 = y;
        double r432017 = r432015 * r432016;
        double r432018 = r432013 - r432016;
        double r432019 = r432017 / r432018;
        return r432019;
}

double f(double x, double y) {
        double r432020 = x;
        double r432021 = 2.0;
        double r432022 = r432020 * r432021;
        double r432023 = y;
        double r432024 = r432020 - r432023;
        double r432025 = r432023 / r432024;
        double r432026 = r432022 * r432025;
        return r432026;
}

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.2
Target0.3
Herbie7.0
\[\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 y < -8.605627297464034e+62 or 1.1280865726302276e-119 < y

    1. Initial program 15.2

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

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

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

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

    if -8.605627297464034e+62 < y < 1.1280865726302276e-119

    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 clear-num15.4

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{x - y}{x} \cdot \frac{\frac{1}{y}}{2}}}\]
    9. Applied add-cube-cbrt0.5

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{x - y}{x}} \cdot \frac{\sqrt[3]{1}}{\frac{\frac{1}{y}}{2}}}\]
    11. Simplified0.4

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

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

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

Reproduce

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