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

\mathbf{else}:\\
\;\;\;\;1 - \frac{1 - x}{y + 1} \cdot y\\

\end{array}
double f(double x, double y) {
        double r577599 = 1.0;
        double r577600 = x;
        double r577601 = r577599 - r577600;
        double r577602 = y;
        double r577603 = r577601 * r577602;
        double r577604 = r577602 + r577599;
        double r577605 = r577603 / r577604;
        double r577606 = r577599 - r577605;
        return r577606;
}

double f(double x, double y) {
        double r577607 = y;
        double r577608 = -129624842.47456154;
        bool r577609 = r577607 <= r577608;
        double r577610 = 184531412.1859252;
        bool r577611 = r577607 <= r577610;
        double r577612 = !r577611;
        bool r577613 = r577609 || r577612;
        double r577614 = 1.0;
        double r577615 = r577614 / r577607;
        double r577616 = x;
        double r577617 = r577616 / r577607;
        double r577618 = r577614 * r577617;
        double r577619 = r577615 - r577618;
        double r577620 = r577619 + r577616;
        double r577621 = r577614 - r577616;
        double r577622 = r577607 + r577614;
        double r577623 = r577621 / r577622;
        double r577624 = r577623 * r577607;
        double r577625 = r577614 - r577624;
        double r577626 = r577613 ? r577620 : r577625;
        return r577626;
}

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.3
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 < -129624842.47456154 or 184531412.1859252 < y

    1. Initial program 45.2

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

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

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

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

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

    if -129624842.47456154 < y < 184531412.1859252

    1. Initial program 0.2

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

      \[\leadsto 1 - \color{blue}{\frac{1 - x}{\frac{y + 1}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.2

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

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

Reproduce

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