Average Error: 14.9 → 0.2
Time: 1.8s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.316089910188541 \cdot 10^{57} \lor \neg \left(x \le 15954.868549912213\right):\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -2.316089910188541 \cdot 10^{57} \lor \neg \left(x \le 15954.868549912213\right):\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

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

\end{array}
double f(double x, double y) {
        double r298521 = x;
        double r298522 = 2.0;
        double r298523 = r298521 * r298522;
        double r298524 = y;
        double r298525 = r298523 * r298524;
        double r298526 = r298521 - r298524;
        double r298527 = r298525 / r298526;
        return r298527;
}

double f(double x, double y) {
        double r298528 = x;
        double r298529 = -2.3160899101885412e+57;
        bool r298530 = r298528 <= r298529;
        double r298531 = 15954.868549912213;
        bool r298532 = r298528 <= r298531;
        double r298533 = !r298532;
        bool r298534 = r298530 || r298533;
        double r298535 = 2.0;
        double r298536 = r298528 * r298535;
        double r298537 = y;
        double r298538 = r298528 - r298537;
        double r298539 = r298536 / r298538;
        double r298540 = r298539 * r298537;
        double r298541 = r298537 / r298538;
        double r298542 = r298536 * r298541;
        double r298543 = r298534 ? r298540 : r298542;
        return r298543;
}

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.9
Target0.3
Herbie0.2
\[\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.3160899101885412e+57 or 15954.868549912213 < x

    1. Initial program 18.1

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

      \[\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 -2.3160899101885412e+57 < x < 15954.868549912213

    1. Initial program 12.3

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.316089910188541 \cdot 10^{57} \lor \neg \left(x \le 15954.868549912213\right):\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \end{array}\]

Reproduce

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