Average Error: 14.7 → 0.5
Time: 2.1s
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 r457307 = x;
        double r457308 = 2.0;
        double r457309 = r457307 * r457308;
        double r457310 = y;
        double r457311 = r457309 * r457310;
        double r457312 = r457307 - r457310;
        double r457313 = r457311 / r457312;
        return r457313;
}

double f(double x, double y) {
        double r457314 = x;
        double r457315 = -2.7432044255292434e+84;
        bool r457316 = r457314 <= r457315;
        double r457317 = 6.454028353291742e+38;
        bool r457318 = r457314 <= r457317;
        double r457319 = !r457318;
        bool r457320 = r457316 || r457319;
        double r457321 = 2.0;
        double r457322 = r457314 * r457321;
        double r457323 = y;
        double r457324 = r457314 - r457323;
        double r457325 = r457322 / r457324;
        double r457326 = r457325 * r457323;
        double r457327 = r457323 / r457324;
        double r457328 = r457322 * r457327;
        double r457329 = r457320 ? r457326 : r457328;
        return r457329;
}

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 
(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)))