Average Error: 15.0 → 2.0
Time: 32.4s
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}:\\ \;\;\;\;y \cdot \sqrt[3]{{\left(\frac{x \cdot 2}{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}:\\
\;\;\;\;y \cdot \sqrt[3]{{\left(\frac{x \cdot 2}{x - y}\right)}^{3}}\\

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

\end{array}
double f(double x, double y) {
        double r414624 = x;
        double r414625 = 2.0;
        double r414626 = r414624 * r414625;
        double r414627 = y;
        double r414628 = r414626 * r414627;
        double r414629 = r414624 - r414627;
        double r414630 = r414628 / r414629;
        return r414630;
}

double f(double x, double y) {
        double r414631 = y;
        double r414632 = -1.794266843434528e-157;
        bool r414633 = r414631 <= r414632;
        double r414634 = x;
        double r414635 = 2.0;
        double r414636 = r414634 * r414635;
        double r414637 = r414634 / r414631;
        double r414638 = 1.0;
        double r414639 = r414637 - r414638;
        double r414640 = r414636 / r414639;
        double r414641 = 3.448485370032303e-155;
        bool r414642 = r414631 <= r414641;
        double r414643 = r414634 - r414631;
        double r414644 = r414636 / r414643;
        double r414645 = 3.0;
        double r414646 = pow(r414644, r414645);
        double r414647 = cbrt(r414646);
        double r414648 = r414631 * r414647;
        double r414649 = r414643 / r414631;
        double r414650 = r414636 / r414649;
        double r414651 = r414642 ? r414648 : r414650;
        double r414652 = r414633 ? r414640 : r414651;
        return r414652;
}

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
Herbie2.0
\[\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 associate-/r/0.1

      \[\leadsto \color{blue}{\frac{x \cdot 2}{x - y} \cdot y}\]
    5. Using strategy rm
    6. Applied add-cbrt-cube41.1

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

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

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

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

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

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

    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. Recombined 3 regimes into one program.
  4. Final simplification2.0

    \[\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}:\\ \;\;\;\;y \cdot \sqrt[3]{{\left(\frac{x \cdot 2}{x - y}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

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