Average Error: 15.0 → 1.9
Time: 31.7s
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}{\frac{x}{y} - 1}\\ \mathbf{elif}\;y \le 3.448485370032302944418093156077181588583 \cdot 10^{-155}:\\ \;\;\;\;\left(2 \cdot y\right) \cdot \sqrt[3]{{\left(\frac{x}{x - y}\right)}^{3}}\\ \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}{\frac{x}{y} - 1}\\

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

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

\end{array}
double f(double x, double y) {
        double r474340 = x;
        double r474341 = 2.0;
        double r474342 = r474340 * r474341;
        double r474343 = y;
        double r474344 = r474342 * r474343;
        double r474345 = r474340 - r474343;
        double r474346 = r474344 / r474345;
        return r474346;
}

double f(double x, double y) {
        double r474347 = y;
        double r474348 = -1.794266843434528e-157;
        bool r474349 = r474347 <= r474348;
        double r474350 = x;
        double r474351 = 2.0;
        double r474352 = r474350 * r474351;
        double r474353 = r474350 / r474347;
        double r474354 = 1.0;
        double r474355 = r474353 - r474354;
        double r474356 = r474352 / r474355;
        double r474357 = 3.448485370032303e-155;
        bool r474358 = r474347 <= r474357;
        double r474359 = r474351 * r474347;
        double r474360 = r474350 - r474347;
        double r474361 = r474350 / r474360;
        double r474362 = 3.0;
        double r474363 = pow(r474361, r474362);
        double r474364 = cbrt(r474363);
        double r474365 = r474359 * r474364;
        double r474366 = r474360 / r474347;
        double r474367 = r474352 / r474366;
        double r474368 = r474358 ? r474365 : r474367;
        double r474369 = r474349 ? r474356 : r474368;
        return r474369;
}

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 *-un-lft-identity2.4

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

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

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

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

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

    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 \color{blue}{1 \cdot \frac{x \cdot 2}{\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}{\frac{x}{y} - 1}\\ \mathbf{elif}\;y \le 3.448485370032302944418093156077181588583 \cdot 10^{-155}:\\ \;\;\;\;\left(2 \cdot y\right) \cdot \sqrt[3]{{\left(\frac{x}{x - y}\right)}^{3}}\\ \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)))