Average Error: 15.0 → 0.6
Time: 1.7s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.47596719439230232 \cdot 10^{122} \lor \neg \left(x \le 67448507228.817856\right):\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x - y}{y}}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -3.47596719439230232 \cdot 10^{122} \lor \neg \left(x \le 67448507228.817856\right):\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

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

\end{array}
double f(double x, double y) {
        double r437802 = x;
        double r437803 = 2.0;
        double r437804 = r437802 * r437803;
        double r437805 = y;
        double r437806 = r437804 * r437805;
        double r437807 = r437802 - r437805;
        double r437808 = r437806 / r437807;
        return r437808;
}

double f(double x, double y) {
        double r437809 = x;
        double r437810 = -3.475967194392302e+122;
        bool r437811 = r437809 <= r437810;
        double r437812 = 67448507228.817856;
        bool r437813 = r437809 <= r437812;
        double r437814 = !r437813;
        bool r437815 = r437811 || r437814;
        double r437816 = 2.0;
        double r437817 = r437809 * r437816;
        double r437818 = y;
        double r437819 = r437809 - r437818;
        double r437820 = r437817 / r437819;
        double r437821 = r437820 * r437818;
        double r437822 = r437819 / r437818;
        double r437823 = r437817 / r437822;
        double r437824 = r437815 ? r437821 : r437823;
        return r437824;
}

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.7210442634149447 \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 < -3.475967194392302e+122 or 67448507228.817856 < x

    1. Initial program 19.2

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

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

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

    if -3.475967194392302e+122 < x < 67448507228.817856

    1. Initial program 12.3

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

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

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

Reproduce

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