Average Error: 14.9 → 0.2
Time: 10.2s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -3.849631356825476242761920153389444366702 \cdot 10^{75} \lor \neg \left(x \le 46.00635378919195517255502636544406414032\right):\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -3.849631356825476242761920153389444366702 \cdot 10^{75} \lor \neg \left(x \le 46.00635378919195517255502636544406414032\right):\\
\;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\

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

\end{array}
double f(double x, double y) {
        double r303874 = x;
        double r303875 = 2.0;
        double r303876 = r303874 * r303875;
        double r303877 = y;
        double r303878 = r303876 * r303877;
        double r303879 = r303874 - r303877;
        double r303880 = r303878 / r303879;
        return r303880;
}

double f(double x, double y) {
        double r303881 = x;
        double r303882 = -3.849631356825476e+75;
        bool r303883 = r303881 <= r303882;
        double r303884 = 46.006353789191955;
        bool r303885 = r303881 <= r303884;
        double r303886 = !r303885;
        bool r303887 = r303883 || r303886;
        double r303888 = 2.0;
        double r303889 = r303881 * r303888;
        double r303890 = y;
        double r303891 = r303881 - r303890;
        double r303892 = r303889 / r303891;
        double r303893 = r303892 * r303890;
        double r303894 = r303890 / r303891;
        double r303895 = r303889 * r303894;
        double r303896 = r303887 ? r303893 : r303895;
        return r303896;
}

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.9
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 x < -3.849631356825476e+75 or 46.006353789191955 < x

    1. Initial program 17.8

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

      \[\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.849631356825476e+75 < x < 46.006353789191955

    1. Initial program 12.7

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

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

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

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

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

Reproduce

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