Average Error: 15.2 → 1.5
Time: 6.7s
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 -2.98374479519658591 \cdot 10^{-65} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -8.21511219976497913 \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 6.50597864520907364 \cdot 10^{-82}\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \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 -2.98374479519658591 \cdot 10^{-65} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -8.21511219976497913 \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 6.50597864520907364 \cdot 10^{-82}\right):\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r665371 = x;
        double r665372 = 2.0;
        double r665373 = r665371 * r665372;
        double r665374 = y;
        double r665375 = r665373 * r665374;
        double r665376 = r665371 - r665374;
        double r665377 = r665375 / r665376;
        return r665377;
}

double f(double x, double y) {
        double r665378 = x;
        double r665379 = 2.0;
        double r665380 = r665378 * r665379;
        double r665381 = y;
        double r665382 = r665380 * r665381;
        double r665383 = r665378 - r665381;
        double r665384 = r665382 / r665383;
        double r665385 = -2.983744795196586e-65;
        bool r665386 = r665384 <= r665385;
        double r665387 = -8.215112199764979e-271;
        bool r665388 = r665384 <= r665387;
        double r665389 = 0.0;
        bool r665390 = r665384 <= r665389;
        double r665391 = !r665390;
        double r665392 = 6.505978645209074e-82;
        bool r665393 = r665384 <= r665392;
        bool r665394 = r665391 && r665393;
        bool r665395 = r665388 || r665394;
        double r665396 = !r665395;
        bool r665397 = r665386 || r665396;
        double r665398 = r665381 / r665383;
        double r665399 = r665380 * r665398;
        double r665400 = r665397 ? r665399 : r665384;
        return r665400;
}

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.2
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 (/ (* (* x 2.0) y) (- x y)) < -2.983744795196586e-65 or -8.215112199764979e-271 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 6.505978645209074e-82 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 28.0

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

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

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

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

    if -2.983744795196586e-65 < (/ (* (* x 2.0) y) (- x y)) < -8.215112199764979e-271 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 6.505978645209074e-82

    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 -2.98374479519658591 \cdot 10^{-65} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -8.21511219976497913 \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 6.50597864520907364 \cdot 10^{-82}\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

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