# Solving System of 9 linear coupled ODE

I am trying to solve a system of 9 linear coupled ODE using DSolve. To try things out I do :

e1 = app'[t] == a a03[t] + b app[t]
e2 = a03'[t] == d a03[t] - c app[t]

DSolve[{e1, e2, a03[0] == 1, app[0] == 2}, {app, a03}, {t}]


It works perfectly. Now I try to solve the real thing :

ex1 = Derivative[1][app][t] == 2*a03[t]*A21 + 2*A21*a30[t] + 2*I*app[t]*B22 + I*a3p[t]*w + I*Conjugate[a3p[t]]*w - 2*I*app[t]*w +
(-4*a33[t] + Conjugate[apm[t]] + apm[t])*Subscript[A, c]^11;
ex2 = Derivative[1][apm][t] == (Conjugate[app[t]] + app[t])*Subscript[A, c]^11 -
I*((-a3m[t] + Conjugate[a3p[t]])*w + 2*(a03[t] + a30[t])*Subscript[B, c]^11);
ex3 = Derivative[1][a30][t] == -2*A21*(Conjugate[app[t]] - app[t]) - 2*I*(Conjugate[a0m[t]] - Conjugate[a0p[t]])*w +
2*I*(4 + Conjugate[apm[t]] + apm[t])*Subscript[B, c]^11;
ex4 = Derivative[1][a03][t] == -2*A21*(Conjugate[app[t]] - app[t]) - 2*I*(a0m[t] - a0p[t])*w + 2*I*(4 + Conjugate[apm[t]] + apm[t])*Subscript[B, c]^11;
ex5 = Derivative[1][a33][t] == 2*I*((-a3m[t] + a3p[t] - Conjugate[a3m[t]] + Conjugate[a3p[t]])*w + 2*I*(Conjugate[app[t]] + app[t])*Subscript[A, c]^11 +
4*(a03[t] + a30[t])*Subscript[B, c]^11);
ex6 = Derivative[1][a0p][t] == 4*I*((-I)*A21*Conjugate[a3m[t]] + a0p[t]*B22 + a03[t]*w - a0p[t]*w - I*a0m[t]*Subscript[A, c]^11 -
Conjugate[a3p[t]]*Subscript[B, c]^11);
ex7 = Derivative[1][a0m][t] == -4*I*((-I)*A21*Conjugate[a3p[t]] + a0m[t]*B22 + a03[t]*w - a0m[t]*w + I*a0p[t]*Subscript[A, c]^11 +
Conjugate[a3m[t]]*Subscript[B, c]^11);
ex8 = Derivative[1][a3m][t] == 2*I*(-2*I*A21*Conjugate[a0p[t]] - 2*a3m[t]*B22 - 2*a33[t]*w + 2*a3m[t]*w - Conjugate[app[t]]*w + apm[t]*w -
2*I*(a3p[t] + 2*Conjugate[a3p[t]])*Subscript[A, c]^11 + 2*(2*a0m[t] + Conjugate[a0m[t]])*Subscript[B, c]^11);
ex9 = Derivative[1][a3p][t] == 2*I*(2*I*A21*Conjugate[a0m[t]] + 2*a3p[t]*B22 + 2*a33[t]*w - 2*a3p[t]*w - Conjugate[apm[t]]*w + app[t]*w -
2*I*(a3m[t] + 2*Conjugate[a3m[t]])*Subscript[A, c]^11 + 2*(2*a0p[t] + Conjugate[a0p[t]])*Subscript[B, c]^11);
DSolve[{ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9}, {app, apm, a30, a03, a33, a0p, a0m, a3m, a3p}, t]


This however fails and gives the following output :

