Average Error: 22.6 → 0.2
Time: 3.0s
Precision: 64
\[1 - \frac{\left(1 - x\right) \cdot y}{y + 1}\]
\[\begin{array}{l} \mathbf{if}\;y \le -108877906.66506458818912506103515625 \lor \neg \left(y \le 134742881.761377394199371337890625\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{y} - \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 -108877906.66506458818912506103515625 \lor \neg \left(y \le 134742881.761377394199371337890625\right):\\
\;\;\;\;1 \cdot \left(\frac{1}{y} - \frac{x}{y}\right) + x\\

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

\end{array}
double f(double x, double y) {
        double r788767 = 1.0;
        double r788768 = x;
        double r788769 = r788767 - r788768;
        double r788770 = y;
        double r788771 = r788769 * r788770;
        double r788772 = r788770 + r788767;
        double r788773 = r788771 / r788772;
        double r788774 = r788767 - r788773;
        return r788774;
}

double f(double x, double y) {
        double r788775 = y;
        double r788776 = -108877906.66506459;
        bool r788777 = r788775 <= r788776;
        double r788778 = 134742881.7613774;
        bool r788779 = r788775 <= r788778;
        double r788780 = !r788779;
        bool r788781 = r788777 || r788780;
        double r788782 = 1.0;
        double r788783 = 1.0;
        double r788784 = r788783 / r788775;
        double r788785 = x;
        double r788786 = r788785 / r788775;
        double r788787 = r788784 - r788786;
        double r788788 = r788782 * r788787;
        double r788789 = r788788 + r788785;
        double r788790 = r788782 - r788785;
        double r788791 = r788775 + r788782;
        double r788792 = r788790 / r788791;
        double r788793 = r788792 * r788775;
        double r788794 = r788782 - r788793;
        double r788795 = r788781 ? r788789 : r788794;
        return r788795;
}

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.6
Target0.2
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.848278829724677052581682801246643066:\\ \;\;\;\;\frac{1}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891002655029296875:\\ \;\;\;\;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 < -108877906.66506459 or 134742881.7613774 < y

    1. Initial program 46.7

      \[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 -108877906.66506459 < y < 134742881.7613774

    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 -108877906.66506458818912506103515625 \lor \neg \left(y \le 134742881.761377394199371337890625\right):\\ \;\;\;\;1 \cdot \left(\frac{1}{y} - \frac{x}{y}\right) + x\\ \mathbf{else}:\\ \;\;\;\;1 - \frac{1 - x}{y + 1} \cdot y\\ \end{array}\]

Reproduce

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