Partial fraction expansion (partial fraction decomposition)

```
[r,p,k]
= residue(b,a)
```

```
[b,a] =
residue(r,p,k)
```

`[`

finds
the residues, poles, and direct term of a Partial Fraction Expansion of the ratio of two polynomials,
where the expansion is of the form`r`

,`p`

,`k`

]
= residue(`b`

,`a`

)

$$\frac{b(s)}{a(s)}=\frac{{b}_{m}{s}^{m}+{b}_{m-1}{s}^{m-1}+\dots +{b}_{1}s+{b}_{0}}{{a}_{n}{s}^{n}+{a}_{n-1}{s}^{n-1}+\dots +{a}_{1}s+{a}_{0}}=\frac{{r}_{n}}{s-{p}_{n}}+\mathrm{...}+\frac{{r}_{2}}{s-{p}_{2}}+\frac{{r}_{1}}{s-{p}_{1}}+k\left(s\right).$$

The inputs to `residue`

are vectors of coefficients
of the polynomials `b = [bm ... b1 b0]`

and ```
a
= [an ... a1 a0]
```

. The outputs are the residues ```
r
= [rn ... r2 r1]
```

, the poles `p = [pn ... p2 p1]`

,
and the polynomial `k`

. For most textbook problems, `k`

is `0`

or
a constant.

`residue`

first obtains the poles using `roots`

.
Next, if the fraction is nonproper, the direct term `k`

is
found using `deconv`

, which performs polynomial long
division. Finally, `residue`

determines the residues
by evaluating the polynomial with individual roots removed. For repeated
roots, `resi2`

computes the residues at the repeated
root locations.

Numerically, the partial fraction expansion of a ratio of polynomials
represents an ill-posed problem. If the denominator polynomial, *a*(*s*),
is near a polynomial with multiple roots, then small changes in the
data, including roundoff errors, can result in arbitrarily large changes
in the resulting poles and residues. Problem formulations making use
of state-space or zero-pole representations are preferable.

[1] Oppenheim, A.V. and R.W. Schafer. *Digital
Signal Processing*. Prentice-Hall, 1975, p. 56.