Average Error: 14.7 → 0.5
Time: 10.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.743204425529243396853868243030742880919 \cdot 10^{84} \lor \neg \left(x \le 645402835329174226489839576403337543680\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.743204425529243396853868243030742880919 \cdot 10^{84} \lor \neg \left(x \le 645402835329174226489839576403337543680\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 r237373 = x;
        double r237374 = 2.0;
        double r237375 = r237373 * r237374;
        double r237376 = y;
        double r237377 = r237375 * r237376;
        double r237378 = r237373 - r237376;
        double r237379 = r237377 / r237378;
        return r237379;
}

double f(double x, double y) {
        double r237380 = x;
        double r237381 = -2.7432044255292434e+84;
        bool r237382 = r237380 <= r237381;
        double r237383 = 6.454028353291742e+38;
        bool r237384 = r237380 <= r237383;
        double r237385 = !r237384;
        bool r237386 = r237382 || r237385;
        double r237387 = 2.0;
        double r237388 = r237380 * r237387;
        double r237389 = y;
        double r237390 = r237380 - r237389;
        double r237391 = r237388 / r237390;
        double r237392 = r237391 * r237389;
        double r237393 = r237389 / r237390;
        double r237394 = r237388 * r237393;
        double r237395 = r237386 ? r237392 : r237394;
        return r237395;
}

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.7
Target0.5
Herbie0.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.7432044255292434e+84 or 6.454028353291742e+38 < x

    1. Initial program 18.6

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

      \[\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.7432044255292434e+84 < x < 6.454028353291742e+38

    1. Initial program 12.0

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.743204425529243396853868243030742880919 \cdot 10^{84} \lor \neg \left(x \le 645402835329174226489839576403337543680\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 2019322 +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)))