Average Error: 22.7 → 0.3
Time: 9.0s
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 r973757 = 1.0;
        double r973758 = x;
        double r973759 = r973757 - r973758;
        double r973760 = y;
        double r973761 = r973759 * r973760;
        double r973762 = r973760 + r973757;
        double r973763 = r973761 / r973762;
        double r973764 = r973757 - r973763;
        return r973764;
}

double f(double x, double y) {
        double r973765 = y;
        double r973766 = -6690123426642433.0;
        bool r973767 = r973765 <= r973766;
        double r973768 = 115382551.39706199;
        bool r973769 = r973765 <= r973768;
        double r973770 = !r973769;
        bool r973771 = r973767 || r973770;
        double r973772 = 1.0;
        double r973773 = r973772 / r973765;
        double r973774 = x;
        double r973775 = r973773 + r973774;
        double r973776 = r973774 / r973765;
        double r973777 = r973772 * r973776;
        double r973778 = r973775 - r973777;
        double r973779 = r973772 - r973774;
        double r973780 = r973779 * r973765;
        double r973781 = r973765 + r973772;
        double r973782 = r973780 / r973781;
        double r973783 = r973772 - r973782;
        double r973784 = r973771 ? r973778 : r973783;
        return r973784;
}

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))))