Integral Transforms and Complex Variable Functions
5.5 Solving Complex Variable Function Problems
5.5.3 Partial fraction expansion for rational functions Consider the rational functionConsider the rational function
G(x) = B(x)
A(x) = b1xm+ b2xm−1+ · · · + bmx + bm+1
xn+ a1xn−1+ a2xn−2+ · · · + an−1x + an
(5.32)
where ai and bi are all constants. The concept of coprimeness of rational functions is very important. The two polynomials A(x) and B(x) are coprime if there does not exist any common divisor. The greatest common divisor of two polynomials can be very difficult to find manually. However, with help of the gcd() function provided in the Symbolic Math Toolbox of MATLAB, the greatest common divisor C can easily be found with the syntax C=gcd(A,B), where A and B are the two polynomials. If C is a polynomial, then the two polynomials are not coprime. The two polynomials can then be simplified to A/C and B/C, respectively.
Example 5.24 Check whether the two polynomials A(x), B(x) are coprime or not
A(x) = x4+ 7x3+ 13x2+ 19x + 20
B(x) = x7+ 16x6+ 103x5+ 346x4+ 655x3+ 700x2+ 393x + 90.
Solution The greatest common divisor can be obtained with the gcd() function directly
>> syms x; A=x^4+7*x^3+13*x^2+19*x+20;
B=x^7+16*x^6+103*x^5+346*x^4+655*x^3+700*x^2+393*x+90;
d=gcd(A,B)
and it can be seen that the greatest common divisor is d(x) = (x + 5). Thus the two polynomials are not coprime. The two polynomials can easily be reduced with
>> simple(A/d), simple(B/d)
then A(x)/d(x) = x3+ 2x2+ 3x + 4, and B(x)/d(x) = (x + 2)(x + 3)2(x + 1)3. If the polynomials A(x) and B(x) are coprime, and the roots −pi, i = 1, 2, · · · , n of the polynomial equation A(x) = 0 are all distinct, the original rational function G(x) can be expanded into the following form
G(x) = r1
x + p1
+ r2
x + p2 + · · · + rn
x + pn
(5.33) and the expansion is referred to as the partial fraction expansion. In the expression, riare the residues, denoted as Res[G(−pi)], which can be obtained from the limit formula such that
ri= Res[G(−pi)] = lim
x→−pi
G(s)(x + pi). (5.34)
If the term (x + pi)k exists in the denominator, i.e., −pi is the pole of multiplicity k, the corresponding sub-expansion can be written as
ri
x + pi
+ ri+1
(x + pi)2 + · · · + ri+k−1
(x + pi)k. (5.35) Thus, the values ri+j−1 can be evaluated from the following formula
ri+j−1 = 1
(k − 1)! lim
x→−pi
dj−1 dxj−1
G(x)(x + pi)k
, j = 1, 2, · · · , k. (5.36) A numerical function residue() is provided in MATLAB, which can be used in the partial fraction expansion of a given rational function G(x). The syntax of the function is[r,p,K]=residue(b,a), where a =[1, a1, a2, · · · , an], and b =[b1, b2, · · · , bm]. The returned arguments r and p are vectors con-taining the ri coefficients and −pi poles, in (5.33). If repeated poles exist, the ri terms can be replaced with the coefficients in (5.35). The argument k is the direct term, which for the function satisfying k < n, K will return an empty matrix. The function can be used to automatically judge whether the pole −pi is repeated, so as to arrange the values of ri.
Example 5.25 Compute the partial fraction expansion for the following function G(s) = s3+ 2s2+ 3s + 4
s6+ 11s5+ 48s4+ 106s3+ 125s2+ 75s + 18.
Solution The following statements can be used to find the partial fraction expan-sion
>> n=[1,2,3,4]; d=[1,11,48,106,125,75,18]; format long [r,p,k]=residue(n,d); [n,d1]=rat(r); [n,d1,p]
with nT= [−17, −7, 2, 1, −1, 1], dT1 = [8, 4, 1, 8, 2, 2], pT= [−3, −3, −2, −1, −1, −1], where p is the vector of poles, n, d1 are the corresponding numerators and denomi-nators of the coefficients r. It can be seen that −3 is a pole of multiplicity 2, −2 is a single pole, while −1 is a pole of multiplicity 3. Thus the partial fraction expansion can be written as
G(s) = − 17
8(s + 3)− 7
4(s + 3)2 + 2
s + 2 + 1
8(s + 1)− 1
2(s + 1)2 + 1 2(s + 1)3. Example 5.26 Compute the partial fraction expansion of the following function
G(s) = 2s7+ 2s3+ 8
s8+30s7+386s6+2772s5+12093s4+32598s3+52520s2+45600s+16000. Solution With the residue() function, the numerical solutions can be obtained.
And for this example, the partial fraction expansion can be obtained
>> n=[2,0,0,0,2,0,0,8]; d=[1,30,386,2772,12093,32598,52520,45600,16000];
[r,p]=residue(n,d)
and due to the limitations in the numerical results, it might be difficult to find the multiplicity of poles. Thus the exact partial fraction expansion cannot be obtained.
From the results obtained, it can be approximately assumed that p1 = −5 and p2= −4 are poles of multiplicity 3, while p3= −2 and p4= −1 are single poles. Thus the partial fraction expansion can be written as
49995.9030930686
(s + 5) +28488.5832580441
(s + 5)2 +13040.9999762507
(s + 5)3 −50473.1527861460 (s + 4) 21449.5555022347
(s + 4)2 −5481.3333201362
(s + 4)3 +1.2222222224
(s + 2) +0.0023148148 (s + 1) . Clearly, a better analytical or symbolic function is expected without nu-merical issues that may cause the pole multiplicity issues. With the help of the Symbolic Math Toolbox, the following analytical function residue() can be written based on (5.34) and (5.36). The function can then be used to solve a partial fraction expansion problem. The function should be placed under the @sym directory.
1 function f=residue(F,s)
2 f=sym(0); if nargin==1, syms s; end
3 [num,den]=numden(F); x0=solve(den);
4 [x,ii]=sort(double(x0)); x0=x0(ii); x=[x0;rand(1)];
5 kvec=find(diff(double(x))~=0); ee=x(kvec);
6 kvec=[kvec(1); diff(kvec(:,1))];
7 a0=limit(den/s^length(x0),s,inf); % coefficient of the highest order
8 F1=num/(a0*prod(s-x0)); % rearrange f (x) in the denominator to write f1(x)
9 for i=1:length(kvec),
10 for j=1:kvec(i), m=kvec(i); s0=ee(i);
11 k=limit(diff(F1*(s-s0)^m,s,j-1),s,s0); % the f1(x) is used instead
12 f=f+k/(s-s0)^(m-j+1)/factorial(j-1);
13 end, end
and the syntax of the function isf =residue(fun,s), where fun is the analytical expression of the rational function, and s is the independent variable. The returned argument f is the partial fraction expansion.
It should be noted that, if the analytical solutions to the equation of de-nominator polynomial D(x) = 0 cannot be obtained, high-precision numerical solutions should be used instead. Assume that vpa() function can be used to find all the poles xi, i = 1, 2, · · · , n, then the original function can be reorganized such that the term (x − ˆx0)mcan really cancel the poles in (5.37), and the correct residue can finally be obtained
Res[f (ˆx0)] = lim
x→ˆx0
1 (m − 1)!
dm−1
dxm−1[f (ˆx0)(x − ˆx0)m] . (5.37)
Example 5.27 Compute the partial fraction expansion to f (s) in Example 5.25.
Solution The following statements can be used to solve the partial expansion problem
>> syms s;
G=(s^3+2*s^2+3*s+4)/(s^6+11*s^5+48*s^4+106*s^3+125*s^2+75*s+18);
G1=residue(G,s)
and the result below is exactly the same as the one obtained earlier G1(s) = − 17
8(s + 3)− 7
4(s + 3)2 + 2
s + 2+ 1
8(s + 1)− 1
2(s + 1)2 + 1 2(s + 1)3. Example 5.28 Now consider again the rational function G(x) defined in Exam-ple 5.26. Write the partial fraction expansion using analytical methods.
Solution In Example 5.26, the numerical approach was used and the results may not be accurate. Thus the problem can be explored with the symbolic residue() function
>> syms s
G=(2*s^7+2*s^3+8)/(s^8+30*s^7+386*s^6+2772*s^5+12093*s^4+...
32598*s^3+52520*s^2+45600*s+16000);
f=residue(G);
and then the expected partial fraction expansion is 13041
(s + 5)3 + 341863
12(s + 5)2 + 7198933
144(s + 5)− 16444
3(s + 4)3 + 193046 9(s + 4)2
−1349779
27(s + 4)+ 11
9(s + 2)+ 1 432(s + 1).
Compared with the results obtained in Example 5.26, the new result is more convincing. The difference between the expansion and the original function can be found with simple(f -G) which is 0.
Example 5.29 For the non-coprime rational function in Example 5.24, the over-loaded residue() function can be used to write out the partial fraction expansion to the rational function G(x) = A(x)/B(x).
Solution The following statements can be specified to solve the problem
>> syms x; A=x^4+7*x^3+13*x^2+19*x+20;
B=x^7+16*x^6+103*x^5+346*x^4+655*x^3+700*x^2+393*x+90;
residue(A/B,x) and it can be seen that
A(x)
B(x) = − 7
4 (x + 3)2 − 17
8 (x + 3) + 2
(x + 2)+ 1
2 (x + 1)3 − 1
2 (x + 1)2 + 1 8 (x + 1) where in the results, the term regarding x+5 does not exist at all, since simplification was performed within the residue() function already.
Example 5.30 Compute the partial fraction expansion to the following function G(x) = −17x5− 7x4+ 2x3+ x2− x + 1
x6+ 11x5+ 48x4+ 106x3+ 125x2+ 75x + 17. Solution The numerical residue() can be used first
>> num=[-17 -7 2 1 -1 1]; den=[1 11 48 106 125 75 17];
[r,p,k]=residue(num,den); [r,p,k]
and the partial fraction expansion can be written as
−556.256530687201
x + 3.261731010738 + 0.212556796963 x + 0.520859605293 0.879464926195 − j5.497076257858
x + 2.53094582005 − j0.39976310545 + 0.879464926195 + j5.497076257858 x + 2.53094582005 + j0.39976310545 +268.64252201892 + j349.12310949979
x + 2.53094582005 − j0.39976310545+268.64252201892 − j349.12310949979 x + 2.53094582005 + j0.39976310545. If the symbolic function residue() is used instead
>> syms x; G=(-17*x^5-7*x^4+2*x^3+x^2-x+1)...
/(x^6+11*x^5+48*x^4+106*x^3+125*x^2+75*x+17);
G1=residue(G,x)
more accurate partial fraction expansion can be obtained 0.21255679696263229441850086860134
x + 0.520859605293200521173180894658− 556.256530686961041694760596634 x + 3.26173101073851870211029033154 + 0.879464926194620659866107689053 + j5.49707625785732772459122493102
x + 1.0777588719352924223318783254+j0.602106591060761485593453095064 + 0.879464926194620659866107689053 − j5.49707625785732772459122493102
x + 1.0777588719352924223318783254−j0.602106591060761485593453095064 + 268.642522018804584040304940194 − j349.12310949952681814422714893
x + 2.5309458200488479660263860615+j0.39976310544985541814054726452 + 268.642522018804584040304940194 + j349.12310949952681814422714893
x + 2.5309458200488479660263860615−j0.39976310544985541814054726452.