Example #1
0
 def asech(self, value):
     """
     Verilen değeri kullanarak, sumpy.asech döndürür
     :param value: değer
     :return: sympy.asech
     """
     return sp.asech(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)'
Example #3
0
def test_inverses():
    x = Symbol('x')
    assert sinh(x).inverse() == asinh
    raises(AttributeError, lambda: cosh(x).inverse())
    assert tanh(x).inverse() == atanh
    assert coth(x).inverse() == acoth
    assert asinh(x).inverse() == sinh
    assert acosh(x).inverse() == cosh
    assert atanh(x).inverse() == tanh
    assert acoth(x).inverse() == coth
    assert asech(x).inverse() == sech
Example #4
0
def test_inverses():
    x = Symbol('x')
    assert sinh(x).inverse() == asinh
    raises(AttributeError, lambda: cosh(x).inverse())
    assert tanh(x).inverse() == atanh
    assert coth(x).inverse() == acoth
    assert asinh(x).inverse() == sinh
    assert acosh(x).inverse() == cosh
    assert atanh(x).inverse() == tanh
    assert acoth(x).inverse() == coth
    assert asech(x).inverse() == sech
Example #5
0
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))
Example #6
0
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))
Example #7
0
def test_asech_rewrite():
    x = Symbol('x')
    assert asech(x).rewrite(log) == log(1 / x +
                                        sqrt(1 / x - 1) * sqrt(1 / x + 1))
Example #8
0
def test_asech_series():
    x = Symbol('x')
    t6 = asech(x).expansion_term(6, x)
    assert t6 == -5 * x**6 / 96
    assert asech(x).expansion_term(8, x, t6, 0) == -35 * x**8 / 1024
Example #9
0
def test_asech():
    x = Symbol('x')

    assert unchanged(asech, -x)

    # values at fixed points
    assert asech(1) == 0
    assert asech(-1) == pi * I
    assert asech(0) == oo
    assert asech(2) == I * pi / 3
    assert asech(-2) == 2 * I * pi / 3
    assert asech(nan) == nan

    # at infinites
    assert asech(oo) == I * pi / 2
    assert asech(-oo) == I * pi / 2
    assert asech(zoo) == I * AccumBounds(-pi / 2, pi / 2)

    assert asech(I) == log(1 + sqrt(2)) - I * pi / 2
    assert asech(-I) == log(1 + sqrt(2)) + I * pi / 2
    assert asech(sqrt(2) - sqrt(6)) == 11 * I * pi / 12
    assert asech(sqrt(2 - 2 / sqrt(5))) == I * pi / 10
    assert asech(-sqrt(2 - 2 / sqrt(5))) == 9 * I * pi / 10
    assert asech(2 / sqrt(2 + sqrt(2))) == I * pi / 8
    assert asech(-2 / sqrt(2 + sqrt(2))) == 7 * I * pi / 8
    assert asech(sqrt(5) - 1) == I * pi / 5
    assert asech(1 - sqrt(5)) == 4 * I * pi / 5
    assert asech(-sqrt(2 * (2 + sqrt(2)))) == 5 * I * pi / 8

    # properties
    # asech(x) == acosh(1/x)
    assert asech(sqrt(2)) == acosh(1 / sqrt(2))
    assert asech(2 / sqrt(3)) == acosh(sqrt(3) / 2)
    assert asech(2 / sqrt(2 + sqrt(2))) == acosh(sqrt(2 + sqrt(2)) / 2)
    assert asech(S(2)) == acosh(1 / S(2))

    # asech(x) == I*acos(1/x)
    # (Note: the exact formula is asech(x) == +/- I*acos(1/x))
    assert asech(-sqrt(2)) == I * acos(-1 / sqrt(2))
    assert asech(-2 / sqrt(3)) == I * acos(-sqrt(3) / 2)
    assert asech(-S(2)) == I * acos(-S.Half)
    assert asech(-2 / sqrt(2)) == I * acos(-sqrt(2) / 2)

    # sech(asech(x)) / x == 1
    assert expand_mul(sech(asech(sqrt(6) - sqrt(2))) /
                      (sqrt(6) - sqrt(2))) == 1
    assert expand_mul(sech(asech(sqrt(6) + sqrt(2))) /
                      (sqrt(6) + sqrt(2))) == 1
    assert (sech(asech(sqrt(2 + 2 / sqrt(5)))) /
            (sqrt(2 + 2 / sqrt(5)))).simplify() == 1
    assert (sech(asech(-sqrt(2 + 2 / sqrt(5)))) /
            (-sqrt(2 + 2 / sqrt(5)))).simplify() == 1
    assert (sech(asech(sqrt(2 * (2 + sqrt(2))))) /
            (sqrt(2 * (2 + sqrt(2))))).simplify() == 1
    assert expand_mul(sech(asech((1 + sqrt(5)))) / ((1 + sqrt(5)))) == 1
    assert expand_mul(sech(asech((-1 - sqrt(5)))) / ((-1 - sqrt(5)))) == 1
    assert expand_mul(
        sech(asech((-sqrt(6) - sqrt(2)))) / ((-sqrt(6) - sqrt(2)))) == 1

    # numerical evaluation
    assert str(asech(5 * I).n(6)) == '0.19869 - 1.5708*I'
    assert str(asech(-5 * I).n(6)) == '0.19869 + 1.5708*I'
