# Mathematica returns 1 for the denominator when clearly it isn't equal to 1

I'm trying to get the transfer function of a system from the State Space representation. It is given by $h(s)=C(sI-A)^{-1}B$ with I the identity matrix. Then I want to find the poles, so the idea is to take the denominator of the above expression and equal that to zero and solve for s. But, when I try to get the denominator, Mathematica just returns 1 when obviously the denominator is way more complicated. Then, I can't solve the equation.

AA = {{-64.383, 0, -22.35, -18.0965, 18096.5}, {0, 0, 27.65, -68.0965,
18096.5}, {1788, -2212, 0, 149, -149999}, {0, 4000, 0, -333.333,
0}, {0, 0, 0, -0.1, 0}};
BB = {{180.965}, {180.965}, {-1490}, {0}, {1}};
Ce = {{0, 0, 0, 1, 0}};
SI = s IdentityMatrix[5];
NSolve[Denominator[FullSimplify[Ce.Inverse[(SI - AA)].BB]] == 0, s]
Denominator[Ce.Inverse[(SI - AA)].BB]

• (1) Denominator will only find a syntactically explicit denominator in a product expression containing factors to negative powers. So could do Denominator[Together[Ce.Inverse[(SI - AA)].BB]]. – Daniel Lichtblau Oct 15 '17 at 20:16
• (2) Mixing symbolic algebra e.g. a function like Together with approximate coefficient expressions is dicey. Much more reliable, sually, is to rationalize first. There are exceptional cases where this is a bad idea e.g. due to speed loss. – Daniel Lichtblau Oct 15 '17 at 20:17
• (3) Explicitly for item (2) of my comments, could do In[15]:= Denominator[ Together[Ce.Inverse[Rationalize[SI - AA]].Rationalize[BB]]] Out[15]= {{2701600775379900000 + 67611605554033051 s + 229709204831000 s^2 + 1974852892695 s^3 + 1988580000 s^4 + 5000000 s^5}}. – Daniel Lichtblau Oct 15 '17 at 20:20

Things work much better if you use vectors instead of row/column matrices. Using LinearSolve[] and Chop[] in this case also helps:

AA = {{-64.383, 0, -22.35, -18.0965, 18096.5},
{0, 0, 27.65, -68.0965, 18096.5},
{1788, -2212, 0, 149, -149999},
{0, 4000, 0, -333.333, 0},
{0, 0, 0, -0.1, 0}};
BB = {180.965, 180.965, -1490, 0, 1};
Ce = {0, 0, 0, 1, 0};

NSolve[Denominator[Chop[Ce.LinearSolve[s IdentityMatrix[5] - AA, BB]]], s]
{{s -> -149.155 - 550.473 I}, {s -> -149.155 + 550.473 I},
{s -> -44.1683}, {s -> -27.6189 - 191.955 I}, {s -> -27.6189 + 191.955 I}}

• (LinearSolve[s IdentityMatrix[5] - AA, BB][[4]] also works, of course.) – J. M.'s ennui Oct 15 '17 at 20:20
• Also it is better to use LinearSolve than Inverse for this sort of thing. More efficient and less opportunity for numeric errors to corrupt things. – Daniel Lichtblau Oct 15 '17 at 20:24

The easy way to do this is to realize that the denominator of the transfer function is a polynomial whose roots are the eigenvalues of the matrix AA. Hence:

Eigenvalues[AA]//Chop
{-149.155 + 550.473 I, -149.155 - 550.473 I, -27.6189 +
191.955 I, -27.6189 - 191.955 I, -44.1683}


which of course are the same as in J.M.s answer. In particular, the denominator is independent of the BB and Ce matrices, though of course these are needed to find the zeroes of the transfer function.

• Nice, I didn't immediately see that the denominator is just the characteristic polynomial! – J. M.'s ennui Oct 16 '17 at 3:04
• I missed that too. Happy to upvote both answers. – Daniel Lichtblau Oct 16 '17 at 4:21