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

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

\end{array}
double f(double x, double y) {
        double r781316 = 1.0;
        double r781317 = x;
        double r781318 = r781316 - r781317;
        double r781319 = y;
        double r781320 = r781318 * r781319;
        double r781321 = r781319 + r781316;
        double r781322 = r781320 / r781321;
        double r781323 = r781316 - r781322;
        return r781323;
}

double f(double x, double y) {
        double r781324 = y;
        double r781325 = -100774082.49659032;
        bool r781326 = r781324 <= r781325;
        double r781327 = 238223948.70080265;
        bool r781328 = r781324 <= r781327;
        double r781329 = !r781328;
        bool r781330 = r781326 || r781329;
        double r781331 = 1.0;
        double r781332 = r781331 / r781324;
        double r781333 = x;
        double r781334 = r781333 / r781324;
        double r781335 = r781331 * r781334;
        double r781336 = r781333 - r781335;
        double r781337 = r781332 + r781336;
        double r781338 = r781331 - r781333;
        double r781339 = r781338 * r781324;
        double r781340 = r781324 * r781324;
        double r781341 = r781331 * r781331;
        double r781342 = r781340 - r781341;
        double r781343 = r781339 / r781342;
        double r781344 = r781324 - r781331;
        double r781345 = r781343 * r781344;
        double r781346 = r781331 - r781345;
        double r781347 = r781330 ? r781337 : r781346;
        return r781347;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original21.8
Target0.2
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.848278829724677052581682801246643066:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891002655029296875:\\ \;\;\;\;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 < -100774082.49659032 or 238223948.70080265 < y

    1. Initial program 45.3

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

      \[\leadsto 1 - \frac{\left(1 - x\right) \cdot y}{\color{blue}{\frac{y \cdot y - 1 \cdot 1}{y - 1}}}\]
    4. Applied associate-/r/49.8

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

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

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

    if -100774082.49659032 < y < 238223948.70080265

    1. Initial program 0.1

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

      \[\leadsto 1 - \frac{\left(1 - x\right) \cdot y}{\color{blue}{\frac{y \cdot y - 1 \cdot 1}{y - 1}}}\]
    4. Applied associate-/r/0.2

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

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

Reproduce

herbie shell --seed 2019350 
(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))))