Average Error: 22.3 → 0.2
Time: 9.1s
Precision: 64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -129624842.47456154 \lor \neg \left(y \le 184531412.18592519\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{y} - \frac{x}{y}\right) + x\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1 - x}{y + 1} \cdot y\\ \end{array}\]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \le -129624842.47456154 \lor \neg \left(y \le 184531412.18592519\right):\\
\;\;\;\;1 \cdot \left(\frac{1}{y} - \frac{x}{y}\right) + x\\

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

\end{array}
double f(double x, double y) {
        double r573037 = 1.0;
        double r573038 = x;
        double r573039 = r573037 - r573038;
        double r573040 = y;
        double r573041 = r573039 * r573040;
        double r573042 = r573040 + r573037;
        double r573043 = r573041 / r573042;
        double r573044 = r573037 - r573043;
        return r573044;
}

double f(double x, double y) {
        double r573045 = y;
        double r573046 = -129624842.47456154;
        bool r573047 = r573045 <= r573046;
        double r573048 = 184531412.1859252;
        bool r573049 = r573045 <= r573048;
        double r573050 = !r573049;
        bool r573051 = r573047 || r573050;
        double r573052 = 1.0;
        double r573053 = 1.0;
        double r573054 = r573053 / r573045;
        double r573055 = x;
        double r573056 = r573055 / r573045;
        double r573057 = r573054 - r573056;
        double r573058 = r573052 * r573057;
        double r573059 = r573058 + r573055;
        double r573060 = r573052 - r573055;
        double r573061 = r573045 + r573052;
        double r573062 = r573060 / r573061;
        double r573063 = r573062 * r573045;
        double r573064 = r573052 - r573063;
        double r573065 = r573051 ? r573059 : r573064;
        return r573065;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original22.3
Target0.3
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.84827882972468:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891003:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -129624842.47456154 or 184531412.1859252 < y

    1. Initial program 45.2

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Using strategy rm
    3. Applied flip3--52.0

      \[\leadsto \color{blue}{\frac{{1}^{3} - {\left(\frac{\left(1 - x\right) \cdot y}{y + 1}\right)}^{3}}{1 \cdot 1 + \left(\frac{\left(1 - x\right) \cdot y}{y + 1} \cdot \frac{\left(1 - x\right) \cdot y}{y + 1} + 1 \cdot \frac{\left(1 - x\right) \cdot y}{y + 1}\right)}}\]
    4. Simplified52.0

      \[\leadsto \frac{{1}^{3} - {\left(\frac{\left(1 - x\right) \cdot y}{y + 1}\right)}^{3}}{\color{blue}{\frac{\left(1 - x\right) \cdot y}{y + 1} \cdot \left(1 + \frac{\left(1 - x\right) \cdot y}{y + 1}\right) + 1 \cdot 1}}\]
    5. Taylor expanded around inf 0.3

      \[\leadsto \color{blue}{\left(x + 1 \cdot \frac{1}{y}\right) - 1 \cdot \frac{x}{y}}\]
    6. Simplified0.3

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

    if -129624842.47456154 < y < 184531412.1859252

    1. Initial program 0.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -129624842.47456154 \lor \neg \left(y \le 184531412.18592519\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{y} - \frac{x}{y}\right) + x\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1 - x}{y + 1} \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2020045 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"
  :precision binary64

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ 1 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1 (/ (* (- 1 x) y) (+ y 1))) (- (/ 1 y) (- (/ x y) x))))

  (- 1 (/ (* (- 1 x) y) (+ y 1))))