Average Error: 14.5 → 0.2
Time: 25.0s
Precision: 64
\[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -6.866893468999323 \cdot 10^{-09}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \mathbf{elif}\;y \le 4.4252920350929445 \cdot 10^{-52}:\\ \;\;\;\;\frac{y}{\frac{x - y}{x \cdot 2.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \end{array}\]
\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -6.866893468999323 \cdot 10^{-09}:\\
\;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\

\mathbf{elif}\;y \le 4.4252920350929445 \cdot 10^{-52}:\\
\;\;\;\;\frac{y}{\frac{x - y}{x \cdot 2.0}}\\

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

\end{array}
double f(double x, double y) {
        double r36985157 = x;
        double r36985158 = 2.0;
        double r36985159 = r36985157 * r36985158;
        double r36985160 = y;
        double r36985161 = r36985159 * r36985160;
        double r36985162 = r36985157 - r36985160;
        double r36985163 = r36985161 / r36985162;
        return r36985163;
}

double f(double x, double y) {
        double r36985164 = y;
        double r36985165 = -6.866893468999323e-09;
        bool r36985166 = r36985164 <= r36985165;
        double r36985167 = x;
        double r36985168 = 2.0;
        double r36985169 = r36985167 * r36985168;
        double r36985170 = r36985167 - r36985164;
        double r36985171 = r36985170 / r36985164;
        double r36985172 = r36985169 / r36985171;
        double r36985173 = 4.4252920350929445e-52;
        bool r36985174 = r36985164 <= r36985173;
        double r36985175 = r36985170 / r36985169;
        double r36985176 = r36985164 / r36985175;
        double r36985177 = r36985174 ? r36985176 : r36985172;
        double r36985178 = r36985166 ? r36985172 : r36985177;
        return r36985178;
}

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.5
Target0.4
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt -1.7210442634149447 \cdot 10^{+81}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \mathbf{elif}\;x \lt 8.364504563556443 \cdot 10^{+16}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{2.0 \cdot x}{x - y} \cdot y\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -6.866893468999323e-09 or 4.4252920350929445e-52 < y

    1. Initial program 13.6

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

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

    if -6.866893468999323e-09 < y < 4.4252920350929445e-52

    1. Initial program 15.5

      \[\frac{\left(x \cdot 2.0\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied *-commutative15.5

      \[\leadsto \frac{\color{blue}{y \cdot \left(x \cdot 2.0\right)}}{x - y}\]
    4. Applied associate-/l*0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -6.866893468999323 \cdot 10^{-09}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \mathbf{elif}\;y \le 4.4252920350929445 \cdot 10^{-52}:\\ \;\;\;\;\frac{y}{\frac{x - y}{x \cdot 2.0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2.0}{\frac{x - y}{y}}\\ \end{array}\]

Reproduce

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