A rational function is defined as this:

$$
f(X) = \frac{a_0 + a_1X + a_2x^2 + \cdots a_n X^n }
{b_0 + b_1X + b_2 X^2 + \cdots + b_mX^M}
$$

Which allowing complex numbers can be factored to this:

$$
f(X) = \frac{a (X - \alpha_1)^{e_1} (X - \alpha_2)^{e_2} \cdots (X - \alpha_r)^{e_r}}
{b (X - \beta_1)^{d_1} (X - \beta_2)^{d_2} \cdots (X - \beta_s)^{d_s}}
$$

And has a "divisor" defined as this:

$$
\operatorname{div}(f(X)) = e_1[\alpha_1] + e_2[\alpha_2] + \cdots + e_r[\alpha_r] - d_1[\beta_1] - d_2[\beta_2] - \cdots - d_r[\beta_r]
$$

The first two steps make perfect sense. The last step doesn't make sense at all. How does one get from the polynomial fraction to the divisor? Can someone explain? Also, in the divisor equation, why does the equation go from $d_1[\beta_1]$ to $d_r[\beta_r]$ rather than $d_s[\beta_s]$