本文整理汇总了Python中sympy.assoc_legendre函数的典型用法代码示例。如果您正苦于以下问题:Python assoc_legendre函数的具体用法?Python assoc_legendre怎么用?Python assoc_legendre使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assoc_legendre函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_jacobi
def test_jacobi():
n = Symbol("n")
a = Symbol("a")
b = Symbol("b")
assert jacobi(0, a, b, x) == 1
assert jacobi(1, a, b, x) == a/2 - b/2 + x*(a/2 + b/2 + 1)
assert jacobi(n, a, a, x) == RisingFactorial(a + 1, n)*gegenbauer(n, a + S(1)/2, x)/RisingFactorial(2*a + 1, n)
assert jacobi(n, a, -a, x) == ((-1)**a*(-x + 1)**(-a/2)*(x + 1)**(a/2)*assoc_legendre(n, a, x)*
factorial(-a + n)*gamma(a + n + 1)/(factorial(a + n)*gamma(n + 1)))
assert jacobi(n, -b, b, x) == ((-x + 1)**(b/2)*(x + 1)**(-b/2)*assoc_legendre(n, b, x)*
gamma(-b + n + 1)/gamma(n + 1))
assert jacobi(n, 0, 0, x) == legendre(n, x)
assert jacobi(n, S.Half, S.Half, x) == RisingFactorial(S(3)/2, n)*chebyshevu(n, x)/factorial(n + 1)
assert jacobi(n, -S.Half, -S.Half, x) == RisingFactorial(S(1)/2, n)*chebyshevt(n, x)/factorial(n)
X = jacobi(n, a, b, x)
assert isinstance(X, jacobi)
assert jacobi(n, a, b, -x) == (-1)**n*jacobi(n, b, a, x)
assert jacobi(n, a, b, 0) == 2**(-n)*gamma(a + n + 1)*hyper((-b - n, -n), (a + 1,), -1)/(factorial(n)*gamma(a + 1))
assert jacobi(n, a, b, 1) == RisingFactorial(a + 1, n)/factorial(n)
m = Symbol("m", positive=True)
assert jacobi(m, a, b, oo) == oo*RisingFactorial(a + b + m + 1, m)
assert conjugate(jacobi(m, a, b, x)) == jacobi(m, conjugate(a), conjugate(b), conjugate(x))
assert diff(jacobi(n,a,b,x), n) == Derivative(jacobi(n, a, b, x), n)
assert diff(jacobi(n,a,b,x), x) == (a/2 + b/2 + n/2 + S(1)/2)*jacobi(n - 1, a + 1, b + 1, x)
示例2: semiNormalizedSH_genericNumpy
def semiNormalizedSH_genericNumpy(e, a, target=None) :
"""
Returns the value of the sh components at the specified orientation.
Version based on the generic formula, using sympy just for legendre.
"""
x,y,z = ead2xyz(e, a, 1)
sn3d = np.zeros((order+1,order+1)) if target is None else target
from sympy import factorial, sqrt, S
import sympy as sp
ra = math.radians(a)
for l in xrange(order+1) :
for m in xrange(-l,l+1) :
absm = abs(m)
factor = math.sqrt(2) if m else 1.
sn3d[shi(l,m)] = (factor
/ math.sqrt(
# sp.factorial(l+absm) / sp.factorial(l-absm) # clearest for the next one
np.prod(xrange(l-absm+1, l+absm+1))
)
* ( sp.assoc_legendre(l,absm,z) * S(-1)**m ).evalf()
* ( np.cos(m*ra) if m>=0 else np.sin(absm*ra) )
)
return sn3d
示例3: get_norm_p
def get_norm_p(n, m, t):
pnm = sympy.assoc_legendre(n, m, t)
if m == 0:
j = 1
if m != 0:
j = 2
p1 = j * (2.0 * n + 1.0)
p2 = float(mt.factorial(n-m))
p3 = float(mt.factorial(n+m))
p4 = p2/p3
return (np.sqrt(p1 * p4)) * pnm
示例4: _get_Ylm
def _get_Ylm(self, l, m):
"""
Compute an expression for spherical harmonic of order (l,m)
in terms of Cartesian unit vectors, :math:`\hat{z}`
and :math:`\hat{x} + i \hat{y}`
Parameters
----------
l : int
the degree of the harmonic
m : int
the order of the harmonic; |m| < l
Returns
-------
expr :
a sympy expression that corresponds to the
requested Ylm
References
----------
https://en.wikipedia.org/wiki/Spherical_harmonics
"""
import sympy as sp
# the relevant cartesian and spherical symbols
x, y, z, r = sp.symbols('x y z r', real=True, positive=True)
xhat, yhat, zhat = sp.symbols('xhat yhat zhat', real=True, positive=True)
xpyhat = sp.Symbol('xpyhat', complex=True)
phi, theta = sp.symbols('phi theta')
defs = [(sp.sin(phi), y/sp.sqrt(x**2+y**2)),
(sp.cos(phi), x/sp.sqrt(x**2+y**2)),
(sp.cos(theta), z/sp.sqrt(x**2 + y**2 + z**2))
]
# the cos(theta) dependence encoded by the associated Legendre poly
expr = sp.assoc_legendre(l, m, sp.cos(theta))
# the exp(i*m*phi) dependence
expr *= sp.expand_trig(sp.cos(m*phi)) + sp.I*sp.expand_trig(sp.sin(m*phi))
# simplifying optimizations
expr = sp.together(expr.subs(defs)).subs(x**2 + y**2 + z**2, r**2)
expr = expr.expand().subs([(x/r, xhat), (y/r, yhat), (z/r, zhat)])
expr = expr.factor().factor(extension=[sp.I]).subs(xhat+sp.I*yhat, xpyhat)
expr = expr.subs(xhat**2 + yhat**2, 1-zhat**2).factor()
# and finally add the normalization
amp = sp.sqrt((2*l+1) / (4*numpy.pi) * sp.factorial(l-m) / sp.factorial(l+m))
expr *= amp
return expr
示例5: test_assoc_legendre
def test_assoc_legendre():
Plm = assoc_legendre
Q = sqrt(1 - x**2)
assert Plm(0, 0, x) == 1
assert Plm(1, 0, x) == x
assert Plm(1, 1, x) == -Q
assert Plm(2, 0, x) == (3*x**2 - 1)/2
assert Plm(2, 1, x) == -3*x*Q
assert Plm(2, 2, x) == 3*Q**2
assert Plm(3, 0, x) == (5*x**3 - 3*x)/2
assert Plm(3, 1, x).expand() == (( 3*(1 - 5*x**2)/2 ).expand() * Q).expand()
assert Plm(3, 2, x) == 15*x * Q**2
assert Plm(3, 3, x) == -15 * Q**3
# negative m
assert Plm(1, -1, x) == -Plm(1, 1, x)/2
assert Plm(2, -2, x) == Plm(2, 2, x)/24
assert Plm(2, -1, x) == -Plm(2, 1, x)/6
assert Plm(3, -3, x) == -Plm(3, 3, x)/720
assert Plm(3, -2, x) == Plm(3, 2, x)/120
assert Plm(3, -1, x) == -Plm(3, 1, x)/12
n = Symbol("n")
m = Symbol("m")
X = Plm(n, m, x)
assert isinstance(X, assoc_legendre)
assert Plm(n, 0, x) == legendre(n, x)
raises(ValueError, lambda: Plm(-1, 0, x))
raises(ValueError, lambda: Plm(0, 1, x))
assert conjugate(assoc_legendre(n, m, x)) == \
assoc_legendre(n, conjugate(m), conjugate(x))
示例6: getSphericalFunc
def getSphericalFunc(self, l, m):
if m < 0:
m = abs(m)
fac = sin(m*theta)
else:
fac = cos(m*theta)
P = assoc_legendre(l, m, cos(phi))
res = fac*P
res = self.sphere2Cart(trigsimp(res))
#Takes care of Abs when the argument is real..
res = res.subs(r2d, r_2d).subs(r3d, r).subs(r, r3d).subs(r_2d, r2d)
return res;
示例7: sphericalHarmonic
def sphericalHarmonic(l,n) :
"""Returns an evaluator for the seminormalized real spherical harmonic
of order l, degree n as defined in:
http://ambisonics.iem.at/xchange/format/ambisonics-xchange-format-appendix
"""
import sympy
sign = -1 if n<0 else +1
n = abs(n)
x,y=sympy.var("x y")
f= sympy.powsimp(sympy.trigsimp(
sympy.assoc_legendre(l,n,sympy.sin(x)) *
(-1)**n *
sympy.sqrt((2*l+1) *
(1 if n==0 else 2) *
sympy.factorial(l-n)/sympy.factorial(l+n)) *
(sympy.cos(n*y) if sign>=0 else sympy.sin(n*y))
))
return SympyEvaluator(f,x,y)
示例8: test_latex_functions
def test_latex_functions():
assert latex(exp(x)) == "e^{x}"
assert latex(exp(1) + exp(2)) == "e + e^{2}"
f = Function("f")
assert latex(f(x)) == "\\operatorname{f}{\\left (x \\right )}"
beta = Function("beta")
assert latex(beta(x)) == r"\beta{\left (x \right )}"
assert latex(sin(x)) == r"\sin{\left (x \right )}"
assert latex(sin(x), fold_func_brackets=True) == r"\sin {x}"
assert latex(sin(2 * x ** 2), fold_func_brackets=True) == r"\sin {2 x^{2}}"
assert latex(sin(x ** 2), fold_func_brackets=True) == r"\sin {x^{2}}"
assert latex(asin(x) ** 2) == r"\operatorname{asin}^{2}{\left (x \right )}"
assert latex(asin(x) ** 2, inv_trig_style="full") == r"\arcsin^{2}{\left (x \right )}"
assert latex(asin(x) ** 2, inv_trig_style="power") == r"\sin^{-1}{\left (x \right )}^{2}"
assert latex(asin(x ** 2), inv_trig_style="power", fold_func_brackets=True) == r"\sin^{-1} {x^{2}}"
assert latex(factorial(k)) == r"k!"
assert latex(factorial(-k)) == r"\left(- k\right)!"
assert latex(subfactorial(k)) == r"!k"
assert latex(subfactorial(-k)) == r"!\left(- k\right)"
assert latex(factorial2(k)) == r"k!!"
assert latex(factorial2(-k)) == r"\left(- k\right)!!"
assert latex(binomial(2, k)) == r"{\binom{2}{k}}"
assert latex(FallingFactorial(3, k)) == r"{\left(3\right)}_{\left(k\right)}"
assert latex(RisingFactorial(3, k)) == r"{\left(3\right)}^{\left(k\right)}"
assert latex(floor(x)) == r"\lfloor{x}\rfloor"
assert latex(ceiling(x)) == r"\lceil{x}\rceil"
assert latex(Min(x, 2, x ** 3)) == r"\min\left(2, x, x^{3}\right)"
assert latex(Min(x, y) ** 2) == r"\min\left(x, y\right)^{2}"
assert latex(Max(x, 2, x ** 3)) == r"\max\left(2, x, x^{3}\right)"
assert latex(Max(x, y) ** 2) == r"\max\left(x, y\right)^{2}"
assert latex(Abs(x)) == r"\lvert{x}\rvert"
assert latex(re(x)) == r"\Re{x}"
assert latex(re(x + y)) == r"\Re{x} + \Re{y}"
assert latex(im(x)) == r"\Im{x}"
assert latex(conjugate(x)) == r"\overline{x}"
assert latex(gamma(x)) == r"\Gamma\left(x\right)"
assert latex(Order(x)) == r"\mathcal{O}\left(x\right)"
assert latex(lowergamma(x, y)) == r"\gamma\left(x, y\right)"
assert latex(uppergamma(x, y)) == r"\Gamma\left(x, y\right)"
assert latex(cot(x)) == r"\cot{\left (x \right )}"
assert latex(coth(x)) == r"\coth{\left (x \right )}"
assert latex(re(x)) == r"\Re{x}"
assert latex(im(x)) == r"\Im{x}"
assert latex(root(x, y)) == r"x^{\frac{1}{y}}"
assert latex(arg(x)) == r"\arg{\left (x \right )}"
assert latex(zeta(x)) == r"\zeta\left(x\right)"
assert latex(zeta(x)) == r"\zeta\left(x\right)"
assert latex(zeta(x) ** 2) == r"\zeta^{2}\left(x\right)"
assert latex(zeta(x, y)) == r"\zeta\left(x, y\right)"
assert latex(zeta(x, y) ** 2) == r"\zeta^{2}\left(x, y\right)"
assert latex(dirichlet_eta(x)) == r"\eta\left(x\right)"
assert latex(dirichlet_eta(x) ** 2) == r"\eta^{2}\left(x\right)"
assert latex(polylog(x, y)) == r"\operatorname{Li}_{x}\left(y\right)"
assert latex(polylog(x, y) ** 2) == r"\operatorname{Li}_{x}^{2}\left(y\right)"
assert latex(lerchphi(x, y, n)) == r"\Phi\left(x, y, n\right)"
assert latex(lerchphi(x, y, n) ** 2) == r"\Phi^{2}\left(x, y, n\right)"
assert latex(Ei(x)) == r"\operatorname{Ei}{\left (x \right )}"
assert latex(Ei(x) ** 2) == r"\operatorname{Ei}^{2}{\left (x \right )}"
assert latex(expint(x, y) ** 2) == r"\operatorname{E}_{x}^{2}\left(y\right)"
assert latex(Shi(x) ** 2) == r"\operatorname{Shi}^{2}{\left (x \right )}"
assert latex(Si(x) ** 2) == r"\operatorname{Si}^{2}{\left (x \right )}"
assert latex(Ci(x) ** 2) == r"\operatorname{Ci}^{2}{\left (x \right )}"
assert latex(Chi(x) ** 2) == r"\operatorname{Chi}^{2}{\left (x \right )}"
assert latex(jacobi(n, a, b, x)) == r"P_{n}^{\left(a,b\right)}\left(x\right)"
assert latex(jacobi(n, a, b, x) ** 2) == r"\left(P_{n}^{\left(a,b\right)}\left(x\right)\right)^{2}"
assert latex(gegenbauer(n, a, x)) == r"C_{n}^{\left(a\right)}\left(x\right)"
assert latex(gegenbauer(n, a, x) ** 2) == r"\left(C_{n}^{\left(a\right)}\left(x\right)\right)^{2}"
assert latex(chebyshevt(n, x)) == r"T_{n}\left(x\right)"
assert latex(chebyshevt(n, x) ** 2) == r"\left(T_{n}\left(x\right)\right)^{2}"
assert latex(chebyshevu(n, x)) == r"U_{n}\left(x\right)"
assert latex(chebyshevu(n, x) ** 2) == r"\left(U_{n}\left(x\right)\right)^{2}"
assert latex(legendre(n, x)) == r"P_{n}\left(x\right)"
assert latex(legendre(n, x) ** 2) == r"\left(P_{n}\left(x\right)\right)^{2}"
assert latex(assoc_legendre(n, a, x)) == r"P_{n}^{\left(a\right)}\left(x\right)"
assert latex(assoc_legendre(n, a, x) ** 2) == r"\left(P_{n}^{\left(a\right)}\left(x\right)\right)^{2}"
assert latex(laguerre(n, x)) == r"L_{n}\left(x\right)"
assert latex(laguerre(n, x) ** 2) == r"\left(L_{n}\left(x\right)\right)^{2}"
assert latex(assoc_laguerre(n, a, x)) == r"L_{n}^{\left(a\right)}\left(x\right)"
assert latex(assoc_laguerre(n, a, x) ** 2) == r"\left(L_{n}^{\left(a\right)}\left(x\right)\right)^{2}"
assert latex(hermite(n, x)) == r"H_{n}\left(x\right)"
assert latex(hermite(n, x) ** 2) == r"\left(H_{n}\left(x\right)\right)^{2}"
# Test latex printing of function names with "_"
assert latex(polar_lift(0)) == r"\operatorname{polar\_lift}{\left (0 \right )}"
assert latex(polar_lift(0) ** 3) == r"\operatorname{polar\_lift}^{3}{\left (0 \right )}"
示例9: acustic_sh
def acustic_sh(l,m,a,z) :
am = numpy.abs(m)
if m<0 :
return sh_normalization(l,am) * sympy.sin(am*a) * sympy.assoc_legendre(l,am,sympy.cos(z))
else:
return sh_normalization(l,am) * sympy.cos(am*a) * sympy.assoc_legendre(l,am,sympy.cos(z))
示例10: xrange
a0, z0 = 0, numpy.pi/2
epsilon = a*1e-15 + z*1e-15
order = 5
nSamples = 70
angles = numpy.arange(0,nSamples+1)*2*numpy.pi/nSamples
w = 2*math.pi*spectralRange/spectrumBins * numpy.arange(spectrumBins)
if False:
print "Checking that the azimuthal formula is equivalent to the zenital formula"
for l in xrange(0,order+1) :
# pattern1 = sum([sh_normalization2(l,m)*sympy.assoc_legendre(l,m,sympy.cos(z))*sympy.assoc_legendre(l,m,1) for m in xrange(0,l+1)])
# pattern1 = sh_normalization2(l,0)*sympy.assoc_legendre(l,0,sympy.cos(z))
pattern1 = sh_normalization2(l,0)*sympy.legendre(l,sympy.cos(z))
pylab.polar(angles, [ pattern1.subs(z,angle)/(2*l+1) for angle in angles ], label="Zenital %s"%l)
pattern2 = sum([sh_normalization2(l,m)*sympy.cos(m*z)*sympy.assoc_legendre(l,m,0)**2 for m in xrange(0,l+1)])
pylab.polar(angles, [ pattern2.subs(z,angle)/(2*l+1) for angle in angles ], label="Azimuthal %s"%l)
pylab.title("Zenital vs Azimuthal variation",horizontalalignment='center', verticalalignment='baseline', position=(.5,-.1))
pylab.rgrids(numpy.arange(.4,1,.2),angle=220)
pylab.legend(loc=2)
pylab.savefig(figurePath(__file__,"pdf"))
pylab.show()
# We take the azimuthal formula which is faster
print "Computing component patterns"
patternComponents = [
sh_normalization2(l,0)*sympy.legendre(l,sympy.cos(z))
for l in xrange(0,order+1)
]
for l, pattern in enumerate(patternComponents) :
print "%i:"%l, pattern
示例11: test_J11
def test_J11():
assert simplify(assoc_legendre(3, 1, x)) == simplify(-R(3, 2)*sqrt(1 - x**2)*(5*x**2 - 1))
示例12: test_J10
def test_J10():
mu, nu = symbols('mu, nu', integer=True)
assert assoc_legendre(nu, mu, 0) == 2**mu*sqrt(pi)/gamma((nu - mu)/2 + 1)/gamma((-nu - mu + 1)/2)
示例13: get_p
def get_p(n, m, t):
return sympy.assoc_legendre(n, m, t)
示例14: test_latex_functions
#.........这里部分代码省略.........
assert latex(Min(x, y)**2) == r"\min\left(x, y\right)^{2}"
assert latex(Max(x, 2, x**3)) == r"\max\left(2, x, x^{3}\right)"
assert latex(Max(x, y)**2) == r"\max\left(x, y\right)^{2}"
assert latex(Abs(x)) == r"\left\lvert{x}\right\rvert"
assert latex(re(x)) == r"\Re{x}"
assert latex(re(x + y)) == r"\Re{x} + \Re{y}"
assert latex(im(x)) == r"\Im{x}"
assert latex(conjugate(x)) == r"\overline{x}"
assert latex(gamma(x)) == r"\Gamma\left(x\right)"
assert latex(Order(x)) == r"\mathcal{O}\left(x\right)"
assert latex(lowergamma(x, y)) == r'\gamma\left(x, y\right)'
assert latex(uppergamma(x, y)) == r'\Gamma\left(x, y\right)'
assert latex(cot(x)) == r'\cot{\left (x \right )}'
assert latex(coth(x)) == r'\coth{\left (x \right )}'
assert latex(re(x)) == r'\Re{x}'
assert latex(im(x)) == r'\Im{x}'
assert latex(root(x, y)) == r'x^{\frac{1}{y}}'
assert latex(arg(x)) == r'\arg{\left (x \right )}'
assert latex(zeta(x)) == r'\zeta\left(x\right)'
assert latex(zeta(x)) == r"\zeta\left(x\right)"
assert latex(zeta(x)**2) == r"\zeta^{2}\left(x\right)"
assert latex(zeta(x, y)) == r"\zeta\left(x, y\right)"
assert latex(zeta(x, y)**2) == r"\zeta^{2}\left(x, y\right)"
assert latex(dirichlet_eta(x)) == r"\eta\left(x\right)"
assert latex(dirichlet_eta(x)**2) == r"\eta^{2}\left(x\right)"
assert latex(polylog(x, y)) == r"\operatorname{Li}_{x}\left(y\right)"
assert latex(
polylog(x, y)**2) == r"\operatorname{Li}_{x}^{2}\left(y\right)"
assert latex(lerchphi(x, y, n)) == r"\Phi\left(x, y, n\right)"
assert latex(lerchphi(x, y, n)**2) == r"\Phi^{2}\left(x, y, n\right)"
assert latex(elliptic_k(z)) == r"K\left(z\right)"
assert latex(elliptic_k(z)**2) == r"K^{2}\left(z\right)"
assert latex(elliptic_f(x, y)) == r"F\left(x\middle| y\right)"
assert latex(elliptic_f(x, y)**2) == r"F^{2}\left(x\middle| y\right)"
assert latex(elliptic_e(x, y)) == r"E\left(x\middle| y\right)"
assert latex(elliptic_e(x, y)**2) == r"E^{2}\left(x\middle| y\right)"
assert latex(elliptic_e(z)) == r"E\left(z\right)"
assert latex(elliptic_e(z)**2) == r"E^{2}\left(z\right)"
assert latex(elliptic_pi(x, y, z)) == r"\Pi\left(x; y\middle| z\right)"
assert latex(elliptic_pi(x, y, z)**2) == \
r"\Pi^{2}\left(x; y\middle| z\right)"
assert latex(elliptic_pi(x, y)) == r"\Pi\left(x\middle| y\right)"
assert latex(elliptic_pi(x, y)**2) == r"\Pi^{2}\left(x\middle| y\right)"
assert latex(Ei(x)) == r'\operatorname{Ei}{\left (x \right )}'
assert latex(Ei(x)**2) == r'\operatorname{Ei}^{2}{\left (x \right )}'
assert latex(expint(x, y)**2) == r'\operatorname{E}_{x}^{2}\left(y\right)'
assert latex(Shi(x)**2) == r'\operatorname{Shi}^{2}{\left (x \right )}'
assert latex(Si(x)**2) == r'\operatorname{Si}^{2}{\left (x \right )}'
assert latex(Ci(x)**2) == r'\operatorname{Ci}^{2}{\left (x \right )}'
assert latex(Chi(x)**2) == r'\operatorname{Chi}^{2}{\left (x \right )}', latex(Chi(x)**2)
assert latex(
jacobi(n, a, b, x)) == r'P_{n}^{\left(a,b\right)}\left(x\right)'
assert latex(jacobi(n, a, b, x)**2) == r'\left(P_{n}^{\left(a,b\right)}\left(x\right)\right)^{2}'
assert latex(
gegenbauer(n, a, x)) == r'C_{n}^{\left(a\right)}\left(x\right)'
assert latex(gegenbauer(n, a, x)**2) == r'\left(C_{n}^{\left(a\right)}\left(x\right)\right)^{2}'
assert latex(chebyshevt(n, x)) == r'T_{n}\left(x\right)'
assert latex(
chebyshevt(n, x)**2) == r'\left(T_{n}\left(x\right)\right)^{2}'
assert latex(chebyshevu(n, x)) == r'U_{n}\left(x\right)'
assert latex(
chebyshevu(n, x)**2) == r'\left(U_{n}\left(x\right)\right)^{2}'
assert latex(legendre(n, x)) == r'P_{n}\left(x\right)'
assert latex(legendre(n, x)**2) == r'\left(P_{n}\left(x\right)\right)^{2}'
assert latex(
assoc_legendre(n, a, x)) == r'P_{n}^{\left(a\right)}\left(x\right)'
assert latex(assoc_legendre(n, a, x)**2) == r'\left(P_{n}^{\left(a\right)}\left(x\right)\right)^{2}'
assert latex(laguerre(n, x)) == r'L_{n}\left(x\right)'
assert latex(laguerre(n, x)**2) == r'\left(L_{n}\left(x\right)\right)^{2}'
assert latex(
assoc_laguerre(n, a, x)) == r'L_{n}^{\left(a\right)}\left(x\right)'
assert latex(assoc_laguerre(n, a, x)**2) == r'\left(L_{n}^{\left(a\right)}\left(x\right)\right)^{2}'
assert latex(hermite(n, x)) == r'H_{n}\left(x\right)'
assert latex(hermite(n, x)**2) == r'\left(H_{n}\left(x\right)\right)^{2}'
theta = Symbol("theta", real=True)
phi = Symbol("phi", real=True)
assert latex(Ynm(n,m,theta,phi)) == r'Y_{n}^{m}\left(\theta,\phi\right)'
assert latex(Ynm(n, m, theta, phi)**3) == r'\left(Y_{n}^{m}\left(\theta,\phi\right)\right)^{3}'
assert latex(Znm(n,m,theta,phi)) == r'Z_{n}^{m}\left(\theta,\phi\right)'
assert latex(Znm(n, m, theta, phi)**3) == r'\left(Z_{n}^{m}\left(\theta,\phi\right)\right)^{3}'
# Test latex printing of function names with "_"
assert latex(
polar_lift(0)) == r"\operatorname{polar\_lift}{\left (0 \right )}"
assert latex(polar_lift(
0)**3) == r"\operatorname{polar\_lift}^{3}{\left (0 \right )}"
assert latex(totient(n)) == r'\phi\left( n \right)'
# some unknown function name should get rendered with \operatorname
fjlkd = Function('fjlkd')
assert latex(fjlkd(x)) == r'\operatorname{fjlkd}{\left (x \right )}'
# even when it is referred to without an argument
assert latex(fjlkd) == r'\operatorname{fjlkd}'
示例15: test_J11
def test_J11():
assert assoc_legendre(3,1,x) == sqrt(1 - x**2)*(R(3,2) - R(15,2)*x**2)