# How can I draw this particular phase diagram in Mathematica? [duplicate]

Sketch the phase diagram for systems with the following velocity functions where a and b are constants with b > a > 0

a. dx/dt = a, dy/dt = b
b. dx/dt = a, dy/dt = x

Please can someone show me how to draw the phase diagrams for these two functions here?

I know these functions are too simple but this is what we are learning to do in our class right now. So, I'd appreciate some help. Thanks.

• Can you provide a link to an example of what the output should look like? – bobthechemist Feb 21 '14 at 3:59
• StreamPlot is what I use if the phase space is 2D. Unfortunately, I don't understand your notation. But look it up and see if you can figure out how to apply it to your problem. – Michael E2 Feb 21 '14 at 4:04
• @sumonmumu welcome to Mathematica StackExchange! The above systems are too simple. It is very important to understand the mathematical notion of a phase space before you use an advanced software like MMA. Only in that way you will appreciate Mathematics, Physics (dynamics) and MMA. – tchronis Feb 21 '14 at 6:47
• First some nitpicking: I believe you meant "phase portrait", "phase diagram" is something that shows up in physical chemistry. Second: do you really need mathematica for this task? Try to find out what dy/dx is by looking at your system of equations... – Peltio Feb 21 '14 at 9:48

I place here a more complicated example without the use of StreamPlot

Let x'[t]=y[t] and y'[t]=-Sin[x[t]]

T = 10; sol[v_, d_] :=
NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]], x[0] == d,
y[0] == v}, {x, y}, {t, -T, T}];

and

phspace[d0_, v0_, d0step_: Pi, v0step_: 0.5] := ParametricPlot[
Flatten[
Table[{x[t], y[t]} /. sol[v, d], {d, -Abs[d0], Abs[d0],
d0step}, {v, -Abs[v0], Abs[v0], v0step}]
, 1] // Evaluate
, {t, -T, T}, PlotStyle -> Thick, AxesLabel -> {x, y},
PlotRange -> {{-T, T}, {-5, 5}}]

phspace[2 Pi, 3, Pi, 0.5]

StreamPlot contains arrows too! Check:

StreamPlot[{y, -Sin[x]}, {x, -2 Pi, 2 Pi}, {y, -3, 3}, AspectRatio -> 3/(2 Pi)]