2

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.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
Bak Itzik
  • 23
  • 2
  • You are wrong. There is a good way to learn more apart from only asking questions. Here: http://mathematica.stackexchange.com/questions/18/where-can-i-find-examples-of-good-mathematica-programming-practice you will find lots of resources to learn Mathematica. Have fun! – Alexei Boulbitch Jul 10 '14 at 07: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 07:15

2 Answers2

4

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)

Nasser
  • 143,286
  • 11
  • 154
  • 359
  • 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 07:28
  • Maybe you want to see something like StreamPlot[{-y, x}, {x, -1, 1}, {y, -1, 1}] ? – Dr. Wolfgang Hintze Jul 10 '14 at 07: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
4

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] == 0, v[0] == 1}, {y[t], v[t]}, t];

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

(* Out[71]= {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

Dr. Wolfgang Hintze
  • 13,039
  • 17
  • 47