Average Error: 21.0 → 0.1
Time: 17.8s
Precision: 64
\[1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}\]
\[\begin{array}{l} \mathbf{if}\;y \le -3.40118678716794 \cdot 10^{+15}:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x \cdot 1.0}{y}\\ \mathbf{elif}\;y \le 11305515126613318.0:\\ \;\;\;\;\left(1.0 - \frac{\left(y \cdot y\right) \cdot \left(\left(1.0 - x\right) \cdot y\right)}{\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 \cdot 1.0}{y}\\ \end{array}\]
1.0 - \frac{\left(1.0 - x\right) \cdot y}{y + 1.0}
\begin{array}{l}
\mathbf{if}\;y \le -3.40118678716794 \cdot 10^{+15}:\\
\;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x \cdot 1.0}{y}\\

\mathbf{elif}\;y \le 11305515126613318.0:\\
\;\;\;\;\left(1.0 - \frac{\left(y \cdot y\right) \cdot \left(\left(1.0 - x\right) \cdot y\right)}{\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 \cdot 1.0}{y}\\

\end{array}
double f(double x, double y) {
        double r31122136 = 1.0;
        double r31122137 = x;
        double r31122138 = r31122136 - r31122137;
        double r31122139 = y;
        double r31122140 = r31122138 * r31122139;
        double r31122141 = r31122139 + r31122136;
        double r31122142 = r31122140 / r31122141;
        double r31122143 = r31122136 - r31122142;
        return r31122143;
}

double f(double x, double y) {
        double r31122144 = y;
        double r31122145 = -3.40118678716794e+15;
        bool r31122146 = r31122144 <= r31122145;
        double r31122147 = x;
        double r31122148 = 1.0;
        double r31122149 = r31122148 / r31122144;
        double r31122150 = r31122147 + r31122149;
        double r31122151 = r31122147 * r31122148;
        double r31122152 = r31122151 / r31122144;
        double r31122153 = r31122150 - r31122152;
        double r31122154 = 11305515126613318.0;
        bool r31122155 = r31122144 <= r31122154;
        double r31122156 = r31122144 * r31122144;
        double r31122157 = r31122148 - r31122147;
        double r31122158 = r31122157 * r31122144;
        double r31122159 = r31122156 * r31122158;
        double r31122160 = r31122148 * r31122148;
        double r31122161 = r31122160 * r31122148;
        double r31122162 = r31122156 * r31122144;
        double r31122163 = r31122161 + r31122162;
        double r31122164 = r31122159 / r31122163;
        double r31122165 = r31122148 - r31122164;
        double r31122166 = r31122158 / r31122163;
        double r31122167 = r31122148 * r31122144;
        double r31122168 = r31122160 - r31122167;
        double r31122169 = r31122166 * r31122168;
        double r31122170 = r31122165 - r31122169;
        double r31122171 = r31122155 ? r31122170 : r31122153;
        double r31122172 = r31122146 ? r31122153 : r31122171;
        return r31122172;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original21.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 < -3.40118678716794e+15 or 11305515126613318.0 < y

    1. Initial program 44.1

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

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

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

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

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

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

    if -3.40118678716794e+15 < y < 11305515126613318.0

    1. Initial program 0.6

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

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

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

      \[\leadsto 1.0 - \color{blue}{\left(1.0 - x\right)} \cdot \frac{y}{y + 1.0}\]
    6. Using strategy rm
    7. Applied flip3-+0.6

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

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

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

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

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

      \[\leadsto \color{blue}{\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 + y \cdot \left(y \cdot y\right)}\right) - \left(1.0 \cdot 1.0 - y \cdot 1.0\right) \cdot \frac{\left(1.0 - x\right) \cdot y}{\left(1.0 \cdot 1.0\right) \cdot 1.0 + y \cdot \left(y \cdot y\right)}}\]
    14. Using strategy rm
    15. Applied associate-*r/0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -3.40118678716794 \cdot 10^{+15}:\\ \;\;\;\;\left(x + \frac{1.0}{y}\right) - \frac{x \cdot 1.0}{y}\\ \mathbf{elif}\;y \le 11305515126613318.0:\\ \;\;\;\;\left(1.0 - \frac{\left(y \cdot y\right) \cdot \left(\left(1.0 - x\right) \cdot y\right)}{\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 \cdot 1.0}{y}\\ \end{array}\]

Reproduce

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