# Can't find solutions to an equation involving a variable in eigenvalues

In control sytems we know that a system is of order 2 if there are two different eigenvalues such that they ratio is 10. In this case I want to find the controller gain that makes the above possible. So, let's say the first root is $\lambda_1(k_c)$ while another root is $\lambda_2(k_c)$. I want to find the kc such that $\lambda_1(k_c)=10\lambda_2(k_c)$

By the way, of course that we have to see the real part of each eigenvalue, it doesn't make sense to look to the imaginary part.

So far I have the following:

AAstable = {{-64.383, 0, -22.35, 0, (36193 kc)/200}, {0, 0,
27.65, -50, (36193 kc)/200}, {1788, -2212, 0, 0, -1490 kc}, {0,
4000, 0, -333.333, 0}, {0, 0, 0, -0.1, 0}};
NSolve[Re[Eigenvalues[AAstable]] == 10 Re[Eigenvalues[AAstable]], kc]


Mathematica returns just a bunch of things that doesn't make any sense:

> {{Re[Root[SystemReduceDumpP$53239, 4]] -> 0., > Re[Root[SystemReduceDumpP$53239, 3]] -> 0.,

• Mathematica says there is no solution for real kc. You can try NSolve[re==10 re &&Element[kc,Reals],kc] which gives {} Oct 15 '17 at 23:43
• But I think there is something wrong.. In fact let $k_c=17.603$. The eigenvalues are $\{-11.1259, -111.26 - j484.519 , -111.26 + j484.519 , -82.0349 - j167.054 , -82.0349 + j167.054 \}$. Clearly, $\frac{11.1259}{111.26}\approx 10$. So there should be any solution... (by the way I found that $k_c$ by looking the RootLocus but I need a better approximation than the graphic one) Oct 15 '17 at 23:53

I often solve these sorts of problems by defining objective functions that are 0 whenever the condition we want is met. I'm not sure exactly which eigenvalues you want to have a ratio of 10. The following objective function is 0 whenever any ratio is 10, but you can modify it as you need.

allRatios[kc_] := With[
{e = DeleteDuplicatesBy[Re@Eigenvalues[AAstable[kc]], Chop]},
Outer[#1/#2 &, e, e]
]
objective[kc_] := Min[(allRatios[kc] - 10)^2]


Now you can use NMinimize, FindRoot, or FindMinimime to find the zeros of objective:

FindMinimum[objective[x], {x, 10}]


If you play around with starting positions you will find solutions of either 17.6032 or 13.3927. You also occasionally get warnings about machine precision limits. The best way to check what is going on since the problem is only one dimensional is just to make a plot where we see the two solutions:

Plot[objective[x], {x, 0, 30}] We can also look at eg.

allRatios[17.60318522324276] // MatrixForm


which gives Edit: note you will need to change AAstable to be a function of kc to make the above code work.

• What do you mean with change AAstable to be a function of kc? Is it enough to write AAstable[kc_] ? Because it doesn't seem to work with that. EDIT: it was just me. Using Clear[AAstable] made it work. Oct 16 '17 at 1:20

A graphical way to approach this would be to use RootLocusPlot.

Once you set it up, you can 'see' the effects of changing $kc$. The real pole moves to the left and the two pairs of complex poles move to the right (and will eventually destabilize the system if $kc$ is increased too much).

The ratio of 10 can be achieved twice. As $kc$ is increased to $\approx 13.5$, the real pole moves to $\approx -8$ and the real part of one complex pair moves to $\approx -80$. Then as kc becomes $\approx$ 17.5 the real pole has moved further left to $\approx-11$ and the other complex pair has moved right with it's real part at $\approx-110$. (I had a little fun playing around with the Manipulate.)

AAstable = {{-64.383, 0, -22.35, 0, (36193 kc)/200}, {0, 0,
27.65, -50, (36193 kc)/200}, {1788, -2212, 0, 0, -1490 kc}, {0,
4000, 0, -333.333, 0}, {0, 0, 0, -0.1, 0}};

tfm = 1/CharacteristicPolynomial[AAstable, s] Manipulate[RootLocusPlot[tfm, {kc, 0, 200}, FeedbackType -> None,
AspectRatio -> 1, GridLines -> {{-110, -11}, None},
PoleZeroMarkers -> "ParameterValues" -> {kVal}], {kVal, 0, 200, 0.5}] Here is another approach that equates the characteristic polynomials.

(s + p) (s + 10 p + c I) (s + 10 p - c I) (s^2 + a s + b) +
CharacteristicPolynomial[AAstable, s];

CoefficientList[%, s];
sols = NSolve[%, {p, c, a, b, kc}, Reals] DeleteDuplicates[kc /. sols]
`

{13.3927, 17.6032}