Skip to main content
3 of 5
edited tags; edited tags
bbgodfrey
  • 63k
  • 18
  • 94
  • 169

Reject diverging solution of NDSolve

I'm trying to numerically simulate a spring system with complex stiffness. In essence systems of the form

$x''(t)+ (a+ ib) x(t)=0$

For this simple example an analytic solution is easy to find. The code

Eqn = {x''[t] + (a + I*b)*x[t] == 0}; AnalyticSol = DSolve[Eqn, x[t], t] 

produces the output

$\left\{x(t)\to c_1 e^{t \sqrt{-a-i b}}+c_2 e^{t \left(-\sqrt{-a-i b}\right)}\right\}$

The problem with this solution is that the first term diverges. A literature search shows that the accepted solution is to just $c_1=0$, rejecting the diverging solution. This replaces one of the initial conditions. The other initial condition is then made to be complex to account for both the initial position and velocity.

Now the actual system I'm working with is much more complex and can only be solved numerically. So I was wondering if there was any way to do something like this with NDSolve. As you can see by default it will not reject the diverging solution

a = 1.1; b = 1.2; T = 20; Eqn = {x''[t] + (a + I*b)*x[t] == 0}; Inits = {x[0] == 1, x'[0] == 0}; Sys = Join[Eqn, Inits]; NumericalSol = NDSolve[Sys, x[t], {t, 0, T}]; Plot[Evaluate[Re[x[t]] /. NumericalSol], {t, 0, T}] 

enter image description here

xentity1x
  • 261
  • 1
  • 7