3
$\begingroup$

Is there a way to solve below $n$ simultaneous differential equations in Mathematica? $$i\frac{d}{dt}M_{n}\left(t\right) =b\sqrt{N+3+n}M_{n+1}\left(t\right)+h\sqrt{n\left(2N+5\right)}M_{n-1}\left(t\right) $$ I also want to plot $M_{n}$. h,b,N are constants.Range of n is from 0 to N

$\endgroup$
12
  • $\begingroup$ Edited the question $\endgroup$ – Jasmine May 18 at 2:46
  • $\begingroup$ is the range of $n$ all of $\mathbb{Z}$? EDIT: ah I see. is $M_n$ for $n$ outside of that range identically 0, I'm guessing? also are there any initial conditions/functions? $\endgroup$ – thorimur May 18 at 2:52
  • $\begingroup$ Edited the question. As you said range is not a matter here. Also no initial conditions $\endgroup$ – Jasmine May 18 at 2:55
  • 1
    $\begingroup$ You've essentially changed the question to another one, please avoid this. Consider posting a new question. $\endgroup$ – xzczd May 19 at 9:42
  • 1
    $\begingroup$ So, you're expecting the eigenvalue-eigenvector method to handle the unknown $M_{N+1}$? If so, then you're in the wrong direction. The $M_{N+1}$ should be supplemented by you, it's not something can be resolved by turning to another method or software. $\endgroup$ – xzczd May 20 at 3:25
8
$\begingroup$

For small number of ODE's, Mathematica DSolve solves it, but it takes longer time as more ODE's are added.

ClearAll[t, h, b, r, n];
NN = 2;
odes = Table[
  I ToExpression["M" <> ToString[n]]'[t] == 
   b Sqrt[NN + 3 + n]*ToExpression["M" <> ToString[n + 1]][t] + 
    h *Sqrt[n*(2*NN + 5)]*ToExpression["M" <> ToString[n - 1]][t], 
    {n, 0, NN}
];
deps = Table[ToExpression["M" <> ToString[n]][t], {n, 0, NN}] 

Mathematica graphics

Now call DSolve

 DSolve[odes, deps, t]

The solution is too long to post. For N=6 you get

Mathematica graphics

Now it will take much longer time to solve it. I did not want to wait for it.

You did not say how big N is. (btw, N is reserved, so better use different letter)

Edit

To answers comments. To hope to get a solution that can be plotted, need to supply IC and values for the missing parameters $h,b$ and the last $M(t)$. Here is an example for 3 equations just for illustration.

ClearAll[t, h, b, n, M];
NN = 2;
h = 5; b = 6; (*some made up values*)
odes = Table[
  I ToExpression["M" <> ToString[n]]'[t] == 
   b Sqrt[NN + 3 + n]*ToExpression["M" <> ToString[n + 1]][t] + 
    h *Sqrt[n*(2*NN + 5)]*ToExpression["M" <> ToString[n - 1]][t], {n,
    0, NN}] 
deps = Table[ToExpression["M" <> ToString[n]][t], {n, 0, NN}] 
M3[t_] := 2*t; (*some function for the last one, which has no ODE*)
ic = {M0[0] == 1, M1[1] == 2, M2[0] == 2}; (*some IC*)

Mathematica graphics

Now solve the system

DSolve[{odes, ic}, deps, t]

Now the solutions can be plotted. But they are complex. So can plot either the abs or imaginary or real parts. They are complex, since your ODE is complex.

Mathematica graphics

For example

 Plot[Re[M0[t] /. sol], {t, 0, 3}]

Mathematica graphics

 Plot[Re[M1[t] /. sol], {t, 0, 3}]

Mathematica graphics

etc.

Btw, if IC and other values are available, it will be better to use NDSolve instead of DSolve for this. DSolve takes too long time for large N.

$\endgroup$
9
  • $\begingroup$ I want to get a plot as well. $\endgroup$ – Jasmine May 18 at 5:45
  • $\begingroup$ The solution I got when used your code, has un-evaluated integrals. $\endgroup$ – DiSp0sablE_H3r0 May 18 at 6:36
  • $\begingroup$ @Jasmine it is not possible to get a plot, since there are many unknowns in the solution. To obtain a plot, you need to specify values for h,b and initial conditions, and also definition for the last $M__{N+1}(t)$ function. Since that remains undefined. Once you do all this, then DSolve was able to give exact solutions that can be plotted. (But they are complex, since your input is complex). Btw, why did you edit your question and removed Range of n is from 0 to N from it? My solution was based on that. $\endgroup$ – Nasser May 18 at 6:57
  • $\begingroup$ @DiSp0sablE_H3r0 DSolve gives an integral, since it does not know what one unknown function $M__{N+1}(t)$ is. This needs to be supplied by the user, then it will integrate it. $\endgroup$ – Nasser May 18 at 7:00
  • $\begingroup$ @Nasser yes, yes. No argument here. I just mentioned it for completeness. $\endgroup$ – DiSp0sablE_H3r0 May 18 at 7: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.