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 r756144 = 1.0;
        double r756145 = x;
        double r756146 = r756144 - r756145;
        double r756147 = y;
        double r756148 = r756146 * r756147;
        double r756149 = r756147 + r756144;
        double r756150 = r756148 / r756149;
        double r756151 = r756144 - r756150;
        return r756151;
}

double f(double x, double y) {
        double r756152 = y;
        double r756153 = -108877906.66506459;
        bool r756154 = r756152 <= r756153;
        double r756155 = 134742881.7613774;
        bool r756156 = r756152 <= r756155;
        double r756157 = !r756156;
        bool r756158 = r756154 || r756157;
        double r756159 = 1.0;
        double r756160 = 1.0;
        double r756161 = r756160 / r756152;
        double r756162 = x;
        double r756163 = r756162 / r756152;
        double r756164 = r756161 - r756163;
        double r756165 = r756159 * r756164;
        double r756166 = r756165 + r756162;
        double r756167 = r756159 - r756162;
        double r756168 = r756152 + r756159;
        double r756169 = r756167 / r756168;
        double r756170 = r756169 * r756152;
        double r756171 = r756159 - r756170;
        double r756172 = r756158 ? r756166 : r756171;
        return r756172;
}

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