Average Error: 15.3 → 0.3
Time: 28.2s
Precision: 64
\[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.678200599830845516946512912055678313986 \cdot 10^{53} \lor \neg \left(x \le 3.181619446512529125094192620739909077175 \cdot 10^{-59}\right):\\ \;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \end{array}\]
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
\begin{array}{l}
\mathbf{if}\;x \le -1.678200599830845516946512912055678313986 \cdot 10^{53} \lor \neg \left(x \le 3.181619446512529125094192620739909077175 \cdot 10^{-59}\right):\\
\;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\

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

\end{array}
double f(double x, double y) {
        double r262043 = x;
        double r262044 = 2.0;
        double r262045 = r262043 * r262044;
        double r262046 = y;
        double r262047 = r262045 * r262046;
        double r262048 = r262043 - r262046;
        double r262049 = r262047 / r262048;
        return r262049;
}

double f(double x, double y) {
        double r262050 = x;
        double r262051 = -1.6782005998308455e+53;
        bool r262052 = r262050 <= r262051;
        double r262053 = 3.181619446512529e-59;
        bool r262054 = r262050 <= r262053;
        double r262055 = !r262054;
        bool r262056 = r262052 || r262055;
        double r262057 = y;
        double r262058 = 2.0;
        double r262059 = r262057 * r262058;
        double r262060 = r262050 - r262057;
        double r262061 = r262050 / r262060;
        double r262062 = r262059 * r262061;
        double r262063 = r262050 * r262058;
        double r262064 = r262050 / r262057;
        double r262065 = 1.0;
        double r262066 = r262064 - r262065;
        double r262067 = r262063 / r262066;
        double r262068 = r262056 ? r262062 : r262067;
        return r262068;
}

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.3
Target0.4
Herbie0.3
\[\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 < -1.6782005998308455e+53 or 3.181619446512529e-59 < x

    1. Initial program 16.0

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Simplified15.0

      \[\leadsto \color{blue}{\frac{x \cdot 2}{\frac{x - y}{y}}}\]
    3. Using strategy rm
    4. Applied div-inv15.1

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

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

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

    if -1.6782005998308455e+53 < x < 3.181619446512529e-59

    1. Initial program 14.5

      \[\frac{\left(x \cdot 2\right) \cdot y}{x - y}\]
    2. Simplified0.3

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

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

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

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

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

      \[\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.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.678200599830845516946512912055678313986 \cdot 10^{53} \lor \neg \left(x \le 3.181619446512529125094192620739909077175 \cdot 10^{-59}\right):\\ \;\;\;\;\left(y \cdot 2\right) \cdot \frac{x}{x - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{\frac{x}{y} - 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019196 
(FPCore (x y)
  :name "Linear.Projection:perspective from linear-1.19.1.3, B"

  :herbie-target
  (if (< x -1.7210442634149447e+81) (* (/ (* 2.0 x) (- x y)) y) (if (< x 8.364504563556443e+16) (/ (* x 2.0) (/ (- x y) y)) (* (/ (* 2.0 x) (- x y)) y)))

  (/ (* (* x 2.0) y) (- x y)))