Average Error: 15.1 → 0.6
Time: 1.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.33189894052977407 \cdot 10^{107} \lor \neg \left(x \le 7.95841056633505603 \cdot 10^{55}\right):\\ \;\;\;\;\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x - y}}\right) \cdot \left(y \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -1.33189894052977407 \cdot 10^{107} \lor \neg \left(x \le 7.95841056633505603 \cdot 10^{55}\right):\\
\;\;\;\;\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x - y}}\right) \cdot \left(y \cdot 2\right)\\

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

\end{array}
double f(double x, double y) {
        double r584089 = x;
        double r584090 = 2.0;
        double r584091 = r584089 * r584090;
        double r584092 = y;
        double r584093 = r584091 * r584092;
        double r584094 = r584089 - r584092;
        double r584095 = r584093 / r584094;
        return r584095;
}

double f(double x, double y) {
        double r584096 = x;
        double r584097 = -1.331898940529774e+107;
        bool r584098 = r584096 <= r584097;
        double r584099 = 7.958410566335056e+55;
        bool r584100 = r584096 <= r584099;
        double r584101 = !r584100;
        bool r584102 = r584098 || r584101;
        double r584103 = cbrt(r584096);
        double r584104 = r584103 * r584103;
        double r584105 = y;
        double r584106 = r584096 - r584105;
        double r584107 = cbrt(r584106);
        double r584108 = r584107 * r584107;
        double r584109 = r584104 / r584108;
        double r584110 = r584103 / r584107;
        double r584111 = r584109 * r584110;
        double r584112 = 2.0;
        double r584113 = r584105 * r584112;
        double r584114 = r584111 * r584113;
        double r584115 = r584096 * r584112;
        double r584116 = r584105 / r584106;
        double r584117 = r584115 * r584116;
        double r584118 = r584102 ? r584114 : r584117;
        return r584118;
}

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.1
Target0.3
Herbie0.6
\[\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 2 regimes
  2. if x < -1.331898940529774e+107 or 7.958410566335056e+55 < x

    1. Initial program 20.9

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

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

      \[\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)}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt1.3

      \[\leadsto \frac{x}{\color{blue}{\left(\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}\right) \cdot \sqrt[3]{x - y}}} \cdot \left(y \cdot 2\right)\]
    10. Applied add-cube-cbrt0.4

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

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

    if -1.331898940529774e+107 < x < 7.958410566335056e+55

    1. Initial program 11.8

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

      \[\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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.33189894052977407 \cdot 10^{107} \lor \neg \left(x \le 7.95841056633505603 \cdot 10^{55}\right):\\ \;\;\;\;\left(\frac{\sqrt[3]{x} \cdot \sqrt[3]{x}}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\sqrt[3]{x}}{\sqrt[3]{x - y}}\right) \cdot \left(y \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \end{array}\]

Reproduce

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