Average Error: 15.1 → 0.2
Time: 1.6s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.0306756776612656 \cdot 10^{44} \lor \neg \left(x \le 8.69159111879264488 \cdot 10^{-21}\right):\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{1 \cdot \left(\frac{x}{y} - 1\right)}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -3.0306756776612656 \cdot 10^{44} \lor \neg \left(x \le 8.69159111879264488 \cdot 10^{-21}\right):\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

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

\end{array}
double f(double x, double y) {
        double r493801 = x;
        double r493802 = 2.0;
        double r493803 = r493801 * r493802;
        double r493804 = y;
        double r493805 = r493803 * r493804;
        double r493806 = r493801 - r493804;
        double r493807 = r493805 / r493806;
        return r493807;
}

double f(double x, double y) {
        double r493808 = x;
        double r493809 = -3.0306756776612656e+44;
        bool r493810 = r493808 <= r493809;
        double r493811 = 8.691591118792645e-21;
        bool r493812 = r493808 <= r493811;
        double r493813 = !r493812;
        bool r493814 = r493810 || r493813;
        double r493815 = 2.0;
        double r493816 = r493808 * r493815;
        double r493817 = y;
        double r493818 = r493808 - r493817;
        double r493819 = r493816 / r493818;
        double r493820 = r493819 * r493817;
        double r493821 = 1.0;
        double r493822 = r493808 / r493817;
        double r493823 = r493822 - r493821;
        double r493824 = r493821 * r493823;
        double r493825 = r493816 / r493824;
        double r493826 = r493814 ? r493820 : r493825;
        return r493826;
}

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.1
Target0.3
Herbie0.2
\[\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.0306756776612656e+44 or 8.691591118792645e-21 < x

    1. Initial program 16.6

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

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

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

    if -3.0306756776612656e+44 < x < 8.691591118792645e-21

    1. Initial program 13.7

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity0.2

      \[\leadsto \frac{x \cdot 2}{\frac{x - y}{\color{blue}{1 \cdot y}}}\]
    6. Applied *-un-lft-identity0.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -3.0306756776612656 \cdot 10^{44} \lor \neg \left(x \le 8.69159111879264488 \cdot 10^{-21}\right):\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{1 \cdot \left(\frac{x}{y} - 1\right)}\\ \end{array}\]

Reproduce

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