Average Error: 15.3 → 0.6
Time: 13.0s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.471592529896085774661241966279671564936 \cdot 10^{-299} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.814653870831097695138700872366755944978 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{x}{\frac{-1 + \frac{x}{y}}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.471592529896085774661241966279671564936 \cdot 10^{-299} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.814653870831097695138700872366755944978 \cdot 10^{-20}\right):\\
\;\;\;\;\frac{x}{\frac{-1 + \frac{x}{y}}{2}}\\

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

\end{array}
double f(double x, double y) {
        double r350165 = x;
        double r350166 = 2.0;
        double r350167 = r350165 * r350166;
        double r350168 = y;
        double r350169 = r350167 * r350168;
        double r350170 = r350165 - r350168;
        double r350171 = r350169 / r350170;
        return r350171;
}

double f(double x, double y) {
        double r350172 = x;
        double r350173 = 2.0;
        double r350174 = r350172 * r350173;
        double r350175 = y;
        double r350176 = r350174 * r350175;
        double r350177 = r350172 - r350175;
        double r350178 = r350176 / r350177;
        double r350179 = -inf.0;
        bool r350180 = r350178 <= r350179;
        double r350181 = -1.4715925298960858e-299;
        bool r350182 = r350178 <= r350181;
        double r350183 = 0.0;
        bool r350184 = r350178 <= r350183;
        double r350185 = !r350184;
        double r350186 = 1.8146538708310977e-20;
        bool r350187 = r350178 <= r350186;
        bool r350188 = r350185 && r350187;
        bool r350189 = r350182 || r350188;
        double r350190 = !r350189;
        bool r350191 = r350180 || r350190;
        double r350192 = -1.0;
        double r350193 = r350172 / r350175;
        double r350194 = r350192 + r350193;
        double r350195 = r350194 / r350173;
        double r350196 = r350172 / r350195;
        double r350197 = r350191 ? r350196 : r350178;
        return r350197;
}

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.3
Target0.4
Herbie0.6
\[\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 2.0) y) (- x y)) < -inf.0 or -1.4715925298960858e-299 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 1.8146538708310977e-20 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 42.5

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

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

      \[\leadsto \frac{x \cdot 2}{\color{blue}{\frac{x}{y} - 1}}\]
    5. Using strategy rm
    6. Applied associate-/l*0.7

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

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

    if -inf.0 < (/ (* (* x 2.0) y) (- x y)) < -1.4715925298960858e-299 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 1.8146538708310977e-20

    1. Initial program 5.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} = -\infty \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.471592529896085774661241966279671564936 \cdot 10^{-299} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 1.814653870831097695138700872366755944978 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{x}{\frac{-1 + \frac{x}{y}}{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019304 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (if (< x -1.7210442634149447e81) (* (/ (* 2 x) (- x y)) y) (if (< x 83645045635564432) (/ (* x 2) (/ (- x y) y)) (* (/ (* 2 x) (- x y)) y)))

  (/ (* (* x 2) y) (- x y)))