# Solving n simultaneous differential equation

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

• Edited the question – Jasmine May 18 at 2:46
• 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? – thorimur May 18 at 2:52
• Edited the question. As you said range is not a matter here. Also no initial conditions – Jasmine May 18 at 2:55
• You've essentially changed the question to another one, please avoid this. Consider posting a new question. – xzczd May 19 at 9:42
• 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. – xzczd May 20 at 3:25

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}] Now call DSolve

 DSolve[odes, deps, t]


The solution is too long to post. For N=6 you get 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 == 1, M1 == 2, M2 == 2}; (*some IC*) 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. For example

 Plot[Re[M0[t] /. sol], {t, 0, 3}] Plot[Re[M1[t] /. sol], {t, 0, 3}] 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.

• I want to get a plot as well. – Jasmine May 18 at 5:45
• The solution I got when used your code, has un-evaluated integrals. – DiSp0sablE_H3r0 May 18 at 6:36
• @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. – Nasser May 18 at 6:57
• @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. – Nasser May 18 at 7:00
• @Nasser yes, yes. No argument here. I just mentioned it for completeness. – DiSp0sablE_H3r0 May 18 at 7:01