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

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

\end{array}
double f(double x, double y) {
        double r623253 = 1.0;
        double r623254 = x;
        double r623255 = r623253 - r623254;
        double r623256 = y;
        double r623257 = r623255 * r623256;
        double r623258 = r623256 + r623253;
        double r623259 = r623257 / r623258;
        double r623260 = r623253 - r623259;
        return r623260;
}

double f(double x, double y) {
        double r623261 = y;
        double r623262 = -100161581.36651158;
        bool r623263 = r623261 <= r623262;
        double r623264 = 279165547.0253698;
        bool r623265 = r623261 <= r623264;
        double r623266 = !r623265;
        bool r623267 = r623263 || r623266;
        double r623268 = x;
        double r623269 = 1.0;
        double r623270 = r623268 / r623261;
        double r623271 = r623269 * r623270;
        double r623272 = r623268 - r623271;
        double r623273 = r623269 / r623261;
        double r623274 = r623272 + r623273;
        double r623275 = r623269 - r623268;
        double r623276 = 1.0;
        double r623277 = r623269 + r623261;
        double r623278 = r623276 / r623277;
        double r623279 = r623278 * r623261;
        double r623280 = r623275 * r623279;
        double r623281 = r623269 - r623280;
        double r623282 = r623267 ? r623274 : r623281;
        return r623282;
}

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.9
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 < -100161581.36651158 or 279165547.0253698 < y

    1. Initial program 46.0

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Simplified29.6

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

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

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

    if -100161581.36651158 < y < 279165547.0253698

    1. Initial program 0.2

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

      \[\leadsto \color{blue}{1 - \left(1 - x\right) \cdot \frac{y}{1 + y}}\]
    3. Using strategy rm
    4. Applied div-inv0.2

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

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

Reproduce

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

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

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