Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
You are wrong. There is a good way to learn more apart from only asking questions. Here:… you will find lots of resources to learn Mathematica. Have fun! – Alexei Boulbitch Jul 10 '14 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. – Alexei Boulbitch Jul 10 '14 at 7:15
@Community: I think this question is off-topic and should be closed. – Alexei Boulbitch Jul 10 '14 at 7:16
up vote 1 down vote accepted

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[0] == 1, v[0] == 2}, {v[t], y[t]}, t];
ParametricPlot[Evaluate@{v[t] /. sol, y[t] /. sol}, {t, 0, 1}]

Mathematica graphics

(as others mentioned, you have lots of syntax errors there)

share|improve this answer
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. – Bak Itzik Jul 10 '14 at 7:28
Maybe you want to see something like StreamPlot[{-y, x}, {x, -1, 1}, {y, -1, 1}] ? – Dr. Wolfgang Hintze Jul 10 '14 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. – Bak Itzik Jul 10 '14 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:

In[69]:= Clear[a, y, v, yy, vv, sol]

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

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

Out[71]= {Sin[a t]/a, Cos[a t]}

In[72]:= 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

share|improve this answer
Please do not include the In[] and Out[] in the code, as it makes it hard to copy/paste as is. – Nasser Jul 10 '14 at 7:36
Ok Nasser, thanks for your hint. – Dr. Wolfgang Hintze Jul 10 '14 at 8:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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