Vous êtes sur la page 1sur 7

INTRODUCTORY COMPUTATIONAL PHYSICS

NAME: AROOJ MUKARRAM


EXERCISE 2.3
SOLUTION
E
i+1
=
ml
2
2
_

2
i+1
+
g
l

2
i+1
_
=
ml
2
2
_

2
i+1
+
g
l
_

2
i
+
2
i+1
(t)
2
+ 2
i

i+1
t

_
=
ml
2
2
_

2
i+1
_
1 +
g
l
(t)
2
_
+
g
l

2
i
+
i+1
_
2
g
l

i
t
__
=
ml
2
2
__

2
i
+
_
g
l
_
2

2
i
(t)
2
2
g
l

i

i
t
_
_
1 +
g
l
(t)
2
_
+
g
l

2
i
+ 2
g
l

i
t
_

g
l

i
t
_
_
=
ml
2
2
_

2
i
+
_
g
l
_
2

2
i
(t)
2
2
g
l

i

i
t +
g
l

2
i
(t)
2
+
_
g
l
_
3

2
i
(t)
4
2
_
g
l
_
2

i
(t)
3
_
+
ml
2
2
_
g
l

2
i
+ 2
g
l

i

i
t 2
_
g
l
_
2

2
i
(t)
2
_
=
ml
2
2
_

2
i
+
g
l

2
i
_
+
mgl
2
_

2
i

g
l

2
i
_
(t)
2
+
ml
2
2
_
2
_
g
l
_
2

i
(t)
3
+
_
g
l
_
3

2
i
(t)
4
_
= E
i
+
1
2
mgl
_

2
i

g
l

2
i
_
(t)
2
+ O
_
(t)
3
_
1
2
Program for calculating the total energy of the pendulum at each step (from
Euler and Euler-Cromer method) is shown in Figure 1.
Figure 1- Program for calculating total energy of the pendulum at each step
(from Euler and Euler-Cromer method)
3
The program is run for input values of l = 1m,
0
= 0.2rad, t = 0.04s,
t
max
= 10s and m = 0.1kg. The output for this run in shown in Figure 2. It
shows that total energy in Euler-Cromer method is constant as compared to
that for Euler method. For Euler method, it keeps on increasing with each step.
Figure 2- Output of code in gure 1 for l = 1m,
0
= 0.2rad, t = 0.04s,
t
max
= 10s and m = 0.1kg
However, if the program is run again with t
max
= 4s (keeping the other input
values same), we are able to zoom into the sinusoidal uctuations of the total
energy with time for the Cromer method in Figure 3. These uctuations are
4
small (second graph in Figure 3) and total energy is still conserved over each
complete cycle of the motion.
Figure 3- Output of code in gure 1 for l = 1m,
0
= 0.2rad, t = 0.04s,
t
max
= 4s and m = 0.1kg
Program for computing the error of Euler-Cromer method at various reso-
5
lutions is shown in Figure 4.
Figure 4- Program for calculating Euler-Cromer method error at various
resolutions
The program is run for input values of l = 1m,
0
= 0.2rad, Lowest resolution
time step = 0.1s, Number of resolution renements = 4 and t
max
= 5s. The
output for this run in shown in Figure 5. It shows that each factor of 10 in
renement decreases the error by a factor of 10. So the Euler-Cromer method
6
is a rst-order method.
Figure 5- Output of code in gure 4 for input values of l = 1m,
0
= 0.2rad,
Lowest resolution time step = 0.1s, Number of resolution renements = 4 and
t
max
= 5s
7

Vous aimerez peut-être aussi