Average Error: 14.4 → 1.1
Time: 4.1s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -2.509016255470818 \cdot 10^{-23}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -2.14150251518745915 \cdot 10^{-306}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 9.93900771339059028 \cdot 10^{-129}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{x - y}}\\ \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}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -2.509016255470818 \cdot 10^{-23}:\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -2.14150251518745915 \cdot 10^{-306}:\\
\;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\

\mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

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

\end{array}
double f(double x, double y) {
        double r569644 = x;
        double r569645 = 2.0;
        double r569646 = r569644 * r569645;
        double r569647 = y;
        double r569648 = r569646 * r569647;
        double r569649 = r569644 - r569647;
        double r569650 = r569648 / r569649;
        return r569650;
}

double f(double x, double y) {
        double r569651 = x;
        double r569652 = 2.0;
        double r569653 = r569651 * r569652;
        double r569654 = y;
        double r569655 = r569653 * r569654;
        double r569656 = r569651 - r569654;
        double r569657 = r569655 / r569656;
        double r569658 = -2.509016255470818e-23;
        bool r569659 = r569657 <= r569658;
        double r569660 = r569656 / r569654;
        double r569661 = r569653 / r569660;
        double r569662 = -2.141502515187459e-306;
        bool r569663 = r569657 <= r569662;
        double r569664 = 0.0;
        bool r569665 = r569657 <= r569664;
        double r569666 = r569654 / r569656;
        double r569667 = r569653 * r569666;
        double r569668 = 9.93900771339059e-129;
        bool r569669 = r569657 <= r569668;
        double r569670 = cbrt(r569654);
        double r569671 = r569670 * r569670;
        double r569672 = r569653 * r569671;
        double r569673 = cbrt(r569656);
        double r569674 = r569673 * r569673;
        double r569675 = r569672 / r569674;
        double r569676 = r569670 / r569673;
        double r569677 = r569675 * r569676;
        double r569678 = r569669 ? r569677 : r569661;
        double r569679 = r569665 ? r569667 : r569678;
        double r569680 = r569663 ? r569657 : r569679;
        double r569681 = r569659 ? r569661 : r569680;
        return r569681;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.4
Target0.3
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \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 4 regimes
  2. if (/ (* (* x 2.0) y) (- x y)) < -2.509016255470818e-23 or 9.93900771339059e-129 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 19.9

      \[\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}}}\]

    if -2.509016255470818e-23 < (/ (* (* x 2.0) y) (- x y)) < -2.141502515187459e-306

    1. Initial program 0.7

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

    if -2.141502515187459e-306 < (/ (* (* x 2.0) y) (- x y)) < 0.0

    1. Initial program 57.5

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

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

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

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

    if 0.0 < (/ (* (* x 2.0) y) (- x y)) < 9.93900771339059e-129

    1. Initial program 13.0

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right)} \cdot \frac{y}{x - y}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt13.2

      \[\leadsto \left(x \cdot 2\right) \cdot \frac{y}{\color{blue}{\left(\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}\right) \cdot \sqrt[3]{x - y}}}\]
    8. Applied *-un-lft-identity13.2

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

      \[\leadsto \left(x \cdot 2\right) \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{y}{\sqrt[3]{x - y}}\right)}\]
    10. Applied associate-*r*14.5

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}} \cdot \frac{y}{\sqrt[3]{x - y}}\]
    12. Using strategy rm
    13. Applied *-un-lft-identity14.5

      \[\leadsto \frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{y}{\color{blue}{1 \cdot \sqrt[3]{x - y}}}\]
    14. Applied add-cube-cbrt14.3

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

      \[\leadsto \frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \color{blue}{\left(\frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{1} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{x - y}}\right)}\]
    16. Applied associate-*r*10.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -2.509016255470818 \cdot 10^{-23}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -2.14150251518745915 \cdot 10^{-306}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 9.93900771339059028 \cdot 10^{-129}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot \left(\sqrt[3]{y} \cdot \sqrt[3]{y}\right)}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{x - y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

  (/ (* (* x 2) y) (- x y)))