Average Error: 15.0 → 0.3
Time: 13.1s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -8.65788639203602374867804606149070922026 \cdot 10^{89}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{elif}\;x \le 0.03126096436082478891016478428355185315013:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \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}\;x \le -8.65788639203602374867804606149070922026 \cdot 10^{89}:\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

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

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

\end{array}
double f(double x, double y) {
        double r73973034 = x;
        double r73973035 = 2.0;
        double r73973036 = r73973034 * r73973035;
        double r73973037 = y;
        double r73973038 = r73973036 * r73973037;
        double r73973039 = r73973034 - r73973037;
        double r73973040 = r73973038 / r73973039;
        return r73973040;
}

double f(double x, double y) {
        double r73973041 = x;
        double r73973042 = -8.657886392036024e+89;
        bool r73973043 = r73973041 <= r73973042;
        double r73973044 = 2.0;
        double r73973045 = r73973041 * r73973044;
        double r73973046 = y;
        double r73973047 = r73973041 - r73973046;
        double r73973048 = r73973045 / r73973047;
        double r73973049 = r73973048 * r73973046;
        double r73973050 = 0.03126096436082479;
        bool r73973051 = r73973041 <= r73973050;
        double r73973052 = r73973046 / r73973047;
        double r73973053 = r73973045 * r73973052;
        double r73973054 = r73973051 ? r73973053 : r73973049;
        double r73973055 = r73973043 ? r73973049 : r73973054;
        return r73973055;
}

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
Herbie0.3
\[\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 < -8.657886392036024e+89 or 0.03126096436082479 < x

    1. Initial program 17.9

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

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

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

    if -8.657886392036024e+89 < x < 0.03126096436082479

    1. Initial program 12.7

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

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

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

      \[\leadsto \color{blue}{\left(x \cdot 2\right)} \cdot \frac{y}{x - y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -8.65788639203602374867804606149070922026 \cdot 10^{89}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{elif}\;x \le 0.03126096436082478891016478428355185315013:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2019173 +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)))