def test_simplifications(): x = Symbol('x') 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_hyper_as_trig(): from sympy.simplify.fu import _osborne as o, _osbornei as i, TR12 eq = sinh(x)**2 + cosh(x)**2 t, f = hyper_as_trig(eq) assert f(fu(t)) == cosh(2*x) e, f = hyper_as_trig(tanh(x + y)) assert f(TR12(e)) == (tanh(x) + tanh(y))/(tanh(x)*tanh(y) + 1) d = Dummy() assert o(sinh(x), d) == I*sin(x*d) assert o(tanh(x), d) == I*tan(x*d) assert o(coth(x), d) == cot(x*d)/I assert o(cosh(x), d) == cos(x*d) assert o(sech(x), d) == sec(x*d) assert o(csch(x), d) == csc(x*d)/I for func in (sinh, cosh, tanh, coth, sech, csch): h = func(pi) assert i(o(h, d), d) == h # /!\ the _osborne functions are not meant to work # in the o(i(trig, d), d) direction so we just check # that they work as they are supposed to work assert i(cos(x*y + z), y) == cosh(x + z*I) assert i(sin(x*y + z), y) == sinh(x + z*I)/I assert i(tan(x*y + z), y) == tanh(x + z*I)/I assert i(cot(x*y + z), y) == coth(x + z*I)*I assert i(sec(x*y + z), y) == sech(x + z*I) assert i(csc(x*y + z), y) == csch(x + z*I)*I
def test_simplifications(): x = Symbol('x') 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_hyper_as_trig(): from sympy.simplify.fu import _osborne as o, _osbornei as i, TR12 eq = sinh(x)**2 + cosh(x)**2 t, f = hyper_as_trig(eq) assert f(fu(t)) == cosh(2 * x) e, f = hyper_as_trig(tanh(x + y)) assert f(TR12(e)) == (tanh(x) + tanh(y)) / (tanh(x) * tanh(y) + 1) d = Dummy() assert o(sinh(x), d) == I * sin(x * d) assert o(tanh(x), d) == I * tan(x * d) assert o(coth(x), d) == cot(x * d) / I assert o(cosh(x), d) == cos(x * d) assert o(sech(x), d) == sec(x * d) assert o(csch(x), d) == csc(x * d) / I for func in (sinh, cosh, tanh, coth, sech, csch): h = func(pi) assert i(o(h, d), d) == h # /!\ the _osborne functions are not meant to work # in the o(i(trig, d), d) direction so we just check # that they work as they are supposed to work assert i(cos(x * y + z), y) == cosh(x + z * I) assert i(sin(x * y + z), y) == sinh(x + z * I) / I assert i(tan(x * y + z), y) == tanh(x + z * I) / I assert i(cot(x * y + z), y) == coth(x + z * I) * I assert i(sec(x * y + z), y) == sech(x + z * I) assert i(csc(x * y + z), y) == csch(x + z * I) * I
def test_csch_rewrite(): x = Symbol("x") 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_acsch(): x = Symbol('x') assert unchanged(acsch, x) assert acsch(-x) == -acsch(x) # values at fixed points assert acsch(1) == log(1 + sqrt(2)) assert acsch(-1) == - log(1 + sqrt(2)) assert acsch(0) is zoo assert acsch(2) == log((1+sqrt(5))/2) assert acsch(-2) == - log((1+sqrt(5))/2) assert acsch(I) == - I*pi/2 assert acsch(-I) == I*pi/2 assert acsch(-I*(sqrt(6) + sqrt(2))) == I*pi / 12 assert acsch(I*(sqrt(2) + sqrt(6))) == -I*pi / 12 assert acsch(-I*(1 + sqrt(5))) == I*pi / 10 assert acsch(I*(1 + sqrt(5))) == -I*pi / 10 assert acsch(-I*2 / sqrt(2 - sqrt(2))) == I*pi / 8 assert acsch(I*2 / sqrt(2 - sqrt(2))) == -I*pi / 8 assert acsch(-I*2) == I*pi / 6 assert acsch(I*2) == -I*pi / 6 assert acsch(-I*sqrt(2 + 2/sqrt(5))) == I*pi / 5 assert acsch(I*sqrt(2 + 2/sqrt(5))) == -I*pi / 5 assert acsch(-I*sqrt(2)) == I*pi / 4 assert acsch(I*sqrt(2)) == -I*pi / 4 assert acsch(-I*(sqrt(5)-1)) == 3*I*pi / 10 assert acsch(I*(sqrt(5)-1)) == -3*I*pi / 10 assert acsch(-I*2 / sqrt(3)) == I*pi / 3 assert acsch(I*2 / sqrt(3)) == -I*pi / 3 assert acsch(-I*2 / sqrt(2 + sqrt(2))) == 3*I*pi / 8 assert acsch(I*2 / sqrt(2 + sqrt(2))) == -3*I*pi / 8 assert acsch(-I*sqrt(2 - 2/sqrt(5))) == 2*I*pi / 5 assert acsch(I*sqrt(2 - 2/sqrt(5))) == -2*I*pi / 5 assert acsch(-I*(sqrt(6) - sqrt(2))) == 5*I*pi / 12 assert acsch(I*(sqrt(6) - sqrt(2))) == -5*I*pi / 12 assert acsch(nan) is nan # properties # acsch(x) == asinh(1/x) assert acsch(-I*sqrt(2)) == asinh(I/sqrt(2)) assert acsch(-I*2 / sqrt(3)) == asinh(I*sqrt(3) / 2) # acsch(x) == -I*asin(I/x) assert acsch(-I*sqrt(2)) == -I*asin(-1/sqrt(2)) assert acsch(-I*2 / sqrt(3)) == -I*asin(-sqrt(3)/2) # csch(acsch(x)) / x == 1 assert expand_mul(csch(acsch(-I*(sqrt(6) + sqrt(2)))) / (-I*(sqrt(6) + sqrt(2)))) == 1 assert expand_mul(csch(acsch(I*(1 + sqrt(5)))) / ((I*(1 + sqrt(5))))) == 1 assert (csch(acsch(I*sqrt(2 - 2/sqrt(5)))) / (I*sqrt(2 - 2/sqrt(5)))).simplify() == 1 assert (csch(acsch(-I*sqrt(2 - 2/sqrt(5)))) / (-I*sqrt(2 - 2/sqrt(5)))).simplify() == 1 # numerical evaluation assert str(acsch(5*I+1).n(6)) == '0.0391819 - 0.193363*I' assert str(acsch(-5*I+1).n(6)) == '0.0391819 + 0.193363*I'
def test_csch_rewrite(): x = Symbol('x') 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_acsch(): x = Symbol('x') assert acsch(-x) == acsch(-x) assert acsch(x) == -acsch(-x) # values at fixed points assert acsch(1) == log(1 + sqrt(2)) assert acsch(-1) == - log(1 + sqrt(2)) assert acsch(0) == zoo assert acsch(2) == log((1+sqrt(5))/2) assert acsch(-2) == - log((1+sqrt(5))/2) assert acsch(I) == - I*pi/2 assert acsch(-I) == I*pi/2 assert acsch(-I*(sqrt(6) + sqrt(2))) == I*pi / 12 assert acsch(I*(sqrt(2) + sqrt(6))) == -I*pi / 12 assert acsch(-I*(1 + sqrt(5))) == I*pi / 10 assert acsch(I*(1 + sqrt(5))) == -I*pi / 10 assert acsch(-I*2 / sqrt(2 - sqrt(2))) == I*pi / 8 assert acsch(I*2 / sqrt(2 - sqrt(2))) == -I*pi / 8 assert acsch(-I*2) == I*pi / 6 assert acsch(I*2) == -I*pi / 6 assert acsch(-I*sqrt(2 + 2/sqrt(5))) == I*pi / 5 assert acsch(I*sqrt(2 + 2/sqrt(5))) == -I*pi / 5 assert acsch(-I*sqrt(2)) == I*pi / 4 assert acsch(I*sqrt(2)) == -I*pi / 4 assert acsch(-I*(sqrt(5)-1)) == 3*I*pi / 10 assert acsch(I*(sqrt(5)-1)) == -3*I*pi / 10 assert acsch(-I*2 / sqrt(3)) == I*pi / 3 assert acsch(I*2 / sqrt(3)) == -I*pi / 3 assert acsch(-I*2 / sqrt(2 + sqrt(2))) == 3*I*pi / 8 assert acsch(I*2 / sqrt(2 + sqrt(2))) == -3*I*pi / 8 assert acsch(-I*sqrt(2 - 2/sqrt(5))) == 2*I*pi / 5 assert acsch(I*sqrt(2 - 2/sqrt(5))) == -2*I*pi / 5 assert acsch(-I*(sqrt(6) - sqrt(2))) == 5*I*pi / 12 assert acsch(I*(sqrt(6) - sqrt(2))) == -5*I*pi / 12 # properties # acsch(x) == asinh(1/x) assert acsch(-I*sqrt(2)) == asinh(I/sqrt(2)) assert acsch(-I*2 / sqrt(3)) == asinh(I*sqrt(3) / 2) # acsch(x) == -I*asin(I/x) assert acsch(-I*sqrt(2)) == -I*asin(-1/sqrt(2)) assert acsch(-I*2 / sqrt(3)) == -I*asin(-sqrt(3)/2) # csch(acsch(x)) / x == 1 assert expand_mul(csch(acsch(-I*(sqrt(6) + sqrt(2)))) / (-I*(sqrt(6) + sqrt(2)))) == 1 assert expand_mul(csch(acsch(I*(1 + sqrt(5)))) / ((I*(1 + sqrt(5))))) == 1 assert (csch(acsch(I*sqrt(2 - 2/sqrt(5)))) / (I*sqrt(2 - 2/sqrt(5)))).simplify() == 1 assert (csch(acsch(-I*sqrt(2 - 2/sqrt(5)))) / (-I*sqrt(2 - 2/sqrt(5)))).simplify() == 1 # numerical evaluation assert str(acsch(5*I+1).n(6)) == '0.0391819 - 0.193363*I' assert str(acsch(-5*I+1).n(6)) == '0.0391819 + 0.193363*I'
def test_derivs(): x = Symbol('x') 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(): x = Symbol("x") 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) assert asech(x).diff(x) == -1 / (x * sqrt(1 - x ** 2)) assert acsch(x).diff(x) == -1 / (x ** 2 * sqrt(1 + x ** (-2)))
def test_sign_assumptions(): p = Symbol('p', positive=True) n = Symbol('n', negative=True) assert sinh(n).is_negative is True assert sinh(p).is_positive is True assert cosh(n).is_positive is True assert cosh(p).is_positive is True assert tanh(n).is_negative is True assert tanh(p).is_positive is True assert csch(n).is_negative is True assert csch(p).is_positive is True assert sech(n).is_positive is True assert sech(p).is_positive is True assert coth(n).is_negative is True assert coth(p).is_positive is True
def csch(self, value): """ Verilen değeri kullanarak, sumpy.csch döndürür :param value: değer :return: sympy.csch """ return sp.csch(value_checker(value))
def test_trig_functions(self, printer, x): # Trig functions assert printer.doprint(sp.acos(x)) == 'acos(x)' assert printer.doprint(sp.acosh(x)) == 'acosh(x)' assert printer.doprint(sp.asin(x)) == 'asin(x)' assert printer.doprint(sp.asinh(x)) == 'asinh(x)' assert printer.doprint(sp.atan(x)) == 'atan(x)' assert printer.doprint(sp.atanh(x)) == 'atanh(x)' assert printer.doprint(sp.ceiling(x)) == 'ceil(x)' assert printer.doprint(sp.cos(x)) == 'cos(x)' assert printer.doprint(sp.cosh(x)) == 'cosh(x)' assert printer.doprint(sp.exp(x)) == 'exp(x)' assert printer.doprint(sp.factorial(x)) == 'factorial(x)' assert printer.doprint(sp.floor(x)) == 'floor(x)' assert printer.doprint(sp.log(x)) == 'log(x)' assert printer.doprint(sp.sin(x)) == 'sin(x)' assert printer.doprint(sp.sinh(x)) == 'sinh(x)' assert printer.doprint(sp.tan(x)) == 'tan(x)' assert printer.doprint(sp.tanh(x)) == 'tanh(x)' # extra trig functions assert printer.doprint(sp.sec(x)) == '1 / cos(x)' assert printer.doprint(sp.csc(x)) == '1 / sin(x)' assert printer.doprint(sp.cot(x)) == '1 / tan(x)' assert printer.doprint(sp.asec(x)) == 'acos(1 / x)' assert printer.doprint(sp.acsc(x)) == 'asin(1 / x)' assert printer.doprint(sp.acot(x)) == 'atan(1 / x)' assert printer.doprint(sp.sech(x)) == '1 / cosh(x)' assert printer.doprint(sp.csch(x)) == '1 / sinh(x)' assert printer.doprint(sp.coth(x)) == '1 / tanh(x)' assert printer.doprint(sp.asech(x)) == 'acosh(1 / x)' assert printer.doprint(sp.acsch(x)) == 'asinh(1 / x)' assert printer.doprint(sp.acoth(x)) == 'atanh(1 / x)'
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 )
def test_complex(): a, b = symbols("a,b", 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_real_assumptions(): z = Symbol('z', real=False) assert sinh(z).is_real is None assert cosh(z).is_real is None assert tanh(z).is_real is None assert sech(z).is_real is None assert csch(z).is_real is None assert coth(z).is_real is None
def test_complex(): a, b = symbols('a,b', 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_issue_13474(): x = Symbol('x') assert simplify(x + csch(sinc(1))) == x + csch(sinc(1))
def test_csch_fdiff(): x = Symbol('x') raises(ArgumentIndexError, lambda: csch(x).fdiff(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_real is True
sp.tan(num) # tangente sp.cot(num) # cotangente sp.sec(num) # secante sp.csc(num) # cosecante sp.asin(num) # Arcoseno sp.acos(num) # Arcocoseno sp.atan(num) # Arcotangente sp.atan2(catetoY, catetoX) # Arcotangente de un triangulo segun los catetos (Angulo) sp.acot(num) # Arcocotangente sp.asec(num) # Arcosecante sp.acsc(num) # Arcocosecante # Funciones hiperbólicas (Angulos en radianes) sp.sinh(num) # Seno sp.cosh(num) # Coseno sp.tanh(num) # tangente sp.coth(num) # cotangente sp.sech(num) # secante sp.csch(num) # cosecante sp.asinh(num) # Arcoseno sp.acosh(num) # Arcocoseno sp.atanh(num) # Arcotangente sp.acoth(num) # Arcocotangente sp.asech(num) # Arcosecante sp.acsch(num) # Arcocosecante # Combinatoria sp.factorial(num) # Factorial sp.functions.combinatorial.numbers.nP(num1, num2) # Permutación sp.functions.combinatorial.numbers.nC(num1, num2) # Combinación
# These LaTeX strings should parse to the corresponding SymPy expression GOOD_PAIRS = [("0", 0), ("1", 1), ("-3.14", _Mul(-1, 3.14)), ("(-7.13)(1.5)", _Mul(_Mul(-1, 7.13), 1.5)), ("x", x), ("2x", 2 * x), ("x^2", x**2), ("x^{3 + 1}", x**_Add(3, 1)), ("-c", -c), ("a \\cdot b", a * b), ("a / b", a / b), ("a \\div b", a / b), ("a + b", a + b), ("a + b - a", _Add(a + b, -a)), ("a^2 + b^2 = c^2", Eq(a**2 + b**2, c**2)), ("\\sin \\theta", sin(theta)), ("\\sin(\\theta)", sin(theta)), ("\\sin^{-1} a", asin(a)), ("\\sin a \\cos b", _Mul(sin(a), cos(b))), ("\\sin \\cos \\theta", sin(cos(theta))), ("\\sin(\\cos \\theta)", sin(cos(theta))), ("\\csch^2(\\theta)", csch(theta)**2), ("\\frac{a}{b}", a / b), ("\\frac{a + b}{c}", _Mul(a + b, _Pow(c, -1))), ("\\frac{7}{3}", _Mul(7, _Pow(3, -1))), ("(\\csc x)(\\sec y)", csc(x) * sec(y)), ("\\lim_{x \\to 3} a", Limit(a, x, 3)), ("\\lim_{x \\rightarrow 3} a", Limit(a, x, 3)), ("\\lim_{x \\Rightarrow 3} a", Limit(a, x, 3)), ("\\lim_{x \\longrightarrow 3} a", Limit(a, x, 3)), ("\\lim_{x \\Longrightarrow 3} a", Limit(a, x, 3)), ("\\lim_{x \\to 3^{+}} a", Limit(a, x, 3, dir='+')), ("\\lim_{x \\to 3^{-}} a", Limit(a, x, 3, dir='-')), ("\\infty", oo), ("\\lim_{x \\to \\infty} \\frac{1}{x}", Limit(_Mul(1, _Pow(x, -1)), x, oo)), ("\\frac{d}{dx} x", Derivative(x, x)), ("\\frac{d}{dt} x", Derivative(x, t)), ("f(x)", f(x)),
def test_csch(): x, y = symbols('x,y') k = Symbol('k', integer=True) n = Symbol('n', positive=True) assert csch(nan) is nan assert csch(zoo) is nan assert csch(oo) == 0 assert csch(-oo) == 0 assert csch(0) is 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) is zoo assert csch(-pi * I) is zoo assert csch(2 * pi * I) is zoo assert csch(-2 * pi * I) is zoo assert csch(-3 * 10**73 * pi * I) is zoo assert csch(7 * 10**103 * pi * I) is zoo assert csch(pi * I / 2) == -I assert csch(-pi * I / 2) == I assert csch(pi * I * Rational(5, 2)) == -I assert csch(pi * I * Rational(7, 2)) == I assert csch(pi * I / 3) == -2 / sqrt(3) * I assert csch(pi * I * Rational(-2, 3)) == 2 / sqrt(3) * I assert csch(pi * I / 4) == -sqrt(2) * I assert csch(-pi * I / 4) == sqrt(2) * I assert csch(pi * I * Rational(7, 4)) == sqrt(2) * I assert csch(pi * I * Rational(-3, 4)) == sqrt(2) * I assert csch(pi * I / 6) == -2 * I assert csch(-pi * I / 6) == 2 * I assert csch(pi * I * Rational(7, 6)) == 2 * I assert csch(pi * I * Rational(-7, 6)) == -2 * I assert csch(pi * I * Rational(-5, 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) is zoo assert csch(17 * k * pi * I) is zoo assert csch(k * pi * I / 2) == -1 / sin(k * pi / 2) * I assert csch(n).is_real == True
def test_issue_11254b(): assert not integrate(csch(x), (x, 0, 1)).has(Integral)
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_real is True