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

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

\end{array}
double f(double x, double y) {
        double r645271 = 1.0;
        double r645272 = x;
        double r645273 = r645271 - r645272;
        double r645274 = y;
        double r645275 = r645273 * r645274;
        double r645276 = r645274 + r645271;
        double r645277 = r645275 / r645276;
        double r645278 = r645271 - r645277;
        return r645278;
}

double f(double x, double y) {
        double r645279 = y;
        double r645280 = -85111338363411.1;
        bool r645281 = r645279 <= r645280;
        double r645282 = 57260141.12847787;
        bool r645283 = r645279 <= r645282;
        double r645284 = !r645283;
        bool r645285 = r645281 || r645284;
        double r645286 = 1.0;
        double r645287 = 1.0;
        double r645288 = r645287 / r645279;
        double r645289 = x;
        double r645290 = r645289 / r645279;
        double r645291 = r645288 - r645290;
        double r645292 = r645286 * r645291;
        double r645293 = r645292 + r645289;
        double r645294 = r645279 * r645279;
        double r645295 = r645286 - r645289;
        double r645296 = r645295 * r645279;
        double r645297 = 3.0;
        double r645298 = pow(r645279, r645297);
        double r645299 = pow(r645286, r645297);
        double r645300 = r645298 + r645299;
        double r645301 = r645296 / r645300;
        double r645302 = r645294 * r645301;
        double r645303 = r645286 - r645302;
        double r645304 = r645286 * r645286;
        double r645305 = r645279 * r645286;
        double r645306 = r645304 - r645305;
        double r645307 = r645301 * r645306;
        double r645308 = r645303 - r645307;
        double r645309 = r645285 ? r645293 : r645308;
        return r645309;
}

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.2
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 < -85111338363411.1 or 57260141.12847787 < y

    1. Initial program 46.2

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Taylor expanded around inf 0.1

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

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

    if -85111338363411.1 < y < 57260141.12847787

    1. Initial program 0.4

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

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

      \[\leadsto 1 - \color{blue}{\frac{\left(1 - x\right) \cdot y}{{y}^{3} + {1}^{3}} \cdot \left(y \cdot y + \left(1 \cdot 1 - y \cdot 1\right)\right)}\]
    5. Using strategy rm
    6. Applied distribute-lft-in0.4

      \[\leadsto 1 - \color{blue}{\left(\frac{\left(1 - x\right) \cdot y}{{y}^{3} + {1}^{3}} \cdot \left(y \cdot y\right) + \frac{\left(1 - x\right) \cdot y}{{y}^{3} + {1}^{3}} \cdot \left(1 \cdot 1 - y \cdot 1\right)\right)}\]
    7. Applied associate--r+0.2

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

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

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

Reproduce

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