# How to manipulate the plot of a coupled ODEs with complex coefficients? [duplicate]

This question already has an answer here:

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?

## marked as duplicate by zhk, MarcoB, march, m_goldberg plotting StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Mar 22 '17 at 18:36

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}]


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}]


• 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. – Muthu manimaran Mar 22 '17 at 8:43
• @Muthumanimaran Remove the PlotRange then you will be able to see the variations w.r.t γ. – zhk Mar 22 '17 at 8:57