Average Error: 15.0 → 1.9
Time: 35.2s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.794266843434528135733297660501734721002 \cdot 10^{-157}:\\ \;\;\;\;\frac{-x \cdot 2}{\left(-\frac{x}{y}\right) + 1}\\ \mathbf{elif}\;y \le 3.448485370032302944418093156077181588583 \cdot 10^{-155}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x}{x - y}\right)}^{3}} \cdot \left(2 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -1.794266843434528135733297660501734721002 \cdot 10^{-157}:\\
\;\;\;\;\frac{-x \cdot 2}{\left(-\frac{x}{y}\right) + 1}\\

\mathbf{elif}\;y \le 3.448485370032302944418093156077181588583 \cdot 10^{-155}:\\
\;\;\;\;\sqrt[3]{{\left(\frac{x}{x - y}\right)}^{3}} \cdot \left(2 \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

\end{array}
double f(double x, double y) {
        double r428514 = x;
        double r428515 = 2.0;
        double r428516 = r428514 * r428515;
        double r428517 = y;
        double r428518 = r428516 * r428517;
        double r428519 = r428514 - r428517;
        double r428520 = r428518 / r428519;
        return r428520;
}

double f(double x, double y) {
        double r428521 = y;
        double r428522 = -1.794266843434528e-157;
        bool r428523 = r428521 <= r428522;
        double r428524 = x;
        double r428525 = 2.0;
        double r428526 = r428524 * r428525;
        double r428527 = -r428526;
        double r428528 = r428524 / r428521;
        double r428529 = -r428528;
        double r428530 = 1.0;
        double r428531 = r428529 + r428530;
        double r428532 = r428527 / r428531;
        double r428533 = 3.448485370032303e-155;
        bool r428534 = r428521 <= r428533;
        double r428535 = r428524 - r428521;
        double r428536 = r428524 / r428535;
        double r428537 = 3.0;
        double r428538 = pow(r428536, r428537);
        double r428539 = cbrt(r428538);
        double r428540 = r428525 * r428521;
        double r428541 = r428539 * r428540;
        double r428542 = r428535 / r428521;
        double r428543 = r428526 / r428542;
        double r428544 = r428534 ? r428541 : r428543;
        double r428545 = r428523 ? r428532 : r428544;
        return r428545;
}

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
Herbie1.9
\[\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 < -1.794266843434528e-157

    1. Initial program 13.4

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Simplified2.4

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

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

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

    if -1.794266843434528e-157 < y < 3.448485370032303e-155

    1. Initial program 21.1

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Simplified22.8

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

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

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

      \[\leadsto \frac{x}{x - y} \cdot \color{blue}{\left(2 \cdot y\right)}\]
    7. Using strategy rm
    8. Applied add-cbrt-cube41.1

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

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

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

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

    if 3.448485370032303e-155 < y

    1. Initial program 12.6

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Simplified2.3

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity2.3

      \[\leadsto \frac{x \cdot 2}{\frac{x - y}{\color{blue}{1 \cdot y}}}\]
    5. Applied *-un-lft-identity2.3

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

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\frac{1}{1} \cdot \frac{x - y}{y}}}\]
    7. Applied associate-/r*2.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.794266843434528135733297660501734721002 \cdot 10^{-157}:\\ \;\;\;\;\frac{-x \cdot 2}{\left(-\frac{x}{y}\right) + 1}\\ \mathbf{elif}\;y \le 3.448485370032302944418093156077181588583 \cdot 10^{-155}:\\ \;\;\;\;\sqrt[3]{{\left(\frac{x}{x - y}\right)}^{3}} \cdot \left(2 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))