4
$\begingroup$

I am using a differential equation method for finding the roots of a function. My function is much more complicated but I can illustrate my problem with a trivial example. The problem occurs when roots coincide and change direction. I use a differential equation method. The example equation is

eq = s^2 + 2 a s + 1;

where a is a parameter (0 < a) and I wish to find the roots as the parameter is varied. To form the differential equation I take two derivatives and put them together as follows

deq = {D[eq, s], D[eq, a]} /. s -> s[a];
de = deq[[1]] s'[a] + deq[[2]] == 0
(* 2 s[a]+(2 a+2 s[a]) (s^\[Prime])[a]\[Equal]0 *)

I set up the differential equation so that I can solve with different initial conditions and over different ranges of the parameter a

ClearAll[sol];
sol[ic_, ae_] := s /. First[NDSolve[{de, s[0] == ic}, s, {a, 0, ae}]]

I have initial conditions from

ic = s /. Solve[eq == 0 /. a -> 0]
(* {-\[ImaginaryI],\[ImaginaryI]} *)

First case is fine

a1 = 0.999;
rts = sol[#, a1] & /@ ic;
ParametricPlot[Evaluate[{Re[#[a]], Im[#[a]]} & /@ rts], {a, 0, 0.999}]

Mathematica graphics

Second case attempts to go further

a1 = 2;
rts = sol[#, a1] & /@ ic;

NDSolve gets stuck as it attempts to go "round the corner" at -1. Is there a way to get NDSolve to go round the corner? Can I get both solutions going round the corner and choosing opposite directions? (One solution should go towards the origin the other towards infinity.) Thanks for help and suggestions.

$\endgroup$

1 Answer 1

3
$\begingroup$

It looks like you're trying to draw a root locus -- there is a special command for this:

RootLocusPlot[s^2 + 2 a s + 1, {a, 0, 2}]

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Thanks.I am familiar with RootLocusPlot[] but my more complicated functions (not always a polynomial) needs a more "personal" touch. It is interesting to note that RootLocusPlot[] does get "round the corner". How does it do that? $\endgroup$
    – Hugh
    Commented Jun 1, 2014 at 17:17
  • 3
    $\begingroup$ Also, note that RootLocusPlot[] is the Evans Root Locus and assumes that there is a feedback path. If you look at your solution it does not go through the same points as mine. $\endgroup$
    – Hugh
    Commented Jun 1, 2014 at 17:37
  • $\begingroup$ You can apply the root locus to a simple polynomial rather than one with a feedback loop (there is an example in the docs). But in any case, it can only handle polynomials -- if you stick a Log or Exp or some nonlinearity, you would need to do it yourself. $\endgroup$
    – bill s
    Commented Jun 1, 2014 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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