Average Error: 15.3 → 0.2
Time: 39.5s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.904038736975755 \cdot 10^{40} \lor \neg \left(x \le 2.2748860877863723 \cdot 10^{-47}\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 -7.904038736975755 \cdot 10^{40} \lor \neg \left(x \le 2.2748860877863723 \cdot 10^{-47}\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 r399100 = x;
        double r399101 = 2.0;
        double r399102 = r399100 * r399101;
        double r399103 = y;
        double r399104 = r399102 * r399103;
        double r399105 = r399100 - r399103;
        double r399106 = r399104 / r399105;
        return r399106;
}

double f(double x, double y) {
        double r399107 = x;
        double r399108 = -7.904038736975755e+40;
        bool r399109 = r399107 <= r399108;
        double r399110 = 2.2748860877863723e-47;
        bool r399111 = r399107 <= r399110;
        double r399112 = !r399111;
        bool r399113 = r399109 || r399112;
        double r399114 = 2.0;
        double r399115 = r399107 * r399114;
        double r399116 = y;
        double r399117 = r399107 - r399116;
        double r399118 = r399115 / r399117;
        double r399119 = r399118 * r399116;
        double r399120 = r399116 / r399117;
        double r399121 = r399115 * r399120;
        double r399122 = r399113 ? r399119 : r399121;
        return r399122;
}

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.3
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 < -7.904038736975755e+40 or 2.2748860877863723e-47 < x

    1. Initial program 16.6

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.3

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

    if -7.904038736975755e+40 < x < 2.2748860877863723e-47

    1. Initial program 13.9

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

      \[\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 -7.904038736975755 \cdot 10^{40} \lor \neg \left(x \le 2.2748860877863723 \cdot 10^{-47}\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 2019199 +o rules:numerics
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))