Professional Documents
Culture Documents
Aarav Ratra
Enrolment no. 21122002
August 31, 2023
1 Problem 1:
For a simple pendulum, with the motion not restricted to small amplitudes, the time period can
be expressed as
s
l dθ
Z θ0
T=4 √
2g 0 cosθ − cosθ0
(1)
where θ0 is the amplitude at t = 0. This integration can be converted into another form by using
sin θ/2
sin θ20 = γ and sin θ0 /2 = sin η
s
l dη
Z π/2
T=4 p
2g 0 1 − γ2 sin2 η
(2)
1. From Eq. (2), calculate the period of the simple pendulum using different types of integra-
tion methods and compare the results.
2. Take different values of the amplitude θ0 form small to large values (atleast 10 values) and
calculate the time periods.
3. Plot the graph between the amplitudes and time periods.
4. Find the physical significance of the results.
1.1 Method:
We can use the methods discussed in the previous assignment
1. Trapezoidal Rule
2. Simpson’s 1/3rd rule
We use the function definitions used last time for the former two, and use a similar approach for
Monte-Carlo.
We shall display the result for 10 values of theta0 , varying from values close to 0 to those close to
π/2.
1
We shall demonstrate the plot for variation in time period with respect to θ0 .
1.2 Program:
gamma = np.sin(theta_0/2)
def func(eta):
return integrand(gamma,eta)
a = 0
b = np.pi/2
T = 4*sqrt(0.5*l/g)*integral_method(func,a,b,1000)
2
return T
[144]: #Solving for the following values and printing results: Simpson's and␣
,→Trapezoidal Method
g = 9.8
l = 2*9.8
#We need to find maximum permissible value of Theta_0 such that we do not␣
,→encounter sqrt error
3
#we need so
Amps_ = np.linspace(0,1.1,1000+1)
Simps = []
Traps = []
Simps = np.array(Simps)
Traps = np.array(Traps)
[146]: plt.plot(Amps_,Simps)
plt.plot(Amps_,Traps)
[147]: plt.plot(Amps_,Traps-Simps)
4
1.3 Results and Discussion
Both the methods give a similar result and the difference in results appears to be minimal. The
methods deviate initially but later they converge to a similar value.
It can be observed
q that the time period, infact, increases for larger values of amplitude θ0 , and it is
l
equal to 2π g for the limiting case of θ0 → 0.
2 Problem 2:
Consider a quantum harmonic oscillator in the first excited state described by the wave function
2
ψ( x ) = xe− x /2 . Normalize this wave function using the Monte Carlo integration method.
2.1 Method:
(x) We use Monte-Carlo’s method to find the area under the curve for the function |ψ( x )|2 .
However, since our range of x is from −∞ to ∞, we use the following result:
Z ∞
t2 + 1
Z 1
t
f ( x )dx = f( ) dt
−∞ −1 1 − t2 ( t2 − 1)2
5
2.2 Program:
def psi_2(x):
return x**2 * exp(-x**2)
def f_t(t):
if np.abs(t) == 1:
val = 0
else:
t1 = (t*t+1)
t2 = (t*t-1)*(t*t-1)
arg = t/((-t*t+1))
val = psi_2(arg)*t1/t2
return val
mval = 2
def point_in(xy):
return int(xy[1] <= f_t(xy[0]) )
def integral(n):
per = sum(point_in(i) for i in points(n))/n
integral_ = 4*per
return integral_
6
| 10$ˆ 5 $ | 0.87504 |
| 10$ˆ 6 $ | 0.886696 |
[149]: sqrt(np.pi)/2
[149]: 0.8862269254527579
√
π
Which is pretty close to the true value, which is supposed to be equal to 2 .
This proves that more the number of points, the more accurate our integral will be.