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

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

\end{array}
double f(double x, double y) {
        double r645323 = 1.0;
        double r645324 = x;
        double r645325 = r645323 - r645324;
        double r645326 = y;
        double r645327 = r645325 * r645326;
        double r645328 = r645326 + r645323;
        double r645329 = r645327 / r645328;
        double r645330 = r645323 - r645329;
        return r645330;
}

double f(double x, double y) {
        double r645331 = y;
        double r645332 = -176458068.3211119;
        bool r645333 = r645331 <= r645332;
        double r645334 = 85600986.116771;
        bool r645335 = r645331 <= r645334;
        double r645336 = !r645335;
        bool r645337 = r645333 || r645336;
        double r645338 = 1.0;
        double r645339 = 1.0;
        double r645340 = r645339 / r645331;
        double r645341 = x;
        double r645342 = r645341 / r645331;
        double r645343 = r645340 - r645342;
        double r645344 = r645338 * r645343;
        double r645345 = r645344 + r645341;
        double r645346 = r645338 - r645341;
        double r645347 = r645346 * r645331;
        double r645348 = r645331 + r645338;
        double r645349 = r645339 / r645348;
        double r645350 = r645347 * r645349;
        double r645351 = r645338 - r645350;
        double r645352 = r645337 ? r645345 : r645351;
        return r645352;
}

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.8
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 < -176458068.3211119 or 85600986.116771 < y

    1. Initial program 45.6

      \[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 -176458068.3211119 < y < 85600986.116771

    1. Initial program 0.2

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

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

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

Reproduce

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