You are on page 1of 5

Needs@"PlotLegends`"D

H* Project 1: A skateboard in a semicircular trough of radius R*L


H* Ghadendra Bhandari*L
In[262]:=

ClearAll@"Global`*"D;
Clear@DerivativeD;
Remove@"Global`*"D;
H* SI units assumed *L
g = 9.8;
H* The length of the rod or wire *L
R = 5.0;
omega = Sqrt@g RD;
H* initial conditions Ht=0L: A=initial theta H20 degree as large angleL,
v0=initial speed *L
theta0 = Pi 9;
H* see what happens with another small angle initial angle 9 degree *L
theta1 = Pi 20;
A = theta0;
v0 = 0.0;
B = v0 HR omegaL;
H* known exact solution for small oscillations *L
theta@t_D := A Cos@omega tD + B Sin@omega tD;
thetaother@t_D := theta1 Cos@omega tD + B Sin@omega tD;
H* Expected period*L
T = 2 Pi omega;
H* how many periods to plot *L
ncycle = 3;
H* plot the exact solution for theta@tD *L
Plot@8theta@tD, thetaother@tD<, 8t, 0, ncycle T<,
ImageSize Large, PlotStyle 8Red, Blue<,
PlotLegends 8"exact for large angle 20 deg", "exact for small angle 9 deg"<D

Printed by Wolfram Mathematica Student Edition

OscillGB.nb

0.3

0.2

0.1

exact
Out[277]=

10

12

10

12

-0.1

-0.2

-0.3

In[251]:=

H* to plot parametric plot need d theta dt *L


thetap@t_D = theta '@tD;
H* plot theta@tD's time derivative *L
Plot@thetap@tD, 8t, 0, ncycle T<, ImageSize LargeD

0.4

0.2

Out[252]=

-0.2

-0.4

Printed by Wolfram Mathematica Student Edition

exact

OscillGB.nb

In[253]:=

H* now numerical solution for large angle*L


eqn1 = Ntheta ''@tD == - omega ^ 2 Sin@Ntheta@tDD;
sol1 =
NDSolve@8eqn1, Ntheta@0D A, Ntheta '@0D == B<, Ntheta, 8t, 0, ncycle T<D Quiet;
Plot@Evaluate@Ntheta@tD . sol1D, 8t, 0, ncycle T<, ImageSize LargeD

0.3

0.2

0.1

Out[255]=

10

12

-0.1

-0.2

-0.3

H* Comparision of Exact solution and Numerical Solution*L


In[256]:=

H* first plot both solutions together *L


Plot@8theta@tD, Evaluate@Ntheta@tD . sol1D<, 8t, 0, ncycle * T<,
PlotLegends 8"exact for large angle", "numerical"<,
AxesLabel 8"t", "@tD"<, ImageSize 800D
H* greek letters are shown Hremove spaceL using, e.g., \ @ThetaD *L
H* now plot the difference,
take note of vertical scale and solution's behavior *L
Plot@8Htheta@tD - Ntheta@tDL . sol1<, 8t, 0, ncycle T<, ImageSize 800D

Printed by Wolfram Mathematica Student Edition

OscillGB.nb

@tD

0.3

0.2

0.1

Out[256]=

10

12

-0.1

-0.2

-0.3

0.04

0.02

Out[257]=

-0.02

Printed by Wolfram Mathematica Student Edition

10

12

OscillGB.nb

In[261]:=

Plot@8theta@tD, Ntheta@tD . sol1<, 8t, 0, ncycle T<,


PlotLegends 8"exact for small", "numerical"<,
AxesLabel 8"t", "@tD"<, ImageSize 800D
@tD

0.3

0.2

0.1

Out[261]=

t
2

10

12

-0.1

-0.2

-0.3

In[260]:=

Results: 1. Amplitude of oscillation depends on the initial displace, but the frequency does not depend.
2. frequency ddepends only on the length of pendulum and acceleration due to gravity.
3. The exam solution and numerical solution match very well.
4.on increasing time difference increases.

Printed by Wolfram Mathematica Student Edition

You might also like