DSolve[{Derivative[1][app][t] == 2*A21*a03[t] + 2*A21*a30[t] + I*w*a3p[t] + 2*I*B22*app[t] - 2*I*w*app[t] + I*w*Conjugate[a3p[t]] +
(-4*a33[t] + apm[t] + Conjugate[apm[t]])*Subscript[A, c]^11, Derivative[1][apm][t] == (app[t] + Conjugate[app[t]])*Subscript[A, c]^11 -
I*(w*(-a3m[t] + Conjugate[a3p[t]]) + 2*(a03[t] + a30[t])*Subscript[B, c]^11),
Derivative[1][a30][t] == -2*I*w*(Conjugate[a0m[t]] - Conjugate[a0p[t]]) - 2*A21*(-app[t] + Conjugate[app[t]]) +
2*I*(4 + apm[t] + Conjugate[apm[t]])*Subscript[B, c]^11, Derivative[1][a03][t] == -2*I*w*(a0m[t] - a0p[t]) - 2*A21*(-app[t] + Conjugate[app[t]]) +
2*I*(4 + apm[t] + Conjugate[apm[t]])*Subscript[B, c]^11, Derivative[1][a33][t] ==
2*I*(w*(-a3m[t] + a3p[t] - Conjugate[a3m[t]] + Conjugate[a3p[t]]) + 2*I*(app[t] + Conjugate[app[t]])*Subscript[A, c]^11 +
4*(a03[t] + a30[t])*Subscript[B, c]^11), Derivative[1][a0p][t] == 4*I*(w*a03[t] + B22*a0p[t] - w*a0p[t] - I*A21*Conjugate[a3m[t]] -
I*a0m[t]*Subscript[A, c]^11 - Conjugate[a3p[t]]*Subscript[B, c]^11), Derivative[1][a0m][t] ==
-4*I*(w*a03[t] + B22*a0m[t] - w*a0m[t] - I*A21*Conjugate[a3p[t]] + I*a0p[t]*Subscript[A, c]^11 + Conjugate[a3m[t]]*Subscript[B, c]^11),
Derivative[1][a3m][t] == 2*I*(-2*w*a33[t] - 2*B22*a3m[t] + 2*w*a3m[t] + w*apm[t] - 2*I*A21*Conjugate[a0p[t]] - w*Conjugate[app[t]] -
2*I*(a3p[t] + 2*Conjugate[a3p[t]])*Subscript[A, c]^11 + 2*(2*a0m[t] + Conjugate[a0m[t]])*Subscript[B, c]^11),
Derivative[1][a3p][t] == 2*I*(2*w*a33[t] + 2*B22*a3p[t] - 2*w*a3p[t] + w*app[t] + 2*I*A21*Conjugate[a0m[t]] - w*Conjugate[apm[t]] -
2*I*(a3m[t] + 2*Conjugate[a3m[t]])*Subscript[A, c]^11 + 2*(2*a0p[t] + Conjugate[a0p[t]])*Subscript[B, c]^11)},
{app, apm, a30, a03, a33, a0p, a0m, a3m, a3p}, t]


Can someone please tell me where I went wrong?

Edit :

I have experimented and discovered that :

