# Documentation

## Partial Fraction Expansion

Partial fraction expansion simplifies a fraction of two polynomials by writing it as a sum of simple fractions. This makes the expression easier to integrate or transform.

Expansion with Real Roots

Consider a fraction of two polynomials

The partial fraction expansion of F(s) is the sum of simple fractions

Represent F(s) in terms of the coefficients of b(s) and a(s).

b = [-4 8]; a = [1 6 8]; 

Find the partial fraction expansion using residue with b and a as inputs. The returned values of r, p, and k represent the partial fraction expansion.

[r,p,k] = residue(b,a) 
r = -12 8 p = -4 -2 k = [] 

For more information on r, p, and k, please see the last section "Definition and Implementation Using residue".

Convert the partial fraction expansion back to polynomial form using r, p, and k as inputs to residue.

[b2,a2] = residue(r,p,k) 
b2 = -4 8 a2 = 1 6 8 

Expansion with Complex Roots and Equal Degree of Numerator and Denominator

If the degree of the numerator is equal to the degree of the denominator, the output k can be nonzero.

Consider a fraction of two polynomials F(s) with complex roots and equal degree of numerator and denominator, where F(s) is

Find the partial fraction expansion of F(s).

b = [2 1 0 0]; a = [1 0 1 1]; [r,p,k] = residue(b,a) 
r = 0.5354 + 1.0390i 0.5354 - 1.0390i -0.0708 + 0.0000i p = 0.3412 + 1.1615i 0.3412 - 1.1615i -0.6823 + 0.0000i k = 2 

residue returns the complex roots and poles, and a constant term in k, representing the partial fraction expansion

Expansion with Numerator Degree Greater Than Denominator Degree

When the degree of the numerator is greater than the degree of the denominator, k is a vector that represents the coefficients of a polynomial in s.

Find the partial fraction expansion of a fraction where the degree of the numerator is larger than the degree of the denominator.

b = [2 0 0 1 0]; a = [1 0 1]; [r,p,k] = residue(b,a) 
r = 0.5000 - 1.0000i 0.5000 + 1.0000i p = 0.0000 + 1.0000i 0.0000 - 1.0000i k = 2 0 -2 

k represents the polynomial , where r, p, and k represent the partial fraction expansion

Definition and Implementation Using residue

Consider the fraction F(s) of two polynomials b and a of degree n and m, respectively

The fraction F(s) can be represented as a sum of simple fractions

This sum is the partial fraction expansion of F. The values are the residues, the values are the poles, and is a polynomial in s. For most textbook problems, is 0 or a constant.

The residue function finds the partial fraction expansion of F(s). The syntax is residue(b,a) where b and a are vectors of coefficients of b(s) and a(s), specified as b = [bn,...,b0] and a = [am,...,a0]. The output arguments are r, p, and k, which specify the residues, poles, and polynomial in s as

r = [rM ... r2 r1]

p = [pM ... p2 p1]

k = [kN ... k2 k1]

The output arguments use the syntax [r,p,k] = residue(b,a).