Average Error: 14.6 → 0.2
Time: 29.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.170166366739387040606763702320271963719 \cdot 10^{-10} \lor \neg \left(y \le 3.246088020282594653661448313913226129461 \cdot 10^{69}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{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 -4.170166366739387040606763702320271963719 \cdot 10^{-10} \lor \neg \left(y \le 3.246088020282594653661448313913226129461 \cdot 10^{69}\right):\\
\;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r342685 = x;
        double r342686 = 2.0;
        double r342687 = r342685 * r342686;
        double r342688 = y;
        double r342689 = r342687 * r342688;
        double r342690 = r342685 - r342688;
        double r342691 = r342689 / r342690;
        return r342691;
}

double f(double x, double y) {
        double r342692 = y;
        double r342693 = -4.170166366739387e-10;
        bool r342694 = r342692 <= r342693;
        double r342695 = 3.2460880202825947e+69;
        bool r342696 = r342692 <= r342695;
        double r342697 = !r342696;
        bool r342698 = r342694 || r342697;
        double r342699 = x;
        double r342700 = 2.0;
        double r342701 = r342699 * r342700;
        double r342702 = r342699 - r342692;
        double r342703 = r342702 / r342692;
        double r342704 = r342701 / r342703;
        double r342705 = r342701 / r342702;
        double r342706 = r342705 * r342692;
        double r342707 = r342698 ? r342704 : r342706;
        return r342707;
}

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.6
Target0.3
Herbie0.2
\[\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 < -4.170166366739387e-10 or 3.2460880202825947e+69 < y

    1. Initial program 16.6

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

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

    if -4.170166366739387e-10 < y < 3.2460880202825947e+69

    1. Initial program 12.8

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Using strategy rm
    3. Applied associate-/l*13.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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -4.170166366739387040606763702320271963719 \cdot 10^{-10} \lor \neg \left(y \le 3.246088020282594653661448313913226129461 \cdot 10^{69}\right):\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2019305 +o rules:numerics
(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)))