# Q 3B
import numpy as np
from scipy.special import legendre
from scipy.integrate import quad
# 1. for m = n (= 6,say)
m=6
n=6
f1 = legendre(m) * legendre(n)
y = quad(f1, -1, 1)
print("\nIntegral Pm * Pn for m = n = 6 is:",y[0]) # Verifying that integral of P(m)*P(n) from -infinity to +infinity for m=n equals 2/(2m+1)
print("2/(2m + 1); m = 6 is = " ,2/(2*m + 1))
# 2. for m != n
m = 3
n = 2
f2 = legendre(m) * legendre(n)
y2 = quad(f2, -1, 1) # Verifying that integral of P(m)*P(n) from -infinity to +infinity for m!=n equals 0
print("\nIntegral Pm * Pn for m not = n is:",y2[0])
Comments
Post a Comment