November 15, 2024

Math/Control Systems Tutorial – Partial Fraction Expansion with MATLAB

In this post we explain partial fraction expansion. This is the first part. The second part is given here. Here is a video accompanying this post:

1. Motivation


Often, in practice, we are faced with the following problem. Given a rational function or a transfer function in the case of control systems, we want to represent such a function as a sum of simpler terms. Once we have such simpler terms, in the case of control systems, we can compute the inverse Laplace transform of simpler terms to obtain the system response in the time domain. We want to expand the function in partial fractions.

For example, say that we have a (transfer) function:

(1)   \begin{align*}W(s)=\frac{1}{(s-2)(s-3)}\end{align*}


So our goal is to try to represent this function as

(2)   \begin{align*}W(s)=\frac{A}{s-2}+\frac{B}{s-3}\end{align*}


where A and B are constants that need to be determined. The expansion (2) is called the partial fraction expansion. First, we are going to use a high-school level approach for solving this problem. Namely, from the last equation, we have:

(3)   \begin{align*}W(s)=\frac{A}{s-2}+\frac{B}{s-3}=\frac{A(s-3)+B(s-2)}{(s-2)(s-3)}\end{align*}


by multiplying the expressions on the right-hand side of the last expression, we obtain:

(4)   \begin{align*}W(s)=\frac{(A+B)s-3A-2B}{(s-2)(s-3)}\end{align*}


We want to find the constants A and B, such that (4) and (1) are equal. These expressions are equal if the following equation is satisfied

(5)   \begin{align*}1=(A+B)s-3A-2B\end{align*}


The expressions on both sides of the last equations are polynomials in s. These polynomials are equal if their coefficients multiplying the terms with the same power of s, equal. Using this logic, from the last equation, we obtain the following systme of equations:

(6)   \begin{align*}0=A+B  \\1=-3A-2B\end{align*}


The solution of this system is A=-1 and B=1. How to verify this result? We can simply substitute these values of A and B in (2) and see if we can get the original expression, given by (1). Another option is to use MATLAB. Namely, the following code computes the solution:

syms s

F=1/((s-2)*(s-3))

partfrac(F)

and as the result, we obtain:

F =
 
1/((s - 2)*(s - 3))
 
 
Factorized =
 
1/(s - 3) - 1/(s - 2)

We can see that our result is correct. Let us briefly comment the MATLAB code. The code line “syms s” is used to define a symbolic variable s. Once we have that variable, with code line 3 we can define a symbolic expression for our function. Finally, code line 5 is used to compute the expansion.

Although the above-explained approach might work for more complicated functions, it becomes tedious and time-consuming if we have many terms. In the sequel, we present a systematic and easy to use approach for computing partial fraction expansion.

Case 1: Distinct Poles- (Cover-up method)

First, let us explain what are the poles and zeros of a function. Consider a general form of a function

(7)   \begin{align*}W(s)=\frac{b_{1}s^{m}+b_{2}s^{m-1}+\ldots+b_{m+1}}{s^{n}+a_{1}s^{n-1}+\ldots+a_{n}}\end{align*}


The last expression, can be written as follows:

(8)   \begin{align*}W(s)=G\frac{(s-z_{1})(s-z_{2})\ldots (s-z_{m})}{(s-p_{1})(s-p_{2})\ldots (s-p_{n})}=G\frac{\prod_{i=1}^{m}(s-z_{i})}{\prod_{i=1}^{n}(s-p_{i})}\end{align*}


where G is a constant. The constant z_{i} is referred to as a zero of the function. The constant p_{i} is referred to as a pole of the function. We can see that when s=z_{i} then the function becomes zero, and when s->p_{i} the function value approaches infinity (for real p_{i}). The poles and zeros can be real or complex. Now, assuming that the poles are distinct, we can write the function W(s) as follows:

(9)   \begin{align*}W(s)=\frac{C_{1}}{s-p_{1}}+\frac{C_{2}}{s-p_{2}}+\ldots+\frac{C_{n}}{s-p_{n}}\end{align*}


