Average Error: 14.7 → 1.4
Time: 34.8s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.182159587378012480642358586488428991674 \cdot 10^{70} \lor \neg \left(x \le 6.512387421164835240080292418646396765453 \cdot 10^{90}\right):\\ \;\;\;\;\frac{\frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}} \cdot \frac{y}{\sqrt[3]{\sqrt[3]{x - y}}}\\ \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.182159587378012480642358586488428991674 \cdot 10^{70} \lor \neg \left(x \le 6.512387421164835240080292418646396765453 \cdot 10^{90}\right):\\
\;\;\;\;\frac{\frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}} \cdot \frac{y}{\sqrt[3]{\sqrt[3]{x - y}}}\\

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

\end{array}
double f(double x, double y) {
        double r467458 = x;
        double r467459 = 2.0;
        double r467460 = r467458 * r467459;
        double r467461 = y;
        double r467462 = r467460 * r467461;
        double r467463 = r467458 - r467461;
        double r467464 = r467462 / r467463;
        return r467464;
}

double f(double x, double y) {
        double r467465 = x;
        double r467466 = -1.1821595873780125e+70;
        bool r467467 = r467465 <= r467466;
        double r467468 = 6.512387421164835e+90;
        bool r467469 = r467465 <= r467468;
        double r467470 = !r467469;
        bool r467471 = r467467 || r467470;
        double r467472 = 2.0;
        double r467473 = r467465 * r467472;
        double r467474 = y;
        double r467475 = r467465 - r467474;
        double r467476 = cbrt(r467475);
        double r467477 = r467476 * r467476;
        double r467478 = r467473 / r467477;
        double r467479 = cbrt(r467477);
        double r467480 = r467478 / r467479;
        double r467481 = cbrt(r467476);
        double r467482 = r467474 / r467481;
        double r467483 = r467480 * r467482;
        double r467484 = r467474 / r467475;
        double r467485 = r467473 * r467484;
        double r467486 = r467471 ? r467483 : r467485;
        return r467486;
}

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.7
Target0.3
Herbie1.4
\[\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 x < -1.1821595873780125e+70 or 6.512387421164835e+90 < x

    1. Initial program 20.6

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt21.4

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{y}{\sqrt[3]{x - y}}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt6.7

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

      \[\leadsto \frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{y}{\color{blue}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \sqrt[3]{\sqrt[3]{x - y}}}}\]
    8. Applied *-un-lft-identity6.8

      \[\leadsto \frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\color{blue}{1 \cdot y}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \sqrt[3]{\sqrt[3]{x - y}}}\]
    9. Applied times-frac6.8

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

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

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

    if -1.1821595873780125e+70 < x < 6.512387421164835e+90

    1. Initial program 11.3

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

      \[\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 simplification1.4

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

Reproduce

herbie shell --seed 2019208 +o rules:numerics
(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)))