Average Error: 15.2 → 0.5
Time: 30.9s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -7.746127243143355974810094617686649809789 \cdot 10^{90} \lor \neg \left(y \le 9.249259069239695741011081415304173923832 \cdot 10^{-66}\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 -7.746127243143355974810094617686649809789 \cdot 10^{90} \lor \neg \left(y \le 9.249259069239695741011081415304173923832 \cdot 10^{-66}\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 r652659 = x;
        double r652660 = 2.0;
        double r652661 = r652659 * r652660;
        double r652662 = y;
        double r652663 = r652661 * r652662;
        double r652664 = r652659 - r652662;
        double r652665 = r652663 / r652664;
        return r652665;
}

double f(double x, double y) {
        double r652666 = y;
        double r652667 = -7.746127243143356e+90;
        bool r652668 = r652666 <= r652667;
        double r652669 = 9.249259069239696e-66;
        bool r652670 = r652666 <= r652669;
        double r652671 = !r652670;
        bool r652672 = r652668 || r652671;
        double r652673 = x;
        double r652674 = 2.0;
        double r652675 = r652673 * r652674;
        double r652676 = r652673 - r652666;
        double r652677 = r652676 / r652666;
        double r652678 = r652675 / r652677;
        double r652679 = r652675 / r652676;
        double r652680 = r652679 * r652666;
        double r652681 = r652672 ? r652678 : r652680;
        return r652681;
}

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.2
Target0.3
Herbie0.5
\[\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 < -7.746127243143356e+90 or 9.249259069239696e-66 < y

    1. Initial program 16.9

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

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

    if -7.746127243143356e+90 < y < 9.249259069239696e-66

    1. Initial program 13.6

      \[\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.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -7.746127243143355974810094617686649809789 \cdot 10^{90} \lor \neg \left(y \le 9.249259069239695741011081415304173923832 \cdot 10^{-66}\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 2019209 +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)))