I want to perform a partial fraction decomposition of a LTI system's frequency response, and I want it to look like this:

$$H(j\omega) = \frac 1 {5 + 2j\omega + (j\omega)^2} = \frac A {\alpha + j\omega} + \frac B {\beta + j\omega}$$

Unfortunately, if I use the Apart function

p = 5 + 2I*w + (I*w)^2
H = Apart[1/p]

what I get looks like this

$$H(j\omega) = \frac {A'} {\alpha' + \omega} + \frac {B'} {\beta' + \omega}$$

where the primed constants are equal to the original ones divided by $j$. I have also tried first performing the substitution $s = j\omega$:

p = 5 + 2s + s^2
H = Apart[1/p] /. w -> I*s

but then Mathematica simply doesn't factor the polynomial. What can I do in this situation?

P.D.: I'm not really sure what tags I should use. Feel free to edit the question to add more appropriate tags.

  • $\begingroup$ and I want it to look like this: You can make it look like this easily, but need to Hold something. Then release the Hold later. But why does it matter what it looks like on the screen? The important thing is that it works for any later computation. Many times, CAS does not display things the way we want, for this, Latex can be used later on for display. CAS is for computation mostly. $\endgroup$ – Nasser Jul 5 at 7:32
  • $\begingroup$ @Nasser: I don't think LaTeX can be used (at least not in a sane way) to figure out the correct values of $A, B, \alpha, \beta$. $\endgroup$ – pyon Jul 5 at 7:35
  • $\begingroup$ If you want the display to look like you have, I can show you how to do it in Latex inside Mathematica, very easily. My point is that you are asking about a display issue. As long as the math done by Mathematica is correct, how it displays on the screen is not that important. Issue for typesetting should be left for other software like Latex. $\endgroup$ – Nasser Jul 5 at 7:36
  • $\begingroup$ @Nasser: Thanks for the offer. Suppose I have the output of the first snippet (the one where the variable s does not appear). How can I programmatically display the values of $A, B, \alpha, \beta$? $\endgroup$ – pyon Jul 5 at 7:39

How can I programmatically display the values of A,B,α,β

For just this, you could do (for the example you have)

p = 5 + 2 I*w + (I*w)^2;
H = Apart[1/p]

enter image description here

A0 = Numerator[First@H]
B0 = Numerator[Last@H]
alpha0 = ComplexExpand@Re[Denominator[First@H]]
beta0 = ComplexExpand@Re[Denominator[Last@H]]
w0 = ComplexExpand@Im[Denominator[First@H]]

Print["A=", A0, " B=", B0, " alpha=", alpha0, " beta=", beta0, " w=", w0]

enter image description here

Compare to

enter image description here

For more general expression, ofcourse need to make the above more general. The above assumes there are only 2 terms in H.

| improve this answer | |
  • $\begingroup$ Does this generalize to the case where H has arbitrarily many summands? $\endgroup$ – pyon Jul 5 at 7:59
  • $\begingroup$ @pyon yes ofcourse. the above handles 2 terms. For more terms, one needs to iterate over all terms and do the same for each. The example you have only has 2 terms, so I used that. You can try it for general case. If stuck, you could always ask again on this forum. $\endgroup$ – Nasser Jul 5 at 8:00
  • $\begingroup$ Your values of $A, B, \alpha, \beta$ are wrong. For starters, $\alpha, \beta$ should not contain the variable $w$ in them. $\endgroup$ – pyon Jul 5 at 8:06
  • $\begingroup$ For reference, the correct values are $\alpha = 1 - 2j$, $\beta = 1 + 2j$, $A = 1/4j$, $B = -1/4j$. And $\omega$ is a variable, so it does not have a specific value. $\endgroup$ – pyon Jul 5 at 8:09
  • 1
    $\begingroup$ Thanks. Old eyes. Small screen (not really). $\endgroup$ – PaulCommentary Jul 6 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.