DSolve[f'[x] == a f[x], f, x]


, takes less than one second, but the following takes around 15 seconds to evaluate :

DSolve[f'[gh] == a Conjugate[f[gh]], f, gh]

• What role play in your code parameters like Subscript[A, c]^11,Subscript[B, c]^11? Why not simply use ac, bc instead of Subscript[A,c]^11, Subscript[B, c]^11? May 1, 2020 at 14:49

We can simplifier this system up to linear matrix equation $$u'(t)=A.u+B$$ using code below

 ex1 = Derivative[1][app][t] ==
2*a03[t]*A21 + 2*A21*a30[t] + 2*I*app[t]*B22 + I*a3p[t]*w +
I*Conjugate[a3p[t]]*w -
2*I*app[t]*w + (-4*a33[t] + Conjugate[apm[t]] + apm[t])*
Subscript[A, c]^11;
ex2 = Derivative[1][apm][
t] == (Conjugate[app[t]] + app[t])*Subscript[A, c]^11 -
I*((-a3m[t] + Conjugate[a3p[t]])*w +
2*(a03[t] + a30[t])*Subscript[B, c]^11);
ex3 = Derivative[1][a30][t] == -2*A21*(Conjugate[app[t]] - app[t]) -
2*I*(Conjugate[a0m[t]] - Conjugate[a0p[t]])*w +
2*I*(4 + Conjugate[apm[t]] + apm[t])*Subscript[B, c]^11;
ex4 = Derivative[1][a03][t] == -2*A21*(Conjugate[app[t]] - app[t]) -
2*I*(a0m[t] - a0p[t])*w +
2*I*(4 + Conjugate[apm[t]] + apm[t])*Subscript[B, c]^11;
ex5 = Derivative[1][a33][t] ==
2*I*((-a3m[t] + a3p[t] - Conjugate[a3m[t]] + Conjugate[a3p[t]])*
w + 2*I*(Conjugate[app[t]] + app[t])*Subscript[A, c]^11 +
4*(a03[t] + a30[t])*Subscript[B, c]^11);
ex6 = Derivative[1][a0p][t] ==
4*I*((-I)*A21*Conjugate[a3m[t]] + a0p[t]*B22 + a03[t]*w -
a0p[t]*w - I*a0m[t]*Subscript[A, c]^11 -
Conjugate[a3p[t]]*Subscript[B, c]^11);
ex7 = Derivative[1][a0m][t] == -4*
I*((-I)*A21*Conjugate[a3p[t]] + a0m[t]*B22 + a03[t]*w - a0m[t]*w +
I*a0p[t]*Subscript[A, c]^11 +
Conjugate[a3m[t]]*Subscript[B, c]^11);
ex8 = Derivative[1][a3m][t] ==
2*I*(-2*I*A21*Conjugate[a0p[t]] - 2*a3m[t]*B22 - 2*a33[t]*w +
2*a3m[t]*w - Conjugate[app[t]]*w + apm[t]*w -
2*I*(a3p[t] + 2*Conjugate[a3p[t]])*Subscript[A, c]^11 +
2*(2*a0m[t] + Conjugate[a0m[t]])*Subscript[B, c]^11);
ex9 = Derivative[1][a3p][t] ==
2*I*(2*I*A21*Conjugate[a0m[t]] + 2*a3p[t]*B22 + 2*a33[t]*w -
2*a3p[t]*w - Conjugate[apm[t]]*w + app[t]*w -
2*I*(a3m[t] + 2*Conjugate[a3m[t]])*Subscript[A, c]^11 +
2*(2*a0p[t] + Conjugate[a0p[t]])*Subscript[B, c]^11);
exp = {ex1, ex2, ex3, ex4, ex5, ex6, ex7, ex8, ex9}; var = {app, apm,
a30, a03, a33, a0p, a0m, a3m, a3p};

rep = Table[
var[[i]][t] -> x[i][t] + I y[i][t], {i, Length[var]}]; par = {B22 ->
b22r + I b22, A21 -> a21r + I a21,
Subscript[A, c]^11 -> acr + I ac , Subscript[B, c]^11 -> bcr + I bc,
w -> w1 + I w2};

rep1 = Table[
var[[i]]'[t] -> x[i]'[t] + I y[i]'[t], {i, Length[var]}]; rep2 =
Flatten[Table[{Conjugate[x[i][t]] -> x[i][t],
Conjugate[y[i][t]] -> y[i][t]}, {i, Length[var]}], 1];

exp1 = exp /. Join[rep, rep1] /. rep2 /. par;

eqs = ComplexExpand[exp1];

X = Array[x, Length[var]]; Y = Array[y, Length[var]];

vars = Join[X, Y];

eq1 = eqs /. {I -> Z};

eqx = eq1 /. {Z -> 0};

eq2 = eq1 /. Z -> 1;

eqy = Table[
First[eq2[[i]]] - First[eqx[[i]]] ==
Last[eq2[[i]]] - Last[eqx[[i]]], {i, Length[eq2]}];


Finally we have 18 equations with separated real and complex part of all variables and parameters

eq18 = Join[eqx, eqy]


Now we can evaluate matrix of this equation

varst = Table[vars[[i]][t], {i, Length[vars]}];

{b, m} = CoefficientArrays[eq18, varst]


We can check how it looks like

m // MatrixForm
b // Normal


We can calculate constant vector as follows

varst1 = Table[vars[[i]]'[t], {i, Length[vars]}];
b0 = b - varst1;


So our matrix equation has a form (don't try to solve it with DSolve):

eqF = varst1 == m.varst - b0;

• Thank you. This was a lot to do. Let me try to understand it better as well. Thanks again. May 5, 2020 at 16:34

Calling

app[t] = appr[t] + I appi[t]
..........................
a3m[t] = a3mr[t] + I a3mi[t]


we can develop an equivalent ODE system with the structure

appr'[t] + I appi'[t] == F1r[appr[t],...,a3mi[t]] + I F1i[appr[t],...,a3mi[t]]
..............................................................................
a3mr'[t] + I a3mi'[t] == F9r[appr[t],...,a3mi[t]] + I F9i[appr[t],...,a3mi[t]]


which is equivalent to the real system

appr'[t] == F1r[appr[t],...,a3mi[t]]
appi'[t] == F1i[appr[t],...,a3mi[t]]
....................................
a3mr'[t] == F9r[appr[t],...,a3mi[t]]
a3mi'[t] == F9i[appr[t],...,a3mi[t]]


As the Fkr, Fki are linear the resulting system will appear as

$$\dot X(t) = A X(t)$$

with solution

$$X(t) = e^{A t}c_0$$

• Probably Nitin can't calculate matrix A for his "real thing". May 3, 2020 at 11:55
• It is as @AlexTrounev said. I have thought of another way to solve the problem which vastly simplifies it. Thanks for trying though. :) May 4, 2020 at 19:33
• @Nitin It is possible to simplifier system on this way up to equation x'=A.x (and I can show a code). Are all parameters like A21, B22, … reals or complex numbers? May 4, 2020 at 19:45
• @AlexTrounev They are complex numbers. It will really help me a lot if you can show me a way to simplify. May 4, 2020 at 20:43