Average Error: 15.2 → 0.4
Time: 10.5s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;y \le -9.984365809073703929848708018230154758947 \cdot 10^{82} \lor \neg \left(y \le 6.617810863587314615453058275008041291286 \cdot 10^{-52}\right):\\ \;\;\;\;\frac{x \cdot 2}{-1 + \frac{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 -9.984365809073703929848708018230154758947 \cdot 10^{82} \lor \neg \left(y \le 6.617810863587314615453058275008041291286 \cdot 10^{-52}\right):\\
\;\;\;\;\frac{x \cdot 2}{-1 + \frac{x}{y}}\\

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

\end{array}
double f(double x, double y) {
        double r417916 = x;
        double r417917 = 2.0;
        double r417918 = r417916 * r417917;
        double r417919 = y;
        double r417920 = r417918 * r417919;
        double r417921 = r417916 - r417919;
        double r417922 = r417920 / r417921;
        return r417922;
}

double f(double x, double y) {
        double r417923 = y;
        double r417924 = -9.984365809073704e+82;
        bool r417925 = r417923 <= r417924;
        double r417926 = 6.6178108635873146e-52;
        bool r417927 = r417923 <= r417926;
        double r417928 = !r417927;
        bool r417929 = r417925 || r417928;
        double r417930 = x;
        double r417931 = 2.0;
        double r417932 = r417930 * r417931;
        double r417933 = -1.0;
        double r417934 = r417930 / r417923;
        double r417935 = r417933 + r417934;
        double r417936 = r417932 / r417935;
        double r417937 = r417930 - r417923;
        double r417938 = r417932 / r417937;
        double r417939 = r417938 * r417923;
        double r417940 = r417929 ? r417936 : r417939;
        return r417940;
}

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.4
\[\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 < -9.984365809073704e+82 or 6.6178108635873146e-52 < y

    1. Initial program 16.4

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

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    4. Taylor expanded around 0 0.5

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

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

    if -9.984365809073704e+82 < y < 6.6178108635873146e-52

    1. Initial program 14.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -9.984365809073703929848708018230154758947 \cdot 10^{82} \lor \neg \left(y \le 6.617810863587314615453058275008041291286 \cdot 10^{-52}\right):\\ \;\;\;\;\frac{x \cdot 2}{-1 + \frac{x}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{x - y} \cdot y\\ \end{array}\]

Reproduce

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