我正在寻找编写以下函数的代码:
import numpy as np
import scipy.special as sp
def Legendre(n,x):
x=np.array(x)
if (n==0):`
return x*0+1.0
elif (n==1):
return x
else:
return ((2.0*n-1.0)*x*Legendre(n-1,x)-(n-1)*Legendre(n-2,x))/n
def RealFn(x):
"""
Fuction to evaluate the Real element of Phase Shift
"""
# Test for valid input
if (x<0):
print("Error: x must be non negative");
return
RealFn = (1/(2*k)*(?)(2*l + 1)*np.sin(2*delta)*Legendre(??)*np.cos(x))**2
return RealFn
如果有人可以帮助我编写勒让德多项式和无限和的编码,我将不胜感激!
的价值也是已知的,所以这只是一个简单的输入。
我相信我错过了还。