Average Error: 22.0 → 0.1
Time: 19.1s
Precision: 64
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
\[\begin{array}{l} \mathbf{if}\;y \le -30415092808503.895:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\ \mathbf{elif}\;y \le 490339666933239.4:\\ \;\;\;\;\left(1.0 - \left(y \cdot y\right) \cdot \frac{\left(1.0 - x\right) \cdot y}{\left(1.0 \cdot 1.0\right) \cdot 1.0 + \left(y \cdot y\right) \cdot y}\right) - \frac{\left(1.0 - x\right) \cdot y}{\left(1.0 \cdot 1.0\right) \cdot 1.0 + \left(y \cdot y\right) \cdot y} \cdot \left(1.0 \cdot 1.0 - 1.0 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\ \end{array}\]
1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}
\begin{array}{l}
\mathbf{if}\;y \le -30415092808503.895:\\
\;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\

\mathbf{elif}\;y \le 490339666933239.4:\\
\;\;\;\;\left(1.0 - \left(y \cdot y\right) \cdot \frac{\left(1.0 - x\right) \cdot y}{\left(1.0 \cdot 1.0\right) \cdot 1.0 + \left(y \cdot y\right) \cdot y}\right) - \frac{\left(1.0 - x\right) \cdot y}{\left(1.0 \cdot 1.0\right) \cdot 1.0 + \left(y \cdot y\right) \cdot y} \cdot \left(1.0 \cdot 1.0 - 1.0 \cdot y\right)\\

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

\end{array}
double f(double x, double y) {
        double r35254140 = 1.0;
        double r35254141 = x;
        double r35254142 = r35254140 - r35254141;
        double r35254143 = y;
        double r35254144 = r35254142 * r35254143;
        double r35254145 = r35254143 + r35254140;
        double r35254146 = r35254144 / r35254145;
        double r35254147 = r35254140 - r35254146;
        return r35254147;
}

double f(double x, double y) {
        double r35254148 = y;
        double r35254149 = -30415092808503.895;
        bool r35254150 = r35254148 <= r35254149;
        double r35254151 = x;
        double r35254152 = 1.0;
        double r35254153 = r35254152 / r35254148;
        double r35254154 = r35254151 + r35254153;
        double r35254155 = r35254151 / r35254148;
        double r35254156 = r35254155 * r35254152;
        double r35254157 = r35254154 - r35254156;
        double r35254158 = 490339666933239.4;
        bool r35254159 = r35254148 <= r35254158;
        double r35254160 = r35254148 * r35254148;
        double r35254161 = r35254152 - r35254151;
        double r35254162 = r35254161 * r35254148;
        double r35254163 = r35254152 * r35254152;
        double r35254164 = r35254163 * r35254152;
        double r35254165 = r35254160 * r35254148;
        double r35254166 = r35254164 + r35254165;
        double r35254167 = r35254162 / r35254166;
        double r35254168 = r35254160 * r35254167;
        double r35254169 = r35254152 - r35254168;
        double r35254170 = r35254152 * r35254148;
        double r35254171 = r35254163 - r35254170;
        double r35254172 = r35254167 * r35254171;
        double r35254173 = r35254169 - r35254172;
        double r35254174 = r35254159 ? r35254173 : r35254157;
        double r35254175 = r35254150 ? r35254157 : r35254174;
        return r35254175;
}

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.0
Target0.2
Herbie0.1
\[\begin{array}{l} \mathbf{if}\;y \lt -3693.8482788297247:\\ \;\;\;\;\frac{1.0}{y} - \left(\frac{x}{y} - x\right)\\ \mathbf{elif}\;y \lt 6799310503.41891:\\ \;\;\;\;1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\\ \mathbf{else}:\\ \;\;\;\;\frac{1.0}{y} - \left(\frac{x}{y} - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if y < -30415092808503.895 or 490339666933239.4 < y

    1. Initial program 45.3

      \[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
    2. Using strategy rm
    3. Applied div-inv45.3

      \[\leadsto 1.0 - \color{blue}{\left(\left(1.0 - x\right) \cdot y\right) \cdot \frac{1}{y + 1.0}}\]
    4. Taylor expanded around inf 0.0

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

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

    if -30415092808503.895 < y < 490339666933239.4

    1. Initial program 0.5

      \[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
    2. Using strategy rm
    3. Applied div-inv0.5

      \[\leadsto 1.0 - \color{blue}{\left(\left(1.0 - x\right) \cdot y\right) \cdot \frac{1}{y + 1.0}}\]
    4. Using strategy rm
    5. Applied flip3-+0.5

      \[\leadsto 1.0 - \left(\left(1.0 - x\right) \cdot y\right) \cdot \frac{1}{\color{blue}{\frac{{y}^{3} + {1.0}^{3}}{y \cdot y + \left(1.0 \cdot 1.0 - y \cdot 1.0\right)}}}\]
    6. Applied associate-/r/0.5

      \[\leadsto 1.0 - \left(\left(1.0 - x\right) \cdot y\right) \cdot \color{blue}{\left(\frac{1}{{y}^{3} + {1.0}^{3}} \cdot \left(y \cdot y + \left(1.0 \cdot 1.0 - y \cdot 1.0\right)\right)\right)}\]
    7. Applied associate-*r*0.5

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

      \[\leadsto 1.0 - \color{blue}{\frac{y \cdot \left(1.0 - x\right)}{\left(y \cdot y\right) \cdot y + \left(1.0 \cdot 1.0\right) \cdot 1.0}} \cdot \left(y \cdot y + \left(1.0 \cdot 1.0 - y \cdot 1.0\right)\right)\]
    9. Using strategy rm
    10. Applied distribute-rgt-in0.5

      \[\leadsto 1.0 - \color{blue}{\left(\left(y \cdot y\right) \cdot \frac{y \cdot \left(1.0 - x\right)}{\left(y \cdot y\right) \cdot y + \left(1.0 \cdot 1.0\right) \cdot 1.0} + \left(1.0 \cdot 1.0 - y \cdot 1.0\right) \cdot \frac{y \cdot \left(1.0 - x\right)}{\left(y \cdot y\right) \cdot y + \left(1.0 \cdot 1.0\right) \cdot 1.0}\right)}\]
    11. Applied associate--r+0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -30415092808503.895:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\ \mathbf{elif}\;y \le 490339666933239.4:\\ \;\;\;\;\left(1.0 - \left(y \cdot y\right) \cdot \frac{\left(1.0 - x\right) \cdot y}{\left(1.0 \cdot 1.0\right) \cdot 1.0 + \left(y \cdot y\right) \cdot y}\right) - \frac{\left(1.0 - x\right) \cdot y}{\left(1.0 \cdot 1.0\right) \cdot 1.0 + \left(y \cdot y\right) \cdot y} \cdot \left(1.0 \cdot 1.0 - 1.0 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x}{y} \cdot 1.0\\ \end{array}\]

Reproduce

herbie shell --seed 2019168 
(FPCore (x y)
  :name "Diagrams.Trail:splitAtParam  from diagrams-lib-1.3.0.3, D"

  :herbie-target
  (if (< y -3693.8482788297247) (- (/ 1.0 y) (- (/ x y) x)) (if (< y 6799310503.41891) (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))) (- (/ 1.0 y) (- (/ x y) x))))

  (- 1.0 (/ (* (- 1.0 x) y) (+ y 1.0))))