Average Error: 14.9 → 0.6
Time: 1.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -9.573025967556919874381857319699629829641 \cdot 10^{-15} \lor \neg \left(x \le 2.651436562478195718952368280494467487413 \cdot 10^{-126}\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 -9.573025967556919874381857319699629829641 \cdot 10^{-15} \lor \neg \left(x \le 2.651436562478195718952368280494467487413 \cdot 10^{-126}\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 r483998 = x;
        double r483999 = 2.0;
        double r484000 = r483998 * r483999;
        double r484001 = y;
        double r484002 = r484000 * r484001;
        double r484003 = r483998 - r484001;
        double r484004 = r484002 / r484003;
        return r484004;
}

double f(double x, double y) {
        double r484005 = x;
        double r484006 = -9.57302596755692e-15;
        bool r484007 = r484005 <= r484006;
        double r484008 = 2.6514365624781957e-126;
        bool r484009 = r484005 <= r484008;
        double r484010 = !r484009;
        bool r484011 = r484007 || r484010;
        double r484012 = 2.0;
        double r484013 = r484005 * r484012;
        double r484014 = y;
        double r484015 = r484005 - r484014;
        double r484016 = r484013 / r484015;
        double r484017 = r484016 * r484014;
        double r484018 = r484014 / r484015;
        double r484019 = r484013 * r484018;
        double r484020 = r484011 ? r484017 : r484019;
        return r484020;
}

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.6
\[\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 < -9.57302596755692e-15 or 2.6514365624781957e-126 < x

    1. Initial program 14.0

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

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

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

    if -9.57302596755692e-15 < x < 2.6514365624781957e-126

    1. Initial program 16.4

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -9.573025967556919874381857319699629829641 \cdot 10^{-15} \lor \neg \left(x \le 2.651436562478195718952368280494467487413 \cdot 10^{-126}\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 2019356 
(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)))