Average Error: 15.1 → 0.2
Time: 1.8s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -4.03649885864486073 \cdot 10^{-67} \lor \neg \left(y \le 9.5601122626142728 \cdot 10^{-5}\right):\\ \;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - 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 -4.03649885864486073 \cdot 10^{-67} \lor \neg \left(y \le 9.5601122626142728 \cdot 10^{-5}\right):\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{y}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r512792 = x;
        double r512793 = 2.0;
        double r512794 = r512792 * r512793;
        double r512795 = y;
        double r512796 = r512794 * r512795;
        double r512797 = r512792 - r512795;
        double r512798 = r512796 / r512797;
        return r512798;
}

double f(double x, double y) {
        double r512799 = y;
        double r512800 = -4.036498858644861e-67;
        bool r512801 = r512799 <= r512800;
        double r512802 = 9.560112262614273e-05;
        bool r512803 = r512799 <= r512802;
        double r512804 = !r512803;
        bool r512805 = r512801 || r512804;
        double r512806 = x;
        double r512807 = 2.0;
        double r512808 = r512806 * r512807;
        double r512809 = r512806 - r512799;
        double r512810 = r512799 / r512809;
        double r512811 = r512808 * r512810;
        double r512812 = r512808 / r512809;
        double r512813 = r512812 * r512799;
        double r512814 = r512805 ? r512811 : r512813;
        return r512814;
}

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 y < -4.036498858644861e-67 or 9.560112262614273e-05 < y

    1. Initial program 15.0

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

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

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

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

    if -4.036498858644861e-67 < y < 9.560112262614273e-05

    1. Initial program 15.3

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

      \[\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}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

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

Reproduce

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