Average Error: 15.0 → 0.6
Time: 9.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -6.28812736973600292546513463779144784486 \cdot 10^{77} \lor \neg \left(y \le 1.368390397641661343136755314604820394056 \cdot 10^{-94}\right):\\ \;\;\;\;\frac{x \cdot 2}{-1 + \frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;y \le -6.28812736973600292546513463779144784486 \cdot 10^{77} \lor \neg \left(y \le 1.368390397641661343136755314604820394056 \cdot 10^{-94}\right):\\
\;\;\;\;\frac{x \cdot 2}{-1 + \frac{x}{y}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

\end{array}
double f(double x, double y) {
        double r319669 = x;
        double r319670 = 2.0;
        double r319671 = r319669 * r319670;
        double r319672 = y;
        double r319673 = r319671 * r319672;
        double r319674 = r319669 - r319672;
        double r319675 = r319673 / r319674;
        return r319675;
}

double f(double x, double y) {
        double r319676 = y;
        double r319677 = -6.288127369736003e+77;
        bool r319678 = r319676 <= r319677;
        double r319679 = 1.3683903976416613e-94;
        bool r319680 = r319676 <= r319679;
        double r319681 = !r319680;
        bool r319682 = r319678 || r319681;
        double r319683 = x;
        double r319684 = 2.0;
        double r319685 = r319683 * r319684;
        double r319686 = -1.0;
        double r319687 = r319683 / r319676;
        double r319688 = r319686 + r319687;
        double r319689 = r319685 / r319688;
        double r319690 = r319683 - r319676;
        double r319691 = r319685 / r319690;
        double r319692 = r319691 * r319676;
        double r319693 = r319682 ? r319689 : r319692;
        return r319693;
}

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.0
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 y < -6.288127369736003e+77 or 1.3683903976416613e-94 < y

    1. Initial program 15.5

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Taylor expanded around 0 0.8

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

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

    if -6.288127369736003e+77 < y < 1.3683903976416613e-94

    1. Initial program 14.5

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -6.28812736973600292546513463779144784486 \cdot 10^{77} \lor \neg \left(y \le 1.368390397641661343136755314604820394056 \cdot 10^{-94}\right):\\ \;\;\;\;\frac{x \cdot 2}{-1 + \frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]

Reproduce

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