# How to solve first order complex differential equation?

I want to solve these differential equations and want to get the value of 'a1'. I used this code given below but it is not showing any result. If anyone can resolve this will be appreciated.

wm = 1;
G1 = 0.005;
delc = 1;
ka = 0.1;
E0 = 0.4;
gma1 = 0.5;
g0 = 1;
kd = 0.2;
del0 = 1;
N1 = 1;
NDSolve[{q1'[t] - wm*p1[t] == 0,
p1'[t] + wm*q1[t] - G1*Abs[a1[t]]^2 + gma1*p1[t] == 0,
a1'[t] + (I*delc + ka)*a1[t] - I*G1*a1[t]*q1[t] - E0 + I*g0*s1[t] ==
0, s1'[t] + (kd - I*del0/2*N1)*s1[t] - I*g0*a1[t]*N1 == 0,
q1 == 0, p1 == 0, a1 == 1, s1 == 0}, {q1, p1, a1,
s1}, {t, 0, 100}]
Show[a1[t]]


here 'Abs' is used for, dagger of a[t] multiply with a[t].

• Have you looked at the error messages? NDSolve::underdet "There are more dependent variables, {a1[t],p1[t],q[t],q1[t],s1[t]}, \ than equations, so the system is underdetermined" Apr 6, 2020 at 4:21
• @Nasser Many have solved these types of equations numerically. Should I separate these equations in the imaginary and real terms and then after solve?
– vini
Apr 6, 2020 at 4:30
• Possibly, yes, but first, I would worry about having more dependent variables than equations than worry about the complex part. Is having more dependent variables than equations intentional? Apr 6, 2020 at 4:32
• One of your DE's has the varible q[t]. Maybe it should be q1[t] ? Apr 6, 2020 at 4:36
• @LouisB yes you are right. Now I need the value of 'a1'. how can i get it?
– vini
Apr 6, 2020 at 7:44

An easy way to plot the real and imaginary parts of the solution for a1[t is like this

soln = NDSolve[{q1'[t] - wm*p1[t] == 0,
p1'[t] + wm*q1[t] - G1*Abs[a1[t]]^2 + gma1*p1[t] == 0,
a1'[t] + (I*delc + ka)*a1[t] - I*G1*a1[t]*q1[t] - E0 +
I*g0*s1[t] == 0,
s1'[t] + (kd - I*del0/2*N1)*s1[t] - I*g0*a1[t]*N1 == 0,
q1 == 0, p1 == 0, a1 == 1, s1 == 0}, {q1, p1, a1,
s1}, {t, 0, 100}];

ReImPlot[a1[t] /. soln, {t, 0, 15}] To create a similar plot with Mathematica 9 we can code

Plot[Evaluate[{Re@a1[t], Im@a1[t]} /. soln], {t, 0, 15},
PlotStyle -> {Automatic, Dashed}]


The latest Mathematica features, however, are available with a basic Wolfram Cloud account (free).