# Plot integration curve of a system of ODEs

I'm really n00b in Mathematica, so please bear with me, as this seems to be my only option to learn how to do what I wany to do.

I have a system of two differential equations:

y' = v[t]
v'[t] = -a^2y


Now, assuming I know the solution of this system is: $y = cos(a\,t),\ v = -a\,sin(a\,t)$, I want to plot the integral curve of the two, on the v-y surface, with a t getting values from 0 to 2 π.

I've tried various combinations of StreamPlot, VectorPlot and many other functions, without any success, although I think it's suppose to be really simple. I've tried also to make a plot in 3D with VectorPlot3D, but to no avail.

I'll appreciate any help.

• You are wrong. There is a good way to learn more apart from only asking questions. Here: mathematica.stackexchange.com/questions/18/… you will find lots of resources to learn Mathematica. Have fun! Jul 10, 2014 at 7:12
• Besides, this: a^2yis an error. Mma reads it as "a to the power of 2y", while you evidently mean "a squared times y. You should have written a^2*y. Finally, have a look into Menu/Help/Documentation Center/NDSolve/BasicExamples/System of ordinary differential equations. You will find there the answer to the analogous question. Jul 10, 2014 at 7:15

one way, if I understand you right (even though I think this will be closed :)

Clear[v, t, y];
a = 9;
eq1 = y'[t] == v[t];
eq2 = v'[t] == -a^2  y[t];
sol = First@DSolve[{eq1, eq2, y == 1, v == 2}, {v[t], y[t]}, t];
ParametricPlot[Evaluate@{v[t] /. sol, y[t] /. sol}, {t, 0, 1}] (as others mentioned, you have lots of syntax errors there)

• Thanks, this is really what I wanted, with small addition - I want to plot it as vector (with direction) and that's why I've tried to do it with VectorPlot. As for the syntax errors - and this goes to Alexei as well - I didn't intended to write the accurate syntax here, this was only to explain the problem. Of course in Mathematice I used the correct syntax. Jul 10, 2014 at 7:28
• Maybe you want to see something like StreamPlot[{-y, x}, {x, -1, 1}, {y, -1, 1}] ? Jul 10, 2014 at 7:47
• Not exactly. I want the result to be just like Nasser did, but with arrows along the curve, showing the 'direction' of the curve. Jul 10, 2014 at 10:02

Instead of explaining too much, here is some correct MMA-code for your problem. By studying it (and the documentation of MMA) in detail you will discover the answer to your question:

Clear[a, y, v, yy, vv, sol]

sol =
DSolve[{y'[t] == v[t] , v'[t] == -a^2 y[t], y == 0, v == 1}, {y[t], v[t]}, t];

{yy[t_, a_], vv[t_, a_]} = {y[t], v[t]} /. sol[]

(* Out= {Sin[a t]/a, Cos[a t]} *)

With[{a = 2},
ParametricPlot[{yy[t, a], vv[t, a]}, {t, 0, 2 \[Pi]/a},
AspectRatio -> Automatic]]


I have dropped the image here for simplicity.

Regards, Wolfgang

• Please do not include the In[] and Out[] in the code, as it makes it hard to copy/paste as is. Jul 10, 2014 at 7:36
• Ok Nasser, thanks for your hint. Jul 10, 2014 at 8:01
• @Nasser Ins and Outs removed Sep 29, 2016 at 7:36
• @Nasser Thanks for upvoting. Actually, you should have punished me because I did it so late ;-) Sep 29, 2016 at 8:58