def test_specfun(): for f in [besselj, bessely, besseli, besselk]: assert octave_code(f(n, x)) == f.__name__ + '(n, x)' assert octave_code(hankel1(n, x)) == 'besselh(n, 1, x)' assert octave_code(hankel2(n, x)) == 'besselh(n, 2, x)' assert octave_code(airyai(x)) == 'airy(0, x)' assert octave_code(airyaiprime(x)) == 'airy(1, x)' assert octave_code(airybi(x)) == 'airy(2, x)' assert octave_code(airybiprime(x)) == 'airy(3, x)' assert octave_code(uppergamma(n, x)) == "gammainc(x, n, 'upper')" assert octave_code(lowergamma(n, x)) == "gammainc(x, n, 'lower')" assert octave_code(jn( n, x)) == 'sqrt(2)*sqrt(pi)*sqrt(1./x).*besselj(n + 1/2, x)/2' assert octave_code(yn( n, x)) == 'sqrt(2)*sqrt(pi)*sqrt(1./x).*bessely(n + 1/2, x)/2' assert octave_code(Chi(x)) == 'coshint(x)' assert octave_code(Ci(x)) == 'cosint(x)' assert octave_code(laguerre(n, x)) == 'laguerreL(n, x)' assert octave_code(li(x)) == 'logint(x)' assert octave_code(loggamma(x)) == 'gammaln(x)' assert octave_code(polygamma(n, x)) == 'psi(n, x)' assert octave_code(Shi(x)) == 'sinhint(x)' assert octave_code(Si(x)) == 'sinint(x)' assert octave_code(LambertW(x)) == 'lambertw(x)' assert octave_code(LambertW(x, n)) == 'lambertw(n, x)' assert octave_code(zeta(x)) == 'zeta(x)' assert octave_code(zeta( x, y)) == '% Not supported in Octave:\n% zeta\nzeta(x, y)'
def test_assoc_laguerre(): # generalized Laguerre polynomials: assert assoc_laguerre(0, alpha, x) == 1 assert assoc_laguerre(1, alpha, x) == -x + alpha + 1 assert assoc_laguerre(2, alpha, x).expand() == \ (x**2/2 - (alpha + 2)*x + (alpha + 2)*(alpha + 1)/2).expand() assert assoc_laguerre(3, alpha, x).expand() == \ (-x**3/6 + (alpha + 3)*x**2/2 - (alpha + 2)*(alpha + 3)*x/2 + (alpha + 1)*(alpha + 2)*(alpha + 3)/6).expand() # Test the lowest 10 polynomials with laguerre_poly, to make sure it works: for i in range(10): assert assoc_laguerre(i, 0, x).expand() == laguerre_poly(i, x) X = assoc_laguerre(n, m, x) assert isinstance(X, assoc_laguerre) assert assoc_laguerre(n, 0, x) == laguerre(n, x) assert assoc_laguerre(n, alpha, 0) == binomial(alpha + n, alpha) p = Symbol('p', positive=True) assert assoc_laguerre(p, alpha, oo) == (-1)**p*oo assert assoc_laguerre(p, alpha, -oo) == oo assert diff(assoc_laguerre(n, alpha, x), x) == \ -assoc_laguerre(n - 1, alpha + 1, x) pytest.raises(ArgumentIndexError, lambda: assoc_laguerre(n, m, x).fdiff(1)) assert conjugate(assoc_laguerre(n, alpha, x)) == \ assoc_laguerre(n, conjugate(alpha), conjugate(x)) pytest.raises(ValueError, lambda: assoc_laguerre(-2.1, alpha, x)) # issue sympy/sympy#10961 X = assoc_laguerre(Rational(5, 2), alpha, x) assert isinstance(X, assoc_laguerre) assert (diff(assoc_laguerre(n, alpha, x), alpha) == Sum(assoc_laguerre(k, alpha, x)/(-alpha + n), (k, 0, n - 1)))
def test_assoc_laguerre(): # generalized Laguerre polynomials: assert assoc_laguerre(0, alpha, x) == 1 assert assoc_laguerre(1, alpha, x) == -x + alpha + 1 assert assoc_laguerre(2, alpha, x).expand() == \ (x**2/2 - (alpha + 2)*x + (alpha + 2)*(alpha + 1)/2).expand() assert assoc_laguerre(3, alpha, x).expand() == \ (-x**3/6 + (alpha + 3)*x**2/2 - (alpha + 2)*(alpha + 3)*x/2 + (alpha + 1)*(alpha + 2)*(alpha + 3)/6).expand() # Test the lowest 10 polynomials with laguerre_poly, to make sure it works: for i in range(10): assert assoc_laguerre(i, 0, x).expand() == laguerre_poly(i, x) X = assoc_laguerre(n, m, x) assert isinstance(X, assoc_laguerre) assert assoc_laguerre(n, 0, x) == laguerre(n, x) assert assoc_laguerre(n, alpha, 0) == binomial(alpha + n, alpha) p = Symbol('p', positive=True) assert assoc_laguerre(p, alpha, oo) == (-1)**p*oo assert assoc_laguerre(p, alpha, -oo) == oo assert diff(assoc_laguerre(n, alpha, x), x) == \ -assoc_laguerre(n - 1, alpha + 1, x) pytest.raises(ArgumentIndexError, lambda: assoc_laguerre(n, m, x).fdiff(1)) assert conjugate(assoc_laguerre(n, alpha, x)) == \ assoc_laguerre(n, conjugate(alpha), conjugate(x)) pytest.raises(ValueError, lambda: assoc_laguerre(-2.1, alpha, x)) # issue sympy/sympy#10961 X = assoc_laguerre(Rational(5, 2), alpha, x) assert isinstance(X, assoc_laguerre)
def test_laguerre(): assert laguerre(0, x) == 1 assert laguerre(1, x) == -x + 1 assert laguerre(2, x) == x**2 / 2 - 2 * x + 1 assert laguerre(3, x) == -x**3 / 6 + 3 * x**2 / 2 - 3 * x + 1 assert laguerre(n, oo) == (-1)**n * oo assert laguerre(n, -oo) == oo X = laguerre(n, x) assert isinstance(X, laguerre) assert laguerre(n, 0) == 1 assert conjugate(laguerre(n, x)) == laguerre(n, conjugate(x)) assert diff(laguerre(n, x), x) == -assoc_laguerre(n - 1, 1, x) pytest.raises(ArgumentIndexError, lambda: laguerre(n, x).fdiff(1)) pytest.raises(ValueError, lambda: laguerre(-2.1, x)) # issue sympy/sympy#10961 X = laguerre(Rational(5, 2), x) assert isinstance(X, laguerre)
def test_laguerre(): assert laguerre(0, x) == 1 assert laguerre(1, x) == -x + 1 assert laguerre(2, x) == x**2/2 - 2*x + 1 assert laguerre(3, x) == -x**3/6 + 3*x**2/2 - 3*x + 1 assert laguerre(n, oo) == (-1)**n*oo assert laguerre(n, -oo) == oo assert laguerre(-n, x) == exp(x)*laguerre(n - 1, -x) X = laguerre(n, x) assert isinstance(X, laguerre) assert laguerre(n, 0) == 1 assert conjugate(laguerre(n, x)) == laguerre(n, conjugate(x)) assert diff(laguerre(n, x), x) == -assoc_laguerre(n - 1, 1, x) pytest.raises(ArgumentIndexError, lambda: laguerre(n, x).fdiff(1)) pytest.raises(ValueError, lambda: laguerre(-2.1, x)) # issue sympy/sympy#10961 X = laguerre(Rational(5, 2), x) assert isinstance(X, laguerre)