Average Error: 14.7 → 1.0
Time: 10.3s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.975374295122667162704038551002068202701 \cdot 10^{-14} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -5.706968196127495363453461459528252382654 \cdot 10^{-304} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.511616892944529186384117339932247186396 \cdot 10^{-114}\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.975374295122667162704038551002068202701 \cdot 10^{-14} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -5.706968196127495363453461459528252382654 \cdot 10^{-304} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.511616892944529186384117339932247186396 \cdot 10^{-114}\right):\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r337656 = x;
        double r337657 = 2.0;
        double r337658 = r337656 * r337657;
        double r337659 = y;
        double r337660 = r337658 * r337659;
        double r337661 = r337656 - r337659;
        double r337662 = r337660 / r337661;
        return r337662;
}

double f(double x, double y) {
        double r337663 = x;
        double r337664 = 2.0;
        double r337665 = r337663 * r337664;
        double r337666 = y;
        double r337667 = r337665 * r337666;
        double r337668 = r337663 - r337666;
        double r337669 = r337667 / r337668;
        double r337670 = -4.975374295122667e-14;
        bool r337671 = r337669 <= r337670;
        double r337672 = -5.706968196127495e-304;
        bool r337673 = r337669 <= r337672;
        double r337674 = 0.0;
        bool r337675 = r337669 <= r337674;
        double r337676 = !r337675;
        double r337677 = 3.511616892944529e-114;
        bool r337678 = r337669 <= r337677;
        bool r337679 = r337676 && r337678;
        bool r337680 = r337673 || r337679;
        double r337681 = !r337680;
        bool r337682 = r337671 || r337681;
        double r337683 = r337666 / r337668;
        double r337684 = r337665 * r337683;
        double r337685 = r337682 ? r337684 : r337669;
        return r337685;
}

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.7
Target0.5
Herbie1.0
\[\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 2.0) y) (- x y)) < -4.975374295122667e-14 or -5.706968196127495e-304 < (/ (* (* x 2.0) y) (- x y)) < 0.0 or 3.511616892944529e-114 < (/ (* (* x 2.0) y) (- x y))

    1. Initial program 25.9

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

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

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

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

    if -4.975374295122667e-14 < (/ (* (* x 2.0) y) (- x y)) < -5.706968196127495e-304 or 0.0 < (/ (* (* x 2.0) y) (- x y)) < 3.511616892944529e-114

    1. Initial program 5.9

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -4.975374295122667162704038551002068202701 \cdot 10^{-14} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le -5.706968196127495363453461459528252382654 \cdot 10^{-304} \lor \neg \left(\frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 0.0\right) \land \frac{\left(x \cdot 2\right) \cdot y}{x - y} \le 3.511616892944529186384117339932247186396 \cdot 10^{-114}\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x \cdot 2\right) \cdot y}{x - y}\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 
(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)))