0
$\begingroup$

I am a new user of Mathematica. I am trying to get the solutions for a system of coupled ODEs and get the plots of the solutions. I used the following code on Mathematica,

γ = 0; c = Sqrt[2];
DSolve[{ι*y1'[x] - γ*y1[x] + c*y2[x] == 0, 
        ι*y2'[x] + c*y1[x] + c*y3[x] == 0,
        ι*y3'[x] - γ*y3[x] + c*y2[x] == 0, 
        y1[0] == y3[0] == 0, y2[0] == 1}, {y1[x], y2[x], y3[x]}, x]

Which gives me the solutions of the ODEs but how can I plot the Square of the Absolute values of the Solutions i.e, $|y1|^2, |y2|^2 , |y3|^2$ on the plot?

I used the following after the above code

Plot[{Abs[y1[x]]^2, Abs[y2[x]]^2, Abs[y3[x]]^2}, {x, 0, Pi}, PlotRange -> {0, 10}]

But it did not work. Also I would like to manipulate the plot by changing the parameter Gamma in the ODE, Is there a way to do that?

$\endgroup$
3
$\begingroup$

For iota you need to use I not ι and for Manipulate visit here.

c = Sqrt[2];

sol = DSolve[{I*y1'[x] - γ*y1[x] + c*y2[x] == 0, 
              I*y2'[x] + c*y1[x] + c*y3[x] == 0, 
              I*y3'[x] - γ*y3[x] + c*y2[x] == 0, y1[0] == y3[0] == 0, y2[0] == 1}, 
             {y1[x], y2[x], y3[x]}, x];   

Manipulate[Plot[Evaluate[{Abs[y1[x]]^2, Abs[y2[x]]^2, Abs[y3[x]]^2} /. sol /. {γ -> γ1}],
             {x, 0, Pi}, PlotRange -> {0, 10}], {γ1, 0, 1, 0.1}]

enter image description here

In response to the OP's comment,

Manipulate[Plot[Evaluate[{Abs[y1[x]]^2, Abs[y2[x]]^2, Abs[y3[x]]^2} /. sol /. {γ -> γ1}],
                 {x, 0, Pi}], {γ1, 0, 6, 0.5}]

enter image description here

$\endgroup$
  • $\begingroup$ But by changing Gamma there is no change in the plot, but actually there was change in the plot when we change Gamma, suppose say gamma = 6, the phase of the solution different from the solution when gamma =0 and the y-axis is also shifted in the case when gamma=6. $\endgroup$ – Muthu manimaran Mar 22 '17 at 8:43
  • $\begingroup$ @Muthumanimaran Remove the PlotRange then you will be able to see the variations w.r.t γ. $\endgroup$ – zhk Mar 22 '17 at 8:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.