# Solving coupled differential equations with unknown constants

Is it possible to obtain exact solutions of these types of coupled differential equations directly in Mathematica

x'[t]=-I a x[t] + I \Sqrt b y[t]
y'[t]=I \Sqrt b x[t] + I \Sqrt b z[t]
z'[t]=I \sqrt b y[t] - I a z[t]


with initial conditions x=1 and y=z=0 ?

Note: a,b are real constants

Equations use Equal (==) vice Set (=)

eqns = {x'[t] == -I a x[t] + I Sqrt b y[t],
y'[t] == I Sqrt b x[t] + I Sqrt b z[t],
z'[t] == I Sqrt b y[t] - I a z[t],
x == 1, y == z == 0};

soln = DSolve[eqns, {x, y, z}, t][] // FullSimplify

{x -> Function[{t},
(4*b^2*E^((-I)*a*t - (1/2)*I*
(a + Sqrt[a^2 + 16*b^2])*
t)*(a^2*E^(I*a*t) +
16*b^2*E^(I*a*t) +
a*Sqrt[a^2 + 16*b^2]*
E^(I*a*t) + 2*a^2*
E^((1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t) +
32*b^2*E^((1/2)*I*
(a + Sqrt[a^2 + 16*b^2])*
t) + a^2*E^(I*a*t +
(1/2)*I*(-a + Sqrt[
a^2 + 16*b^2])*t +
(1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t) +
16*b^2*E^(I*a*t + (1/2)*I*
(-a + Sqrt[a^2 +
16*b^2])*t + (1/2)*I*
(a + Sqrt[a^2 + 16*b^2])*
t) - a*Sqrt[a^2 +
16*b^2]*E^(I*a*t +
(1/2)*I*(-a + Sqrt[
a^2 + 16*b^2])*t +
(1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t)))/
((a^2 + 16*b^2 -
a*Sqrt[a^2 + 16*b^2])*
(a^2 + 16*b^2 +
a*Sqrt[a^2 + 16*b^2]))],
y -> Function[{t},
-((16*Sqrt*b^3*Sqrt[
a^2 + 16*b^2]*(-1 +
E^((1/2)*I*(-a + Sqrt[
a^2 + 16*b^2])*t +
(1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t)))/
E^((1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t)/
((-a^2 - 16*b^2 +
a*Sqrt[a^2 + 16*b^2])*
(a^2 + 16*b^2 +
a*Sqrt[a^2 + 16*b^2])))],
z -> Function[{t},
(4*b^2*E^((-I)*a*t - (1/2)*I*
(a + Sqrt[a^2 + 16*b^2])*
t)*(a^2*E^(I*a*t) +
16*b^2*E^(I*a*t) +
a*Sqrt[a^2 + 16*b^2]*
E^(I*a*t) - 2*a^2*
E^((1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t) -
32*b^2*E^((1/2)*I*
(a + Sqrt[a^2 + 16*b^2])*
t) + a^2*E^(I*a*t +
(1/2)*I*(-a + Sqrt[
a^2 + 16*b^2])*t +
(1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t) +
16*b^2*E^(I*a*t + (1/2)*I*
(-a + Sqrt[a^2 +
16*b^2])*t + (1/2)*I*
(a + Sqrt[a^2 + 16*b^2])*
t) - a*Sqrt[a^2 +
16*b^2]*E^(I*a*t +
(1/2)*I*(-a + Sqrt[
a^2 + 16*b^2])*t +
(1/2)*I*(a + Sqrt[
a^2 + 16*b^2])*t)))/
((a^2 + 16*b^2 -
a*Sqrt[a^2 + 16*b^2])*
(a^2 + 16*b^2 +
a*Sqrt[a^2 + 16*b^2]))]}


Verifyng that the solution satisfies the equations and initial conditions

And @@ ((eqns /. soln) // Simplify)

(*  True  *)

• thanx. i'm srry, but, i'm getting Equation or list of equations expected instead of True in the first argument {(x^\[Prime])[t]==-I a x[t]+I Sqrt b y[t],(y^\[Prime])[t]==I Sqrt b x[t]+I Sqrt b z[t],True,x==1,y==z==0}. >>. am i inputting it wrong ? – ss1729 Apr 24 '16 at 15:14
• @ss1729, because of your previous definitions with Set= all equations evaluate to True; so you need to re-start the kernel to clear all previously defined symbols. – kglr Apr 24 '16 at 15:18
soln = ParametricNDSolve[{x'[t] == -I a x[t] + I Sqrt b y[t],
y'[t] == I Sqrt b x[t] + I Sqrt b z[t],
z'[t] == I Sqrt b y[t] - I a z[t], x == 1, y == 0,
z == 0}, {x, y, z}, {t, 0, 20}, {a, b}]

Plot[Through[{Re, Im}@#] & /@ {x[.1, .5][t], y[.1, .5][t],
z[.1, .5][t]} /. soln, {t, 0, 10}, Evaluated -> True,
PlotLegends -> (Style[#, Italic, 16] & /@ {"Re[x[.1,.5][t]",
"Im[x[.1,.5][t]", "Re[y[.1,.5][t]", "Im[y[.1,.5][t]",
"Re[z[.1,.5][t]", "Im[z[.1,.5][t]"})] • +1 On my Mac with v10.4.1 the PlotLegends don't show properly unless I use Evaluate with the first argument to Plot. The option Evaluated -> True doesn't work with Plot on later versions. – Bob Hanlon Apr 24 '16 at 16:36
• @BobHanlon, right; same on v9 on Windows 10 if i use "Expressions" as the setting for PlotLegends – kglr Apr 24 '16 at 16:37