def test_simplifications(): assert sinh(asinh(x)) == x assert sinh(acosh(x)) == sqrt(x - 1) * sqrt(x + 1) assert sinh(atanh(x)) == x / sqrt(1 - x**2) assert sinh(acoth(x)) == 1 / (sqrt(x - 1) * sqrt(x + 1)) assert cosh(asinh(x)) == sqrt(1 + x**2) assert cosh(acosh(x)) == x assert cosh(atanh(x)) == 1 / sqrt(1 - x**2) assert cosh(acoth(x)) == x / (sqrt(x - 1) * sqrt(x + 1)) assert tanh(asinh(x)) == x / sqrt(1 + x**2) assert tanh(acosh(x)) == sqrt(x - 1) * sqrt(x + 1) / x assert tanh(atanh(x)) == x assert tanh(acoth(x)) == 1 / x assert coth(asinh(x)) == sqrt(1 + x**2) / x assert coth(acosh(x)) == x / (sqrt(x - 1) * sqrt(x + 1)) assert coth(atanh(x)) == 1 / x assert coth(acoth(x)) == x assert csch(asinh(x)) == 1 / x assert csch(acosh(x)) == 1 / (sqrt(x - 1) * sqrt(x + 1)) assert csch(atanh(x)) == sqrt(1 - x**2) / x assert csch(acoth(x)) == sqrt(x - 1) * sqrt(x + 1) assert sech(asinh(x)) == 1 / sqrt(1 + x**2) assert sech(acosh(x)) == 1 / x assert sech(atanh(x)) == sqrt(1 - x**2) assert sech(acoth(x)) == sqrt(x - 1) * sqrt(x + 1) / x
def test_simplifications(): assert sinh(asinh(x)) == x assert sinh(acosh(x)) == sqrt(x - 1) * sqrt(x + 1) assert sinh(atanh(x)) == x/sqrt(1 - x**2) assert sinh(acoth(x)) == 1/(sqrt(x - 1) * sqrt(x + 1)) assert cosh(asinh(x)) == sqrt(1 + x**2) assert cosh(acosh(x)) == x assert cosh(atanh(x)) == 1/sqrt(1 - x**2) assert cosh(acoth(x)) == x/(sqrt(x - 1) * sqrt(x + 1)) assert tanh(asinh(x)) == x/sqrt(1 + x**2) assert tanh(acosh(x)) == sqrt(x - 1) * sqrt(x + 1) / x assert tanh(atanh(x)) == x assert tanh(acoth(x)) == 1/x assert coth(asinh(x)) == sqrt(1 + x**2)/x assert coth(acosh(x)) == x/(sqrt(x - 1) * sqrt(x + 1)) assert coth(atanh(x)) == 1/x assert coth(acoth(x)) == x assert csch(asinh(x)) == 1/x assert csch(acosh(x)) == 1/(sqrt(x - 1) * sqrt(x + 1)) assert csch(atanh(x)) == sqrt(1 - x**2)/x assert csch(acoth(x)) == sqrt(x - 1) * sqrt(x + 1) assert sech(asinh(x)) == 1/sqrt(1 + x**2) assert sech(acosh(x)) == 1/x assert sech(atanh(x)) == sqrt(1 - x**2) assert sech(acoth(x)) == sqrt(x - 1) * sqrt(x + 1)/x
def test_csch_rewrite(): assert csch(x).rewrite(exp) == 1 / (exp(x)/2 - exp(-x)/2) \ == csch(x).rewrite('tractable') assert csch(x).rewrite(cosh) == I / cosh(x + I * pi / 2) tanh_half = tanh(S.Half * x) assert csch(x).rewrite(tanh) == (1 - tanh_half**2) / (2 * tanh_half) coth_half = coth(S.Half * x) assert csch(x).rewrite(coth) == (coth_half**2 - 1) / (2 * coth_half)
def test_derivs(): assert coth(x).diff(x) == -sinh(x)**(-2) assert sinh(x).diff(x) == cosh(x) assert cosh(x).diff(x) == sinh(x) assert tanh(x).diff(x) == -tanh(x)**2 + 1 assert csch(x).diff(x) == -coth(x) * csch(x) assert sech(x).diff(x) == -tanh(x) * sech(x) assert acoth(x).diff(x) == 1 / (-x**2 + 1) assert asinh(x).diff(x) == 1 / sqrt(x**2 + 1) assert acosh(x).diff(x) == 1 / sqrt(x**2 - 1) assert atanh(x).diff(x) == 1 / (-x**2 + 1)
def test_derivs(): assert coth(x).diff(x) == -sinh(x)**(-2) assert sinh(x).diff(x) == cosh(x) assert cosh(x).diff(x) == sinh(x) assert tanh(x).diff(x) == -tanh(x)**2 + 1 assert csch(x).diff(x) == -coth(x)*csch(x) assert sech(x).diff(x) == -tanh(x)*sech(x) assert acoth(x).diff(x) == 1/(-x**2 + 1) assert asinh(x).diff(x) == 1/sqrt(x**2 + 1) assert acosh(x).diff(x) == 1/sqrt(x**2 - 1) assert atanh(x).diff(x) == 1/(-x**2 + 1)
def test_sech(): k = Symbol('k', integer=True) n = Symbol('n', positive=True) assert sech(nan) == nan assert sech(zoo) == nan assert sech(oo) == 0 assert sech(-oo) == 0 assert sech(0) == 1 assert sech(-1) == sech(1) assert sech(-x) == sech(x) assert sech(pi * I) == sec(pi) assert sech(-pi * I) == sec(pi) assert sech(-2**1024 * E) == sech(2**1024 * E) assert sech(pi * I / 2) == zoo assert sech(-pi * I / 2) == zoo assert sech((-3 * 10**73 + 1) * pi * I / 2) == zoo assert sech((7 * 10**103 + 1) * pi * I / 2) == zoo assert sech(pi * I) == -1 assert sech(-pi * I) == -1 assert sech(5 * pi * I) == -1 assert sech(8 * pi * I) == 1 assert sech(pi * I / 3) == 2 assert sech(-2 * pi * I / 3) == -2 assert sech(pi * I / 4) == sqrt(2) assert sech(-pi * I / 4) == sqrt(2) assert sech(5 * pi * I / 4) == -sqrt(2) assert sech(-5 * pi * I / 4) == -sqrt(2) assert sech(pi * I / 6) == 2 / sqrt(3) assert sech(-pi * I / 6) == 2 / sqrt(3) assert sech(7 * pi * I / 6) == -2 / sqrt(3) assert sech(-5 * pi * I / 6) == -2 / sqrt(3) assert sech(pi * I / 105) == 1 / cos(pi / 105) assert sech(-pi * I / 105) == 1 / cos(pi / 105) assert sech(x * I) == 1 / cos(x) assert sech(k * pi * I) == 1 / cos(k * pi) assert sech(17 * k * pi * I) == 1 / cos(17 * k * pi) assert sech(n).is_extended_real is True assert csch(n).is_finite is None pytest.raises(ArgumentIndexError, lambda: sech(x).fdiff(2))
def test_sech(): k = Symbol('k', integer=True) n = Symbol('n', positive=True) assert sech(nan) == nan assert sech(zoo) == nan assert sech(oo) == 0 assert sech(-oo) == 0 assert sech(0) == 1 assert sech(-1) == sech(1) assert sech(-x) == sech(x) assert sech(pi*I) == sec(pi) assert sech(-pi*I) == sec(pi) assert sech(-2**1024 * E) == sech(2**1024 * E) assert sech(pi*I/2) == zoo assert sech(-pi*I/2) == zoo assert sech((-3*10**73 + 1)*pi*I/2) == zoo assert sech((7*10**103 + 1)*pi*I/2) == zoo assert sech(pi*I) == -1 assert sech(-pi*I) == -1 assert sech(5*pi*I) == -1 assert sech(8*pi*I) == 1 assert sech(pi*I/3) == 2 assert sech(-2*pi*I/3) == -2 assert sech(pi*I/4) == sqrt(2) assert sech(-pi*I/4) == sqrt(2) assert sech(5*pi*I/4) == -sqrt(2) assert sech(-5*pi*I/4) == -sqrt(2) assert sech(pi*I/6) == 2/sqrt(3) assert sech(-pi*I/6) == 2/sqrt(3) assert sech(7*pi*I/6) == -2/sqrt(3) assert sech(-5*pi*I/6) == -2/sqrt(3) assert sech(pi*I/105) == 1/cos(pi/105) assert sech(-pi*I/105) == 1/cos(pi/105) assert sech(x*I) == 1/cos(x) assert sech(k*pi*I) == 1/cos(k*pi) assert sech(17*k*pi*I) == 1/cos(17*k*pi) assert sech(n).is_extended_real is True assert csch(n).is_finite is None pytest.raises(ArgumentIndexError, lambda: sech(x).fdiff(2))
def test_leading_term(): assert cosh(x).as_leading_term(x) == 1 assert coth(x).as_leading_term(x) == 1 / x assert acosh(x).as_leading_term(x) == I * pi / 2 assert acoth(x).as_leading_term(x) == -I * pi / 2 for func in [sinh, tanh, asinh, atanh]: assert func(x).as_leading_term(x) == x for func in [sinh, cosh, tanh, coth, asinh, acosh, atanh, acoth]: for arg in (1 / x, Rational(1, 2)): eq = func(arg) assert eq.as_leading_term(x) == eq for func in [csch, sech]: eq = func(Rational(1, 2)) assert eq.as_leading_term(x) == eq assert csch(x).as_leading_term(x) == 1 / x
def test_leading_term(): assert cosh(x).as_leading_term(x) == 1 assert coth(x).as_leading_term(x) == 1/x assert acosh(x).as_leading_term(x) == I*pi/2 assert acoth(x).as_leading_term(x) == I*pi/2 for func in [sinh, tanh, asinh, atanh]: assert func(x).as_leading_term(x) == x for func in [sinh, cosh, tanh, coth, asinh, acosh, atanh, acoth]: for arg in (1/x, Rational(1, 2)): eq = func(arg) assert eq.as_leading_term(x) == eq for func in [csch, sech]: eq = func(Rational(1, 2)) assert eq.as_leading_term(x) == eq assert csch(x).as_leading_term(x) == 1/x
def test_complex(): a, b = symbols('a,b', extended_real=True) z = a + b*I for func in [sinh, cosh, tanh, coth, sech, csch]: assert func(z).conjugate() == func(a - b*I) for deep in [True, False]: assert sinh(z).expand( complex=True, deep=deep) == sinh(a)*cos(b) + I*cosh(a)*sin(b) assert cosh(z).expand( complex=True, deep=deep) == cosh(a)*cos(b) + I*sinh(a)*sin(b) assert tanh(z).expand(complex=True, deep=deep) == sinh(a)*cosh( a)/(cos(b)**2 + sinh(a)**2) + I*sin(b)*cos(b)/(cos(b)**2 + sinh(a)**2) assert coth(z).expand(complex=True, deep=deep) == sinh(a)*cosh( a)/(sin(b)**2 + sinh(a)**2) - I*sin(b)*cos(b)/(sin(b)**2 + sinh(a)**2) assert csch(z).expand(complex=True, deep=deep) == cos(b) * sinh(a) / (sin(b)**2 * cosh(a)**2 + cos(b)**2 * sinh(a)**2) - I*sin(b) * cosh(a) / (sin(b)**2 * cosh(a)**2 + cos(b)**2 * sinh(a)**2) assert sech(z).expand(complex=True, deep=deep) == cos(b) * cosh(a) / (sin(b)**2 * sinh(a)**2 + cos(b)**2 * cosh(a)**2) - I*sin(b) * sinh(a) / (sin(b)**2 * sinh(a)**2 + cos(b)**2 * cosh(a)**2)
def test_csch_series(): assert (csch(x).series( x, 0, 10) == 1 / x - x / 6 + 7 * x**3 / 360 - 31 * x**5 / 15120 + 127 * x**7 / 604800 - 73 * x**9 / 3421440 + O(x**10))
def test_csch(): k = Symbol('k', integer=True) n = Symbol('n', positive=True) assert csch(nan) == nan assert csch(zoo) == nan assert csch(oo) == 0 assert csch(-oo) == 0 assert csch(0) == zoo assert csch(-1) == -csch(1) assert csch(-x) == -csch(x) assert csch(-pi) == -csch(pi) assert csch(-2**1024 * E) == -csch(2**1024 * E) assert csch(pi * I) == zoo assert csch(-pi * I) == zoo assert csch(2 * pi * I) == zoo assert csch(-2 * pi * I) == zoo assert csch(-3 * 10**73 * pi * I) == zoo assert csch(7 * 10**103 * pi * I) == zoo assert csch(pi * I / 2) == -I assert csch(-pi * I / 2) == I assert csch(5 * pi * I / 2) == -I assert csch(7 * pi * I / 2) == I assert csch(pi * I / 3) == -2 / sqrt(3) * I assert csch(-2 * pi * I / 3) == 2 / sqrt(3) * I assert csch(pi * I / 4) == -sqrt(2) * I assert csch(-pi * I / 4) == sqrt(2) * I assert csch(7 * pi * I / 4) == sqrt(2) * I assert csch(-3 * pi * I / 4) == sqrt(2) * I assert csch(pi * I / 6) == -2 * I assert csch(-pi * I / 6) == 2 * I assert csch(7 * pi * I / 6) == 2 * I assert csch(-7 * pi * I / 6) == -2 * I assert csch(-5 * pi * I / 6) == 2 * I assert csch(pi * I / 105) == -1 / sin(pi / 105) * I assert csch(-pi * I / 105) == 1 / sin(pi / 105) * I assert csch(x * I) == -1 / sin(x) * I assert csch(k * pi * I) == zoo assert csch(17 * k * pi * I) == zoo assert csch(k * pi * I / 2) == -1 / sin(k * pi / 2) * I assert csch(n).is_extended_real is True assert csch(n).is_finite is None pytest.raises(ArgumentIndexError, lambda: csch(x).fdiff(2))
def test_Function(): assert mathematica_code(f(x, y, z)) == 'f[x, y, z]' assert mathematica_code(sin(x)**cos(x)) == 'Sin[x]^Cos[x]' assert mathematica_code(sign(x)) == 'Sign[x]' assert mathematica_code(atanh(x), user_functions={'atanh': 'ArcTanh'}) == 'ArcTanh[x]' assert (mathematica_code(meijerg( ((1, 1), (3, 4)), ((1, ), ()), x)) == 'MeijerG[{{1, 1}, {3, 4}}, {{1}, {}}, x]') assert (mathematica_code(hyper( (1, 2, 3), (3, 4), x)) == 'HypergeometricPFQ[{1, 2, 3}, {3, 4}, x]') assert mathematica_code(Min(x, y)) == 'Min[x, y]' assert mathematica_code(Max(x, y)) == 'Max[x, y]' assert mathematica_code(Max(x, 2)) == 'Max[2, x]' # issue sympy/sympy#15344 assert mathematica_code(binomial(x, y)) == 'Binomial[x, y]' assert mathematica_code(log(x)) == 'Log[x]' assert mathematica_code(tan(x)) == 'Tan[x]' assert mathematica_code(cot(x)) == 'Cot[x]' assert mathematica_code(asin(x)) == 'ArcSin[x]' assert mathematica_code(acos(x)) == 'ArcCos[x]' assert mathematica_code(atan(x)) == 'ArcTan[x]' assert mathematica_code(acot(x)) == 'ArcCot[x]' assert mathematica_code(sinh(x)) == 'Sinh[x]' assert mathematica_code(cosh(x)) == 'Cosh[x]' assert mathematica_code(tanh(x)) == 'Tanh[x]' assert mathematica_code(coth(x)) == 'Coth[x]' assert mathematica_code(asinh(x)) == 'ArcSinh[x]' assert mathematica_code(acosh(x)) == 'ArcCosh[x]' assert mathematica_code(atanh(x)) == 'ArcTanh[x]' assert mathematica_code(acoth(x)) == 'ArcCoth[x]' assert mathematica_code(sech(x)) == 'Sech[x]' assert mathematica_code(csch(x)) == 'Csch[x]' assert mathematica_code(erf(x)) == 'Erf[x]' assert mathematica_code(erfi(x)) == 'Erfi[x]' assert mathematica_code(erfc(x)) == 'Erfc[x]' assert mathematica_code(conjugate(x)) == 'Conjugate[x]' assert mathematica_code(re(x)) == 'Re[x]' assert mathematica_code(im(x)) == 'Im[x]' assert mathematica_code(polygamma(x, y)) == 'PolyGamma[x, y]' assert mathematica_code(factorial(x)) == 'Factorial[x]' assert mathematica_code(factorial2(x)) == 'Factorial2[x]' assert mathematica_code(rf(x, y)) == 'Pochhammer[x, y]' assert mathematica_code(gamma(x)) == 'Gamma[x]' assert mathematica_code(zeta(x)) == 'Zeta[x]' assert mathematica_code(Heaviside(x)) == 'UnitStep[x]' assert mathematica_code(fibonacci(x)) == 'Fibonacci[x]' assert mathematica_code(polylog(x, y)) == 'PolyLog[x, y]' assert mathematica_code(loggamma(x)) == 'LogGamma[x]' assert mathematica_code(uppergamma(x, y)) == 'Gamma[x, y]' class MyFunc1(Function): @classmethod def eval(cls, x): pass class MyFunc2(Function): @classmethod def eval(cls, x, y): pass pytest.raises( ValueError, lambda: mathematica_code(MyFunc1(x), user_functions={'MyFunc1': ['Myfunc1']})) assert mathematica_code(MyFunc1(x), user_functions={'MyFunc1': 'Myfunc1'}) == 'Myfunc1[x]' assert mathematica_code( MyFunc2(x, y), user_functions={'MyFunc2': [(lambda *x: False, 'Myfunc2')]}) == 'MyFunc2[x, y]'
def test_csch(): k = Symbol('k', integer=True) n = Symbol('n', positive=True) assert csch(nan) == nan assert csch(zoo) == nan assert csch(oo) == 0 assert csch(-oo) == 0 assert csch(0) == zoo assert csch(-1) == -csch(1) assert csch(-x) == -csch(x) assert csch(-pi) == -csch(pi) assert csch(-2**1024 * E) == -csch(2**1024 * E) assert csch(pi*I) == zoo assert csch(-pi*I) == zoo assert csch(2*pi*I) == zoo assert csch(-2*pi*I) == zoo assert csch(-3*10**73*pi*I) == zoo assert csch(7*10**103*pi*I) == zoo assert csch(pi*I/2) == -I assert csch(-pi*I/2) == I assert csch(5*pi*I/2) == -I assert csch(7*pi*I/2) == I assert csch(pi*I/3) == -2/sqrt(3)*I assert csch(-2*pi*I/3) == 2/sqrt(3)*I assert csch(pi*I/4) == -sqrt(2)*I assert csch(-pi*I/4) == sqrt(2)*I assert csch(7*pi*I/4) == sqrt(2)*I assert csch(-3*pi*I/4) == sqrt(2)*I assert csch(pi*I/6) == -2*I assert csch(-pi*I/6) == 2*I assert csch(7*pi*I/6) == 2*I assert csch(-7*pi*I/6) == -2*I assert csch(-5*pi*I/6) == 2*I assert csch(pi*I/105) == -1/sin(pi/105)*I assert csch(-pi*I/105) == 1/sin(pi/105)*I assert csch(x*I) == -1/sin(x)*I assert csch(k*pi*I) == zoo assert csch(17*k*pi*I) == zoo assert csch(k*pi*I/2) == -1/sin(k*pi/2)*I assert csch(n).is_extended_real is True assert csch(n).is_finite is None pytest.raises(ArgumentIndexError, lambda: csch(x).fdiff(2))
def test_csch_rewrite(): assert csch(x).rewrite(exp) == 1 / (exp(x)/2 - exp(-x)/2) \ == csch(x).rewrite('tractable') assert csch(x).rewrite(cosh) == I/cosh(x + I*pi/2) assert csch(x).rewrite(tanh) == (1 - tanh(x/2)**2)/(2*tanh(x/2)) assert csch(x).rewrite(coth) == (coth(x/2)**2 - 1)/(2*coth(x/2))
def test_csch(): x, y = symbols('x,y') k = Symbol('k', integer=True) n = Symbol('n', positive=True) assert csch(nan) == nan assert csch(zoo) == nan assert csch(oo) == 0 assert csch(-oo) == 0 assert csch(0) == zoo assert csch(-1) == -csch(1) assert csch(-x) == -csch(x) assert csch(-pi) == -csch(pi) assert csch(-2**1024 * E) == -csch(2**1024 * E) assert csch(pi * I) == zoo assert csch(-pi * I) == zoo assert csch(2 * pi * I) == zoo assert csch(-2 * pi * I) == zoo assert csch(-3 * 10**73 * pi * I) == zoo assert csch(7 * 10**103 * pi * I) == zoo assert csch(pi * I / 2) == -I assert csch(-pi * I / 2) == I assert csch(5 * pi * I / 2) == -I assert csch(7 * pi * I / 2) == I assert csch(pi * I / 3) == -2 / sqrt(3) * I assert csch(-2 * pi * I / 3) == 2 / sqrt(3) * I assert csch(pi * I / 4) == -sqrt(2) * I assert csch(-pi * I / 4) == sqrt(2) * I assert csch(7 * pi * I / 4) == sqrt(2) * I assert csch(-3 * pi * I / 4) == sqrt(2) * I assert csch(pi * I / 6) == -2 * I assert csch(-pi * I / 6) == 2 * I assert csch(7 * pi * I / 6) == 2 * I assert csch(-7 * pi * I / 6) == -2 * I assert csch(-5 * pi * I / 6) == 2 * I assert csch(pi * I / 105) == -1 / sin(pi / 105) * I assert csch(-pi * I / 105) == 1 / sin(pi / 105) * I assert csch(x * I) == -1 / sin(x) * I assert csch(k * pi * I) == zoo assert csch(17 * k * pi * I) == zoo assert csch(k * pi * I / 2) == -1 / sin(k * pi / 2) * I assert csch(n).is_extended_real is True assert csch(n).is_finite is None
def test_csch_series(): assert (csch(x).series(x, 0, 10) == 1/x - x/6 + 7*x**3/360 - 31*x**5/15120 + 127*x**7/604800 - 73*x**9/3421440 + O(x**10))
def test_csch_rewrite(): assert csch(x).rewrite(exp) == 1 / (exp(x)/2 - exp(-x)/2) \ == csch(x).rewrite('tractable') assert csch(x).rewrite(cosh) == I / cosh(x + I * pi / 2) assert csch(x).rewrite(tanh) == (1 - tanh(x / 2)**2) / (2 * tanh(x / 2)) assert csch(x).rewrite(coth) == (coth(x / 2)**2 - 1) / (2 * coth(x / 2))
def test_csc(): x = symbols('x', extended_real=True) z = symbols('z') # https://github.com/sympy/sympy/issues/6707 cosecant = csc('x') alternate = 1/sin('x') assert cosecant.equals(alternate) assert alternate.equals(cosecant) assert csc.nargs == FiniteSet(1) assert csc(0) == zoo assert csc(pi) == zoo assert csc(pi/2) == 1 assert csc(-pi/2) == -1 assert csc(pi/6) == 2 assert csc(pi/3) == 2*sqrt(3)/3 assert csc(5*pi/2) == 1 assert csc(9*pi/7) == -csc(2*pi/7) assert csc(3*pi/4) == sqrt(2) # issue sympy/sympy#8421 assert csc(I) == -I*csch(1) assert csc(x*I) == -I*csch(x) assert csc(-x) == -csc(x) assert csc(acsc(x)) == x assert csc(x).rewrite(exp) == 2*I/(exp(I*x) - exp(-I*x)) assert csc(x).rewrite(sin) == 1/sin(x) assert csc(x).rewrite(cos) == csc(x) assert csc(x).rewrite(tan) == (tan(x/2)**2 + 1)/(2*tan(x/2)) assert csc(x).rewrite(cot) == (cot(x/2)**2 + 1)/(2*cot(x/2)) assert csc(z).conjugate() == csc(conjugate(z)) assert (csc(z).as_real_imag() == (sin(re(z))*cosh(im(z))/(sin(re(z))**2*cosh(im(z))**2 + cos(re(z))**2*sinh(im(z))**2), -cos(re(z))*sinh(im(z))/(sin(re(z))**2*cosh(im(z))**2 + cos(re(z))**2*sinh(im(z))**2))) assert csc(x).expand(trig=True) == 1/sin(x) assert csc(2*x).expand(trig=True) == 1/(2*sin(x)*cos(x)) assert csc(a).is_algebraic is None assert csc(na).is_algebraic is False assert csc(x).as_leading_term() == csc(x) assert csc(0).is_finite is False assert csc(x).is_finite is None assert csc(pi/2).is_finite assert series(csc(x), x, x0=pi/2, n=6) == \ 1 + (x - pi/2)**2/2 + 5*(x - pi/2)**4/24 + O((x - pi/2)**6, (x, pi/2)) assert series(csc(x), x, x0=0, n=6) == \ 1/x + x/6 + 7*x**3/360 + 31*x**5/15120 + O(x**6) assert csc(x).diff(x) == -cot(x)*csc(x) assert csc(x).taylor_term(0, x) == 1/x assert csc(x).taylor_term(2, x) == 0 assert csc(x).taylor_term(3, x) == 7*x**3/360 assert csc(x).taylor_term(5, x) == 31*x**5/15120 pytest.raises(ArgumentIndexError, lambda: csc(x).fdiff(2))
def test_csch_series(): x = Symbol('x') assert csch(x).series(x, 0, 10) == \ 1/x - x/6 + 7*x**3/360 - 31*x**5/15120 + 127*x**7/604800 \ - 73*x**9/3421440 + O(x**10)