Пример #1
0
 def as_real_imag(self, deep=True, **hints):
     # TODO: Handle deep and hints
     n, m, theta, phi = self.args
     re = (sqrt((2*n + 1)/(4*pi) * C.factorial(n - m)/C.factorial(n + m)) *
           C.cos(m*phi) * assoc_legendre(n, m, C.cos(theta)))
     im = (sqrt((2*n + 1)/(4*pi) * C.factorial(n - m)/C.factorial(n + m)) *
           C.sin(m*phi) * assoc_legendre(n, m, C.cos(theta)))
     return (re, im)
Пример #2
0
 def _eval_expand_func(self, **hints):
     n, m, theta, phi = self.args
     rv = (sqrt(
         (2 * n + 1) / (4 * pi) * factorial(n - m) / factorial(n + m)) *
           exp(I * m * phi) * assoc_legendre(n, m, cos(theta)))
     # We can do this because of the range of theta
     return rv.subs(sqrt(-cos(theta)**2 + 1), sin(theta))
Пример #3
0
def bp(nu, theta, phi, sigma, l, sigmap, lp, i_n, i, delta):
    return (b(l, lp, i_n, i, delta, nu) * legendre(nu, cos(theta)) +
            1/(1 + delta**2) * cos(2 * phi) * assoc_legendre(nu, 2, cos(theta)) *
            (f(l, l, i_n, i, nu) * (-1)**sigma * kappa(nu, l, l) +
             (-1)**(l + lp) * 2 * delta * f(l, lp, i_n, i, nu) *
             (-1)**sigmap * kappa(nu, l, lp) +
             delta**2 * f(lp, lp, i_n, i, nu) *
             (-1)**sigmap * kappa(nu, lp, lp)))
Пример #4
0
 def _eval_expand_func(self, **hints):
     n, m, theta, phi = self.args
     rv = (
         sqrt((2 * n + 1) / (4 * pi) * C.factorial(n - m) / C.factorial(n + m))
         * C.exp(I * m * phi)
         * assoc_legendre(n, m, C.cos(theta))
     )
     # We can do this because of the range of theta
     return rv.subs(sqrt(-cos(theta) ** 2 + 1), sin(theta))
Пример #5
0
def test_special_polynomials():
    assert mcode(hermite(x, y)) == "HermiteH[x, y]"
    assert mcode(laguerre(x, y)) == "LaguerreL[x, y]"
    assert mcode(assoc_laguerre(x, y, z)) == "LaguerreL[x, y, z]"
    assert mcode(jacobi(x, y, z, w)) == "JacobiP[x, y, z, w]"
    assert mcode(gegenbauer(x, y, z)) == "GegenbauerC[x, y, z]"
    assert mcode(chebyshevt(x, y)) == "ChebyshevT[x, y]"
    assert mcode(chebyshevu(x, y)) == "ChebyshevU[x, y]"
    assert mcode(legendre(x, y)) == "LegendreP[x, y]"
    assert mcode(assoc_legendre(x, y, z)) == "LegendreP[x, y, z]"
Пример #6
0
 def _eval_expand_func(self, **hints):
     n, m, theta, phi = self.args
     return (sqrt(
         (2 * n + 1) / (4 * pi) * C.factorial(n - m) / C.factorial(n + m)) *
             C.exp(I * m * phi) * assoc_legendre(n, m, C.cos(theta)))
 def _eval_expand_func(self, **hints):
     n, m, theta, phi = self.args
     return (sqrt((2*n + 1)/(4*pi) * C.factorial(n - m)/C.factorial(n + m)) *
             C.exp(I*m*phi) * assoc_legendre(n, m, C.cos(theta)))