Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10113 > unrolled thread

Re: Phase Plot of Simple Harmonic Motion using Mathematica ??

Started byAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
First post2012-05-17 08:07 +0000
Last post2012-05-17 08:07 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: Phase Plot of Simple Harmonic Motion using Mathematica ?? Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2012-05-17 08:07 +0000

#10113 — Re: Phase Plot of Simple Harmonic Motion using Mathematica ??

FromAlexei Boulbitch <Alexei.Boulbitch@iee.lu>
Date2012-05-17 08:07 +0000
SubjectRe: Phase Plot of Simple Harmonic Motion using Mathematica ??
Message-ID<jp2bkn$4s2$1@smc.vnet.net>
Hi all,

 Plz check my code below for Phase plot of Simple Harmonic motion. The output should be a circle with x along X-axis and dxdt along y-axis.

I'm not getting the output. kindly let me know where i'm wrong.

 Clear[k, m];
k = 1;
m = 3;
solution =
 NDSolve[{x''[t] + k/m x[t] == 0, x[0] == 5, x'[0] == 0},
  x, {t, 0, 250}, MaxSteps \[RightArrow] 50000,
  WorkingPrecision \[RightArrow] 25]
ParametricPlot[Evaluate[{x[t], x'[t]} /. solution], {t, 0, 100},
 PlotRange \[RightArrow] All,
 AxesLabel -> {"x", "\!\(\*OverscriptBox[\(x\), \(.\)]\)"}]

Regards, Rc

Hi, Rahul,

Try this:

Clear[k, m];
k = 1;
m = 3;
solution =
 NDSolve[{x''[t] + (k/m )*x[t] == 0, x[0] == 5, x'[0] == 0},
   x, {t, 0, 250}] // Flatten
ParametricPlot[Evaluate[{x[t], x'[t]} /. solution], {t, 0, 100},
 AxesLabel -> {"x", "x'"}, PlotRange -> All]

The main difference in the function Flatten that I apply to the solution. I t removes the extra parentheses. The latter have prevented you from getting solution.

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu



[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web