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

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

\end{array}
double f(double x, double y) {
        double r634436 = 1.0;
        double r634437 = x;
        double r634438 = r634436 - r634437;
        double r634439 = y;
        double r634440 = r634438 * r634439;
        double r634441 = r634439 + r634436;
        double r634442 = r634440 / r634441;
        double r634443 = r634436 - r634442;
        return r634443;
}

double f(double x, double y) {
        double r634444 = y;
        double r634445 = -131869364.42794824;
        bool r634446 = r634444 <= r634445;
        double r634447 = 45126711.2146551;
        bool r634448 = r634444 <= r634447;
        double r634449 = !r634448;
        bool r634450 = r634446 || r634449;
        double r634451 = 1.0;
        double r634452 = 1.0;
        double r634453 = r634452 / r634444;
        double r634454 = x;
        double r634455 = r634454 / r634444;
        double r634456 = r634453 - r634455;
        double r634457 = r634451 * r634456;
        double r634458 = r634457 + r634454;
        double r634459 = r634451 - r634454;
        double r634460 = r634459 * r634444;
        double r634461 = r634444 + r634451;
        double r634462 = r634460 / r634461;
        double r634463 = r634451 - r634462;
        double r634464 = r634452 * r634463;
        double r634465 = r634450 ? r634458 : r634464;
        return r634465;
}

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.9
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 < -131869364.42794824 or 45126711.2146551 < y

    1. Initial program 45.2

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

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

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

    if -131869364.42794824 < y < 45126711.2146551

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{1 \cdot 1 - \frac{\left(1 - x\right) \cdot y}{y + 1} \cdot \frac{\left(1 - x\right) \cdot y}{y + 1}}{1 + \frac{\left(1 - x\right) \cdot y}{y + 1}}}\]
    4. Using strategy rm
    5. Applied flip-+4.3

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

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

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

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

Reproduce

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