Nothing Special   »   [go: up one dir, main page]

Special Function Hermite Polinomial 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Special Function(Hermite Polinomial)

15/04/2024

1 Hermite Polinomial
Hermite Differntial equation is given as :

d2 y dy
− 2x + 2ny = 0 (1)
dx2 dx
The solution that sattisfies the above equation is known as Hermite Polinomial.The Rodrigue’s
formula is given as :

2 dn −x2
Hn (x) = (−1)n ex e (2)
dxn
The Orthogonality Condition for Hermite Polinomial is given as:

Z +∞
2
e−x Hm (x).Hn (x)dx = 0 f or n ̸= m (3)
−∞

Z +∞
2
e−x Hm (x).Hn (x)dx = 2n n!
p
(π) f or n=m (4)
−∞

1.1 Program:
1.1.1 Question1.
Verify the Orthogonality relation for Hermite Polinomial.

Source Code:
import numpy as np
import math
import matplotlib.pyplot as plt
from scipy.special import hermite as H
from scipy.integrate import quad

m = int(input('Enter the value m = '))


n = int(input('Enter the value n = '))
def f(x): return np.exp(-x**2)*H(n)(x)*H(m)(x)
x = np.linspace(-10,10,100)

15
LHS = quad(f,-np.inf,np.inf)
if m == n:
RHS = (2**n)*(math.factorial(n)*np.sqrt(np.pi))
else:
RHS = 0
print('LHS = ',LHS[0],'RHS = ',RHS)
if abs(LHS[0] - RHS)<0.01:
print('The Orthogonality relation of Legendre plinomial is verified')
else:
print('Not Verified')

Enter the value m = 3


Enter the value n = 3
LHS = 85.07778484346483 RHS = 85.07778484346477
The Orthogonality relation of Legendre plinomial is verified

1.1.2 Question 2.
Verify the following recurrence relation for Hermite Polinomial.

Hn+1 (x) = 2xHn (x) − 2nHn−1 (x)

Source Code:
[22]: #Recurrence relation for Hermite Polinomial 2nd

from numpy import*


from scipy.special import hermite as h
from matplotlib.pyplot import*
x=linspace(-1,1,50)
n= int(input ())
LHS= h(n+1)(x)
RHS = 2*x*h(n)(x) -2*n*h(n-1)(x)
plot(x, LHS, '-', label = 'LHS', color='black')
plot(x, RHS, '*', label = 'RHS', color='black')
legend()
xlabel('position(x)')
ylabel('$H\'_{n+1}(x)$')
grid()
title('Verifying the Recurrence relation for Hermite Polynomial: \n␣
,→$H\'_{n+1}(x) = 2xH_{n}(x)-2nH_{n-1}(x)$')

plot()

16
1.1.3 Question 3.
Consider the wavefunction of 1D Harmonic Oscillator:
 1/4  2
1 1 −x
ψn (x) = p exp Hn (x)
(2n n!) π 2


Where Hn (x) is the Hermite polinomial and we consider = 1.Plot the wavefunction for n = 0,

1 and 2 in a single graph.

Source Code:
[23]: import numpy as np
import math
import matplotlib.pyplot as plt
from scipy.special import hermite as H
from scipy.integrate import quad
def psi(n,x):
return 1/np.sqrt((2**n)*math.factorial(n))*(1/np.pi)**(1/4)*np.exp(-x**2/
,→2)*H(n)(x)

x = np.linspace(-5,5,100)
n = np.array([0,1,2])
for i in n:
plt.plot(x,psi(i,x),linestyle=(0,(2,i*i)), label =r'$\psi_n(x) \;
,→at\quadn=%f$'%i, color = 'black')

plt.legend(bbox_to_anchor=(1.00, 1),ncol=1)
plt.grid()
plt.title(r'Plot of $\psi_n(x)$ for n = 0,1,2')

17
plt.ylabel(r'$\psi_n(x)$')
plt.xlabel('Position(x)')
plt.axhline(y=0, linestyle='-')
plt.show()

18

You might also like