Average Error: 15.0 → 1.5
Time: 8.8s
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} \le -0.4527420254204213012627633361262269318104 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.779655353381883178736011791448591400102 \cdot 10^{-271} \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.787120037860517149775453907563027869265 \cdot 10^{-96}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \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} \le -0.4527420254204213012627633361262269318104 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.779655353381883178736011791448591400102 \cdot 10^{-271} \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.787120037860517149775453907563027869265 \cdot 10^{-96}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\

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

\end{array}
double f(double x, double y) {
        double r361176 = x;
        double r361177 = 2.0;
        double r361178 = r361176 * r361177;
        double r361179 = y;
        double r361180 = r361178 * r361179;
        double r361181 = r361176 - r361179;
        double r361182 = r361180 / r361181;
        return r361182;
}

double f(double x, double y) {
        double r361183 = x;
        double r361184 = 2.0;
        double r361185 = r361183 * r361184;
        double r361186 = y;
        double r361187 = r361185 * r361186;
        double r361188 = r361183 - r361186;
        double r361189 = r361187 / r361188;
        double r361190 = -0.4527420254204213;
        bool r361191 = r361189 <= r361190;
        double r361192 = -1.7796553533818832e-271;
        bool r361193 = r361189 <= r361192;
        double r361194 = -0.0;
        bool r361195 = r361189 <= r361194;
        double r361196 = !r361195;
        double r361197 = 1.7871200378605171e-96;
        bool r361198 = r361189 <= r361197;
        bool r361199 = r361196 && r361198;
        bool r361200 = r361193 || r361199;
        double r361201 = !r361200;
        bool r361202 = r361191 || r361201;
        double r361203 = r361183 / r361186;
        double r361204 = 1.0;
        double r361205 = r361203 - r361204;
        double r361206 = r361185 / r361205;
        double r361207 = r361202 ? r361206 : r361189;
        return r361207;
}

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
Herbie1.5
\[\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)) < -0.4527420254204213 or -1.7796553533818832e-271 < (/ (* (* x 2.0) y) (- x y)) < -0.0 or 1.7871200378605171e-96 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 30.1

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

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

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

    if -0.4527420254204213 < (/ (* (* x 2.0) y) (- x y)) < -1.7796553533818832e-271 or -0.0 < (/ (* (* x 2.0) y) (- x y)) < 1.7871200378605171e-96

    1. Initial program 0.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -0.4527420254204213012627633361262269318104 \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -1.779655353381883178736011791448591400102 \cdot 10^{-271} \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.787120037860517149775453907563027869265 \cdot 10^{-96}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

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