Example #10
0
def test_asech_rewrite():
    x = Symbol('x')
    assert asech(x).rewrite(log) == log(1/x + sqrt(1/x - 1) * sqrt(1/x + 1))
Example #11
0
def test_asech_series():
    x = Symbol('x')
    t6 = asech(x).expansion_term(6, x)
    assert t6 == -5*x**6/96
    assert asech(x).expansion_term(8, x, t6, 0) == -35*x**8/1024
Example #12
0
def test_asech():
    x = Symbol('x')

    assert asech(-x) == asech(-x)

    # values at fixed points
    assert asech(1) == 0
    assert asech(-1) == pi*I
    assert asech(0) == oo
    assert asech(2) == I*pi/3
    assert asech(-2) == 2*I*pi / 3

    # at infinites
    assert asech(oo) == I*pi/2
    assert asech(-oo) == I*pi/2
    assert asech(zoo) == nan

    assert asech(I) == log(1 + sqrt(2)) - I*pi/2
    assert asech(-I) == log(1 + sqrt(2)) + I*pi/2
    assert asech(sqrt(2) - sqrt(6)) == 11*I*pi / 12
    assert asech(sqrt(2 - 2/sqrt(5))) == I*pi / 10
    assert asech(-sqrt(2 - 2/sqrt(5))) == 9*I*pi / 10
    assert asech(2 / sqrt(2 + sqrt(2))) == I*pi / 8
    assert asech(-2 / sqrt(2 + sqrt(2))) == 7*I*pi / 8
    assert asech(sqrt(5) - 1) == I*pi / 5
    assert asech(1 - sqrt(5)) == 4*I*pi / 5
    assert asech(-sqrt(2*(2 + sqrt(2)))) == 5*I*pi / 8

    # properties
    # asech(x) == acosh(1/x)
    assert asech(sqrt(2)) == acosh(1/sqrt(2))
    assert asech(2/sqrt(3)) == acosh(sqrt(3)/2)
    assert asech(2/sqrt(2 + sqrt(2))) == acosh(sqrt(2 + sqrt(2))/2)
    assert asech(S(2)) == acosh(1/S(2))

    # asech(x) == I*acos(1/x)
    # (Note: the exact formula is asech(x) == +/- I*acos(1/x))
    assert asech(-sqrt(2)) == I*acos(-1/sqrt(2))
    assert asech(-2/sqrt(3)) == I*acos(-sqrt(3)/2)
    assert asech(-S(2)) == I*acos(-S.Half)
    assert asech(-2/sqrt(2)) == I*acos(-sqrt(2)/2)

    # sech(asech(x)) / x == 1
    assert expand_mul(sech(asech(sqrt(6) - sqrt(2))) / (sqrt(6) - sqrt(2))) == 1
    assert expand_mul(sech(asech(sqrt(6) + sqrt(2))) / (sqrt(6) + sqrt(2))) == 1
    assert (sech(asech(sqrt(2 + 2/sqrt(5)))) / (sqrt(2 + 2/sqrt(5)))).simplify() == 1
    assert (sech(asech(-sqrt(2 + 2/sqrt(5)))) / (-sqrt(2 + 2/sqrt(5)))).simplify() == 1
    assert (sech(asech(sqrt(2*(2 + sqrt(2))))) / (sqrt(2*(2 + sqrt(2))))).simplify() == 1
    assert expand_mul(sech(asech((1 + sqrt(5)))) / ((1 + sqrt(5)))) == 1
    assert expand_mul(sech(asech((-1 - sqrt(5)))) / ((-1 - sqrt(5)))) == 1
    assert expand_mul(sech(asech((-sqrt(6) - sqrt(2)))) / ((-sqrt(6) - sqrt(2)))) == 1

    # numerical evaluation
    assert str(asech(5*I).n(6)) == '0.19869 - 1.5708*I'
    assert str(asech(-5*I).n(6)) == '0.19869 + 1.5708*I'
Example #13
0
def test_asech_rewrite():
    x = Symbol("x")
    assert asech(x).rewrite(log) == log(1 / x + sqrt(1 / x ** 2 - 1))
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
Example #15
0
def test_fps__logarithmic_singularity_fail():
    f = asech(x)  # Algorithms for computing limits probably needs improvemnts
    assert fps(f, x) == log(2) - log(x) - x ** 2 / 4 - 3 * x ** 4 / 64 + O(x ** 6)
Example #16
0
def test_asech_fdiff():
    x = Symbol('x')
    raises(ArgumentIndexError, lambda: asech(x).fdiff(2))
def test_fps__logarithmic_singularity_fail():
    f = asech(x)  # Algorithms for computing limits probably needs improvemnts
    assert fps(f, x) == log(2) - log(x) - x**2 / 4 - 3 * x**4 / 64 + O(x**6)
Example #18
0
def test_asech_infinities():
    assert asech(oo) == I*pi/2
    assert asech(-oo) == I*pi/2
    assert asech(zoo) == nan