I am using the Python library Sympy to calculate the partial fraction decomposition of the following rational function:
Z = (6.43369157032015e-9*s^3 + 1.35203404799555e-5*s^2 + 0.00357538393743079*s + 0.085)/(4.74334912634438e-11*s^4 + 4.09576274286244e-6*s^3 + 0.00334241812250921*s^2 + 0.15406018058983*s + 1.0)
I am calling the method apart()
like this:
Z_f = apart(Zth.expand(), full=True).doit()
And this is the result:
-1.30434068814287e+23/(s + 85524.0054884464) + 19145168.0/(s + 774.88576677949) + 91.9375/(s + 40.7977016133126) + 2.59375/(s + 7.79746609204661)
As you can see from the result, these are the residuals:
- -3.60418953263334e+22
- -4789228.25000000
- 11.0468750000000
- 0.787109375000000
The problem is that by using other tools I get different residuals.
By using GNU Octave’s residue()
I get these residuals:
- 133.6
- 1.0776
- 0.39501
- 0.56426
Via Wolphram Alpha I get the same residuals as Octave see here the results (please wait until you see the partial fraction expansion) .
Why isn’t the Sympy library not working as expected?
The poles are always correct. Only the residuals are not as I expect.
Thanks for any suggestion.