Average Error: 14.7 → 1.5
Time: 1.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -5.57636306111153486 \cdot 10^{137} \lor \neg \left(y \le 2.19553327371823438 \cdot 10^{93}\right):\\ \;\;\;\;\frac{x \cdot 2}{\sqrt[3]{{\left(\frac{x}{y} - 1\right)}^{3}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -5.57636306111153486 \cdot 10^{137} \lor \neg \left(y \le 2.19553327371823438 \cdot 10^{93}\right):\\
\;\;\;\;\frac{x \cdot 2}{\sqrt[3]{{\left(\frac{x}{y} - 1\right)}^{3}}}\\

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

\end{array}
double f(double x, double y) {
        double r404940 = x;
        double r404941 = 2.0;
        double r404942 = r404940 * r404941;
        double r404943 = y;
        double r404944 = r404942 * r404943;
        double r404945 = r404940 - r404943;
        double r404946 = r404944 / r404945;
        return r404946;
}

double f(double x, double y) {
        double r404947 = y;
        double r404948 = -5.576363061111535e+137;
        bool r404949 = r404947 <= r404948;
        double r404950 = 2.1955332737182344e+93;
        bool r404951 = r404947 <= r404950;
        double r404952 = !r404951;
        bool r404953 = r404949 || r404952;
        double r404954 = x;
        double r404955 = 2.0;
        double r404956 = r404954 * r404955;
        double r404957 = r404954 / r404947;
        double r404958 = 1.0;
        double r404959 = r404957 - r404958;
        double r404960 = 3.0;
        double r404961 = pow(r404959, r404960);
        double r404962 = cbrt(r404961);
        double r404963 = r404956 / r404962;
        double r404964 = r404954 - r404947;
        double r404965 = r404956 / r404964;
        double r404966 = r404965 * r404947;
        double r404967 = r404953 ? r404963 : r404966;
        return r404967;
}

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.5
\[\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 y < -5.576363061111535e+137 or 2.1955332737182344e+93 < y

    1. Initial program 20.8

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

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

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

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

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

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

    if -5.576363061111535e+137 < y < 2.1955332737182344e+93

    1. Initial program 12.0

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/1.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -5.57636306111153486 \cdot 10^{137} \lor \neg \left(y \le 2.19553327371823438 \cdot 10^{93}\right):\\ \;\;\;\;\frac{x \cdot 2}{\sqrt[3]{{\left(\frac{x}{y} - 1\right)}^{3}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]

Reproduce

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