Our goal is to develop the procedure for computing the constants C_{1},C_{2},\ldots, C_{n}. Let us multiply the last expression with (s-p_{i}). As the result, we obtain

(10)   \begin{align*} (s-p_{i})W(s)=\frac{C_{1}(s-p_{i})}{s-p_{1}}+\frac{C_{2}(s-p_{i})}{s-p_{2}}+\ldots +C_{i} +\ldots+\frac{C_{n}(s-p_{i})}{s-p_{n}} \end{align*}


Now by substituting s=p_{i} in the expression (s-p_{i})W(s), we obtain

(11)   \begin{align*}(s-p_{i})W(s)\vert_{s=p_{i}}=C_{i}\end{align*}


That is, we have obtained an expression for computing the constant C_{i}. To compute the constant C_{i} corresponding to the i-th pole, we multiply the unfactorized expression W(s) by s-p_{i} and substitute the value for p_{i}.

Why this partial fraction expansion is important? Namely, after we have computed (9), we can simply compute the inverse Laplace transform by noting that:

(12)   \begin{align*}\mathcal{L}^{-1}\Big( \frac{C_{i}}{s-p_{i}} \Big)=C_{i}e^{p_{i}t}h(t)\end{align*}


where h(t) is a Heaviside step function. We can do this for all other fractions to obtain the time-domain transformation.
Let us do an example.

Example 1: Compute the step response of the function

(13)   \begin{align*}W(s)=\frac{(s+1)(s+3)}{(s+2)(s+4)}\end{align*}


Solution: The step response of the function in the complex domain is obtained by multiplying the transfer function by the term 1/s. This term corresponds to the Laplace transform of the Heaviside step function. That is, we want to compute the inverse Laplace transform of

(14)   \begin{align*}G(s)=W(s)\frac{1}{s}=\frac{(s+1)(s+3)}{(s+2)(s+4)s}\end{align*}


Let us now apply the previously explained approach. We want to expand G(s) as follows:

(15)   \begin{align*}G(s)=\frac{C_{1}}{s}+\frac{C_{2}}{s+2}+\frac{C_{3}}{s+4}\end{align*}


By using the formula (16), we obtain:

(16)   \begin{align*}C_{1}=sG(s)\vert_{s=0}=\frac{(s+1)(s+3)}{(s+2)(s+4)}\vert_{s=0}=\frac{1\cdot 3 }{2 \cdot 4}=\frac{3}{8}\end{align*}


(17)   \begin{align*}C_{2}=(s+2)G(s)\vert_{s=-2}=\frac{(s+1)(s+3)}{s(s+4)}\vert_{s=-2}=\frac{1}{4}\end{align*}


(18)   \begin{align*}C_{3}=(s+4)G(s)\vert_{s=-4}=\frac{(s+1)(s+3)}{s(s+2)}\vert_{s=-4}=\frac{3}{8}\end{align*}


So our factorized expression becomes

(19)   \begin{align*}G(s)=\frac{3}{8}\frac{1}{s}+\frac{1}{4}\frac{1}{s+2}+\frac{3}{8}\frac{1}{s+4}\end{align*}


By computing the inverse Laplace transform of the last expression we obtain

(20)   \begin{align*}g(t)=\mathcal{L}\Big( G(s) \Big)=\Big(\frac{3}{8}+\frac{1}{4}e^{-2t}+\frac{3}{8}e^{-4t}\Big)h(t)\end{align*}


The following MATLAB code is used to compute the partial fraction expansion and the inverse Laplace transform.

clc
syms s

F=(s+1)*(s+3)/(s*(s+2)*(s+4))

Factorized=partfrac(F)

ilaplace(Factorized)

The following output is generated.

F =
 
((s + 1)*(s + 3))/(s*(s + 2)*(s + 4))
 
 
Factorized =
 
1/(4*(s + 2)) + 3/(8*(s + 4)) + 3/(8*s)
 
 
ans =
 
exp(-2*t)/4 + (3*exp(-4*t))/8 + 3/8
 

Notice that we used the MATLAB function “ilaplace()” to compute the inverse Laplace transform.