Average Error: 14.9 → 0.1
Time: 27.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -37872562220022.53125:\\ \;\;\;\;2 \cdot \left(\frac{y}{x - y} \cdot x\right)\\ \mathbf{elif}\;y \le 1032537.977745023905299603939056396484375:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\frac{y}{x - y} \cdot x\right)\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -37872562220022.53125:\\
\;\;\;\;2 \cdot \left(\frac{y}{x - y} \cdot x\right)\\

\mathbf{elif}\;y \le 1032537.977745023905299603939056396484375:\\
\;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\

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

\end{array}
double f(double x, double y) {
        double r21299249 = x;
        double r21299250 = 2.0;
        double r21299251 = r21299249 * r21299250;
        double r21299252 = y;
        double r21299253 = r21299251 * r21299252;
        double r21299254 = r21299249 - r21299252;
        double r21299255 = r21299253 / r21299254;
        return r21299255;
}

double f(double x, double y) {
        double r21299256 = y;
        double r21299257 = -37872562220022.53;
        bool r21299258 = r21299256 <= r21299257;
        double r21299259 = 2.0;
        double r21299260 = x;
        double r21299261 = r21299260 - r21299256;
        double r21299262 = r21299256 / r21299261;
        double r21299263 = r21299262 * r21299260;
        double r21299264 = r21299259 * r21299263;
        double r21299265 = 1032537.9777450239;
        bool r21299266 = r21299256 <= r21299265;
        double r21299267 = r21299259 * r21299260;
        double r21299268 = r21299267 / r21299261;
        double r21299269 = r21299268 * r21299256;
        double r21299270 = r21299266 ? r21299269 : r21299264;
        double r21299271 = r21299258 ? r21299264 : r21299270;
        return r21299271;
}

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.4
Herbie0.1
\[\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 y < -37872562220022.53 or 1032537.9777450239 < y

    1. Initial program 16.8

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

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

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

      \[\leadsto \color{blue}{\left(2 \cdot x\right)} \cdot \frac{y}{x - y}\]
    6. Using strategy rm
    7. Applied associate-*l*0.0

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

    if -37872562220022.53 < y < 1032537.9777450239

    1. Initial program 13.0

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

      \[\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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -37872562220022.53125:\\ \;\;\;\;2 \cdot \left(\frac{y}{x - y} \cdot x\right)\\ \mathbf{elif}\;y \le 1032537.977745023905299603939056396484375:\\ \;\;\;\;\frac{2 \cdot x}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\frac{y}{x - y} \cdot x\right)\\ \end{array}\]

Reproduce

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