Average Error: 14.9 → 1.1
Time: 4.3s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -6.819752026637393519506049512320603510099 \cdot 10^{-42}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;y \le 3.147408210159048214381836933498385687136 \cdot 10^{-101}:\\ \;\;\;\;\left(\frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}}\right) \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\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}\;y \le -6.819752026637393519506049512320603510099 \cdot 10^{-42}:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

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

\end{array}
double f(double x, double y) {
        double r688356 = x;
        double r688357 = 2.0;
        double r688358 = r688356 * r688357;
        double r688359 = y;
        double r688360 = r688358 * r688359;
        double r688361 = r688356 - r688359;
        double r688362 = r688360 / r688361;
        return r688362;
}

double f(double x, double y) {
        double r688363 = y;
        double r688364 = -6.819752026637394e-42;
        bool r688365 = r688363 <= r688364;
        double r688366 = x;
        double r688367 = 2.0;
        double r688368 = r688366 * r688367;
        double r688369 = r688366 - r688363;
        double r688370 = r688363 / r688369;
        double r688371 = r688368 * r688370;
        double r688372 = 3.147408210159048e-101;
        bool r688373 = r688363 <= r688372;
        double r688374 = cbrt(r688369);
        double r688375 = r688374 * r688374;
        double r688376 = r688368 / r688375;
        double r688377 = cbrt(r688363);
        double r688378 = r688377 * r688377;
        double r688379 = cbrt(r688375);
        double r688380 = r688378 / r688379;
        double r688381 = r688376 * r688380;
        double r688382 = cbrt(r688374);
        double r688383 = r688377 / r688382;
        double r688384 = r688381 * r688383;
        double r688385 = r688369 / r688363;
        double r688386 = r688368 / r688385;
        double r688387 = r688373 ? r688384 : r688386;
        double r688388 = r688365 ? r688371 : r688387;
        return r688388;
}

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.9
Target0.3
Herbie1.1
\[\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 < -6.819752026637394e-42

    1. Initial program 13.8

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

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

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

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

    if -6.819752026637394e-42 < y < 3.147408210159048e-101

    1. Initial program 17.5

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt18.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.8

      \[\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.9

      \[\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-prod7.0

      \[\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 add-cube-cbrt7.0

      \[\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}}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \sqrt[3]{\sqrt[3]{x - y}}}\]
    9. Applied times-frac7.0

      \[\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}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}} \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{x - y}}}\right)}\]
    10. Applied associate-*r*1.8

      \[\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}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}}\right) \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{x - y}}}}\]

    if 3.147408210159048e-101 < y

    1. Initial program 12.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -6.819752026637393519506049512320603510099 \cdot 10^{-42}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{elif}\;y \le 3.147408210159048214381836933498385687136 \cdot 10^{-101}:\\ \;\;\;\;\left(\frac{x \cdot 2}{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}} \cdot \frac{\sqrt[3]{y} \cdot \sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{x - y} \cdot \sqrt[3]{x - y}}}\right) \cdot \frac{\sqrt[3]{y}}{\sqrt[3]{\sqrt[3]{x - y}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

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