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

• To: mathgroup at smc.vnet.net
• Subject: [mg126521] Re: Phase Plot of Simple Harmonic Motion using Mathematica ??
• From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
• Date: Thu, 17 May 2012 04:07:26 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```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 == 5, x' == 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 == 5, x' == 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 at iee.lu

```

• Prev by Date: Re: Trying to recursively define a double factorial
• Next by Date: Re: Total least squares with Mathematica?
• Previous by thread: Re: Phase Plot of Simple Harmonic Motion using Mathematica ??