Average Error: 22.7 → 0.3
Time: 9.3s
Precision: 64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -6690123426642433 \lor \neg \left(y \le 115382551.397061989\right):\\ \;\;\;\;\left(\frac{1}{y} + x\right) - 1 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\\ \end{array}\]
1 - \frac{\left(1 - x\right) \cdot y}{y + 1}
\begin{array}{l}
\mathbf{if}\;y \le -6690123426642433 \lor \neg \left(y \le 115382551.397061989\right):\\
\;\;\;\;\left(\frac{1}{y} + x\right) - 1 \cdot \frac{x}{y}\\

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

\end{array}
double f(double x, double y) {
        double r745428 = 1.0;
        double r745429 = x;
        double r745430 = r745428 - r745429;
        double r745431 = y;
        double r745432 = r745430 * r745431;
        double r745433 = r745431 + r745428;
        double r745434 = r745432 / r745433;
        double r745435 = r745428 - r745434;
        return r745435;
}

double f(double x, double y) {
        double r745436 = y;
        double r745437 = -6690123426642433.0;
        bool r745438 = r745436 <= r745437;
        double r745439 = 115382551.39706199;
        bool r745440 = r745436 <= r745439;
        double r745441 = !r745440;
        bool r745442 = r745438 || r745441;
        double r745443 = 1.0;
        double r745444 = r745443 / r745436;
        double r745445 = x;
        double r745446 = r745444 + r745445;
        double r745447 = r745445 / r745436;
        double r745448 = r745443 * r745447;
        double r745449 = r745446 - r745448;
        double r745450 = r745443 - r745445;
        double r745451 = r745450 * r745436;
        double r745452 = r745436 + r745443;
        double r745453 = r745451 / r745452;
        double r745454 = r745443 - r745453;
        double r745455 = r745442 ? r745449 : r745454;
        return r745455;
}

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.7
Target0.2
Herbie0.3
\[\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 < -6690123426642433.0 or 115382551.39706199 < y

    1. Initial program 46.8

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity46.8

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

      \[\leadsto 1 - \color{blue}{\frac{1 - x}{1} \cdot \frac{y}{y + 1}}\]
    5. Simplified29.4

      \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \cdot \frac{y}{y + 1}\]
    6. Using strategy rm
    7. Applied associate-*r/46.8

      \[\leadsto 1 - \color{blue}{\frac{\left(1 - x\right) \cdot y}{y + 1}}\]
    8. Using strategy rm
    9. Applied associate-/l*29.4

      \[\leadsto 1 - \color{blue}{\frac{1 - x}{\frac{y + 1}{y}}}\]
    10. Taylor expanded around inf 0.1

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

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

    if -6690123426642433.0 < y < 115382551.39706199

    1. Initial program 0.4

      \[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity0.4

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

      \[\leadsto 1 - \color{blue}{\frac{1 - x}{1} \cdot \frac{y}{y + 1}}\]
    5. Simplified0.4

      \[\leadsto 1 - \color{blue}{\left(1 - x\right)} \cdot \frac{y}{y + 1}\]
    6. Using strategy rm
    7. Applied associate-*r/0.4

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

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

Reproduce

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