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


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

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

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Phase Plot of Simple Harmonic Motion using Mathematica ??
Date 2012-05-17 08:07 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jp2bkn$4s2$1@smc.vnet.net> (permalink)

Show all headers | View raw


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



Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web