def test_manualintegrate_orthogonal_poly(): n = symbols('n') a, b = 7, Rational(5, 3) polys = [jacobi(n, a, b, x), gegenbauer(n, a, x), chebyshevt(n, x), chebyshevu(n, x), legendre(n, x), hermite(n, x), laguerre(n, x), assoc_laguerre(n, a, x)] for p in polys: integral = manualintegrate(p, x) for deg in [-2, -1, 0, 1, 3, 5, 8]: # some accept negative "degree", some do not try: p_subbed = p.subs(n, deg) except ValueError: continue assert (integral.subs(n, deg).diff(x) - p_subbed).expand() == 0 # can also integrate simple expressions with these polynomials q = x*p.subs(x, 2*x + 1) integral = manualintegrate(q, x) for deg in [2, 4, 7]: assert (integral.subs(n, deg).diff(x) - q.subs(n, deg)).expand() == 0 # cannot integrate with respect to any other parameter t = symbols('t') for i in range(len(p.args) - 1): new_args = list(p.args) new_args[i] = t assert isinstance(manualintegrate(p.func(*new_args), t), Integral)
def test_sympy__functions__special__polynomials__hermite(): from sympy.functions.special.polynomials import hermite assert _test_args(hermite(x, 2))
def test_hermite(): assert hermite(0, x) == 1 assert hermite(1, x) == 2 * x assert hermite(2, x) == 4 * x**2 - 2 assert hermite(3, x) == 8 * x**3 - 12 * x assert hermite(4, x) == 16 * x**4 - 48 * x**2 + 12 assert hermite(6, x) == 64 * x**6 - 480 * x**4 + 720 * x**2 - 120 n = Symbol("n") assert unchanged(hermite, n, x) assert hermite(n, -x) == (-1)**n * hermite(n, x) assert unchanged(hermite, -n, x) assert hermite(n, 0) == 2**n * sqrt(pi) / gamma(S.Half - n / 2) assert hermite(n, oo) is oo assert conjugate(hermite(n, x)) == hermite(n, conjugate(x)) _k = Dummy('k') assert hermite(n, x).rewrite("polynomial").dummy_eq( factorial(n) * Sum((-1)**_k * (2 * x)**(-2 * _k + n) / (factorial(_k) * factorial(-2 * _k + n)), (_k, 0, floor(n / 2)))) assert diff(hermite(n, x), x) == 2 * n * hermite(n - 1, x) assert diff(hermite(n, x), n) == Derivative(hermite(n, x), n) raises(ArgumentIndexError, lambda: hermite(n, x).fdiff(3))