Ejemplo n.º 1
0
def test_math_functions():
	dort('sin(37)', sympy.sin(37))
	dort('cos(38)', sympy.cos(38))
	dort('tan(38)', sympy.tan(38))
	dort('sec(39)', sympy.sec(39))
	dort('csc(40)', sympy.csc(40))
	dort('cot(41)', sympy.cot(41))
	dort('asin(42)', sympy.asin(42))
	dort('acos(43)', sympy.acos(43))
	dort('atan(44)', sympy.atan(44))
	dort('asec(45)', sympy.asec(45))
	dort('acsc(46)', sympy.acsc(46))
	dort('acot(47)', sympy.acot(47))
	dort('sind(37)', sympy.sin(37 * sympy.pi / sympy.Number(180)))
	dort('cosd(38)', sympy.cos(38 * sympy.pi / sympy.Number(180)))
	dort('tand(38)', sympy.tan(38 * sympy.pi / sympy.Number(180)))
	dort('secd(39)', sympy.sec(39 * sympy.pi / sympy.Number(180)))
	dort('cscd(40)', sympy.csc(40 * sympy.pi / sympy.Number(180)))
	dort('cotd(41)', sympy.cot(41 * sympy.pi / sympy.Number(180)))
	dort('asind(42)', sympy.asin(42) * sympy.Number(180) / sympy.pi)
	dort('acosd(43)', sympy.acos(43) * sympy.Number(180) / sympy.pi)
	dort('atand(44)', sympy.atan(44) * sympy.Number(180) / sympy.pi)
	dort('asecd(45)', sympy.asec(45) * sympy.Number(180) / sympy.pi)
	dort('acscd(46)', sympy.acsc(46) * sympy.Number(180) / sympy.pi)
	dort('acotd(47)', sympy.acot(47) * sympy.Number(180) / sympy.pi)
	dort('sinh(4)', sympy.sinh(4))
	dort('cosh(5)', sympy.cosh(5))
	dort('tanh(6)', sympy.tanh(6))
	dort('asinh(4)', sympy.asinh(4))
	dort('acosh(5)', sympy.acosh(5))
	dort('atanh(6)', sympy.atanh(6))	
	dort('int(E)', int(sympy.E))
	dort('int(-E)', int(-sympy.E))
Ejemplo n.º 2
0
def test_asin_rewrite():
    assert asin(x).rewrite(log) == -I*log(I*x + sqrt(1 - x**2))
    assert asin(x).rewrite(atan) == 2*atan(x/(1 + sqrt(1 - x**2)))
    assert asin(x).rewrite(acos) == S.Pi/2 - acos(x)
    assert asin(x).rewrite(acot) == 2*acot((sqrt(-x**2 + 1) + 1)/x)
    assert asin(x).rewrite(asec) == -asec(1/x) + pi/2
    assert asin(x).rewrite(acsc) == acsc(1/x)
Ejemplo n.º 3
0
def test_acot_rewrite():
    assert acot(x).rewrite(log) == I*log((x - I)/(x + I))/2
    assert acot(x).rewrite(asin) == x*(-asin(sqrt(-x**2)/sqrt(-x**2 - 1)) + pi/2)*sqrt(x**(-2))
    assert acot(x).rewrite(acos) == x*sqrt(x**(-2))*acos(sqrt(-x**2)/sqrt(-x**2 - 1))
    assert acot(x).rewrite(atan) == atan(1/x)
    assert acot(x).rewrite(asec) == x*sqrt(x**(-2))*asec(sqrt((x**2 + 1)/x**2))
    assert acot(x).rewrite(acsc) == x*(-acsc(sqrt((x**2 + 1)/x**2)) + pi/2)*sqrt(x**(-2))
Ejemplo n.º 4
0
def test_asin_rewrite():
    assert asin(x).rewrite(log) == -I * log(I * x + sqrt(1 - x**2))
    assert asin(x).rewrite(atan) == 2 * atan(x / (1 + sqrt(1 - x**2)))
    assert asin(x).rewrite(acos) == S.Pi / 2 - acos(x)
    assert asin(x).rewrite(acot) == 2 * acot((sqrt(-x**2 + 1) + 1) / x)
    assert asin(x).rewrite(asec) == -asec(1 / x) + pi / 2
    assert asin(x).rewrite(acsc) == acsc(1 / x)
Ejemplo n.º 5
0
def test_acot_rewrite():
    assert acot(x).rewrite(log) == I*log((x - I)/(x + I))/2
    assert acot(x).rewrite(asin) == x*(-asin(sqrt(-x**2)/sqrt(-x**2 - 1)) + pi/2)*sqrt(x**(-2))
    assert acot(x).rewrite(acos) == x*sqrt(x**(-2))*acos(sqrt(-x**2)/sqrt(-x**2 - 1))
    assert acot(x).rewrite(atan) == atan(1/x)
    assert acot(x).rewrite(asec) == x*sqrt(x**(-2))*asec(sqrt((x**2 + 1)/x**2))
    assert acot(x).rewrite(acsc) == x*(-acsc(sqrt((x**2 + 1)/x**2)) + pi/2)*sqrt(x**(-2))
Ejemplo n.º 6
0
def test_atan_rewrite():
    assert atan(x).rewrite(log) == I*log((1 - I*x)/(1 + I*x))/2
    assert atan(x).rewrite(asin) == (-asin(1/sqrt(x**2 + 1)) + pi/2)*sqrt(x**2)/x
    assert atan(x).rewrite(acos) == sqrt(x**2)*acos(1/sqrt(x**2 + 1))/x
    assert atan(x).rewrite(acot) == acot(1/x)
    assert atan(x).rewrite(asec) == sqrt(x**2)*asec(sqrt(x**2 + 1))/x
    assert atan(x).rewrite(acsc) == (-acsc(sqrt(x**2 + 1)) + pi/2)*sqrt(x**2)/x
Ejemplo n.º 7
0
def test_conv7():
    x = Symbol("x")
    y = Symbol("y")
    assert sin(x/3) == sin(sympy.Symbol("x") / 3)
    assert cos(x/3) == cos(sympy.Symbol("x") / 3)
    assert tan(x/3) == tan(sympy.Symbol("x") / 3)
    assert cot(x/3) == cot(sympy.Symbol("x") / 3)
    assert csc(x/3) == csc(sympy.Symbol("x") / 3)
    assert sec(x/3) == sec(sympy.Symbol("x") / 3)
    assert asin(x/3) == asin(sympy.Symbol("x") / 3)
    assert acos(x/3) == acos(sympy.Symbol("x") / 3)
    assert atan(x/3) == atan(sympy.Symbol("x") / 3)
    assert acot(x/3) == acot(sympy.Symbol("x") / 3)
    assert acsc(x/3) == acsc(sympy.Symbol("x") / 3)
    assert asec(x/3) == asec(sympy.Symbol("x") / 3)

    assert sin(x/3)._sympy_() == sympy.sin(sympy.Symbol("x") / 3)
    assert sin(x/3)._sympy_() != sympy.cos(sympy.Symbol("x") / 3)
    assert cos(x/3)._sympy_() == sympy.cos(sympy.Symbol("x") / 3)
    assert tan(x/3)._sympy_() == sympy.tan(sympy.Symbol("x") / 3)
    assert cot(x/3)._sympy_() == sympy.cot(sympy.Symbol("x") / 3)
    assert csc(x/3)._sympy_() == sympy.csc(sympy.Symbol("x") / 3)
    assert sec(x/3)._sympy_() == sympy.sec(sympy.Symbol("x") / 3)
    assert asin(x/3)._sympy_() == sympy.asin(sympy.Symbol("x") / 3)
    assert acos(x/3)._sympy_() == sympy.acos(sympy.Symbol("x") / 3)
    assert atan(x/3)._sympy_() == sympy.atan(sympy.Symbol("x") / 3)
    assert acot(x/3)._sympy_() == sympy.acot(sympy.Symbol("x") / 3)
    assert acsc(x/3)._sympy_() == sympy.acsc(sympy.Symbol("x") / 3)
    assert asec(x/3)._sympy_() == sympy.asec(sympy.Symbol("x") / 3)
    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)'
Ejemplo n.º 9
0
def test_conv7():
    x = Symbol("x")
    y = Symbol("y")
    assert sin(x / 3) == sin(sympy.Symbol("x") / 3)
    assert cos(x / 3) == cos(sympy.Symbol("x") / 3)
    assert tan(x / 3) == tan(sympy.Symbol("x") / 3)
    assert cot(x / 3) == cot(sympy.Symbol("x") / 3)
    assert csc(x / 3) == csc(sympy.Symbol("x") / 3)
    assert sec(x / 3) == sec(sympy.Symbol("x") / 3)
    assert asin(x / 3) == asin(sympy.Symbol("x") / 3)
    assert acos(x / 3) == acos(sympy.Symbol("x") / 3)
    assert atan(x / 3) == atan(sympy.Symbol("x") / 3)
    assert acot(x / 3) == acot(sympy.Symbol("x") / 3)
    assert acsc(x / 3) == acsc(sympy.Symbol("x") / 3)
    assert asec(x / 3) == asec(sympy.Symbol("x") / 3)

    assert sin(x / 3)._sympy_() == sympy.sin(sympy.Symbol("x") / 3)
    assert sin(x / 3)._sympy_() != sympy.cos(sympy.Symbol("x") / 3)
    assert cos(x / 3)._sympy_() == sympy.cos(sympy.Symbol("x") / 3)
    assert tan(x / 3)._sympy_() == sympy.tan(sympy.Symbol("x") / 3)
    assert cot(x / 3)._sympy_() == sympy.cot(sympy.Symbol("x") / 3)
    assert csc(x / 3)._sympy_() == sympy.csc(sympy.Symbol("x") / 3)
    assert sec(x / 3)._sympy_() == sympy.sec(sympy.Symbol("x") / 3)
    assert asin(x / 3)._sympy_() == sympy.asin(sympy.Symbol("x") / 3)
    assert acos(x / 3)._sympy_() == sympy.acos(sympy.Symbol("x") / 3)
    assert atan(x / 3)._sympy_() == sympy.atan(sympy.Symbol("x") / 3)
    assert acot(x / 3)._sympy_() == sympy.acot(sympy.Symbol("x") / 3)
    assert acsc(x / 3)._sympy_() == sympy.acsc(sympy.Symbol("x") / 3)
    assert asec(x / 3)._sympy_() == sympy.asec(sympy.Symbol("x") / 3)
Ejemplo n.º 10
0
def test_atan_rewrite():
    assert atan(x).rewrite(log) == I*log((1 - I*x)/(1 + I*x))/2
    assert atan(x).rewrite(asin) == (-asin(1/sqrt(x**2 + 1)) + pi/2)*sqrt(x**2)/x
    assert atan(x).rewrite(acos) == sqrt(x**2)*acos(1/sqrt(x**2 + 1))/x
    assert atan(x).rewrite(acot) == acot(1/x)
    assert atan(x).rewrite(asec) == sqrt(x**2)*asec(sqrt(x**2 + 1))/x
    assert atan(x).rewrite(acsc) == (-acsc(sqrt(x**2 + 1)) + pi/2)*sqrt(x**2)/x
Ejemplo n.º 11
0
 def acsc(self, value):
     """
     Verilen değeri kullanarak, sumpy.acsc döndürür
     :param value: değer
     :return: sympy.acsc
     """
     return sp.acsc(value_checker(value))
Ejemplo n.º 12
0
 def __new__(cls, arg):
     obj = acsc(arg)
     if arg.is_real:
         assumptions = {'real': True}
         ass_copy = assumptions.copy()
         obj._assumptions = StdFactKB(assumptions)
         obj._assumptions._generator = ass_copy
     return obj
Ejemplo n.º 13
0
def test_acos_rewrite():
    assert acos(x).rewrite(log) == pi/2 + I*log(I*x + sqrt(1 - x**2))
    assert acos(x).rewrite(atan) == \
           atan(sqrt(1 - x**2)/x) + (pi/2)*(1 - x*sqrt(1/x**2))
    assert acos(0).rewrite(atan) == S.Pi/2
    assert acos(0.5).rewrite(atan) == acos(0.5).rewrite(log)
    assert acos(x).rewrite(asin) == S.Pi/2 - asin(x)
    assert acos(x).rewrite(acot) == -2*acot((sqrt(-x**2 + 1) + 1)/x) + pi/2
    assert acos(x).rewrite(asec) == asec(1/x)
    assert acos(x).rewrite(acsc) == -acsc(1/x) + pi/2
Ejemplo n.º 14
0
def test_acos_rewrite():
    assert acos(x).rewrite(log) == pi/2 + I*log(I*x + sqrt(1 - x**2))
    assert acos(x).rewrite(atan) == \
           atan(sqrt(1 - x**2)/x) + (pi/2)*(1 - x*sqrt(1/x**2))
    assert acos(0).rewrite(atan) == S.Pi/2
    assert acos(0.5).rewrite(atan) == acos(0.5).rewrite(log)
    assert acos(x).rewrite(asin) == S.Pi/2 - asin(x)
    assert acos(x).rewrite(acot) == -2*acot((sqrt(-x**2 + 1) + 1)/x) + pi/2
    assert acos(x).rewrite(asec) == asec(1/x)
    assert acos(x).rewrite(acsc) == -acsc(1/x) + pi/2
Ejemplo n.º 15
0
def test_branch_cuts():
    assert limit(asin(I * x + 2), x, 0) == pi - asin(2)
    assert limit(asin(I * x + 2), x, 0, '-') == asin(2)
    assert limit(asin(I * x - 2), x, 0) == -asin(2)
    assert limit(asin(I * x - 2), x, 0, '-') == -pi + asin(2)
    assert limit(acos(I * x + 2), x, 0) == -acos(2)
    assert limit(acos(I * x + 2), x, 0, '-') == acos(2)
    assert limit(acos(I * x - 2), x, 0) == acos(-2)
    assert limit(acos(I * x - 2), x, 0, '-') == 2 * pi - acos(-2)
    assert limit(atan(x + 2 * I), x, 0) == I * atanh(2)
    assert limit(atan(x + 2 * I), x, 0, '-') == -pi + I * atanh(2)
    assert limit(atan(x - 2 * I), x, 0) == pi - I * atanh(2)
    assert limit(atan(x - 2 * I), x, 0, '-') == -I * atanh(2)
    assert limit(atan(1 / x), x, 0) == pi / 2
    assert limit(atan(1 / x), x, 0, '-') == -pi / 2
    assert limit(atan(x), x, oo) == pi / 2
    assert limit(atan(x), x, -oo) == -pi / 2
    assert limit(acot(x + S(1) / 2 * I), x, 0) == pi - I * acoth(S(1) / 2)
    assert limit(acot(x + S(1) / 2 * I), x, 0, '-') == -I * acoth(S(1) / 2)
    assert limit(acot(x - S(1) / 2 * I), x, 0) == I * acoth(S(1) / 2)
    assert limit(acot(x - S(1) / 2 * I), x, 0,
                 '-') == -pi + I * acoth(S(1) / 2)
    assert limit(acot(x), x, 0) == pi / 2
    assert limit(acot(x), x, 0, '-') == -pi / 2
    assert limit(asec(I * x + S(1) / 2), x, 0) == asec(S(1) / 2)
    assert limit(asec(I * x + S(1) / 2), x, 0, '-') == -asec(S(1) / 2)
    assert limit(asec(I * x - S(1) / 2), x, 0) == 2 * pi - asec(-S(1) / 2)
    assert limit(asec(I * x - S(1) / 2), x, 0, '-') == asec(-S(1) / 2)
    assert limit(acsc(I * x + S(1) / 2), x, 0) == acsc(S(1) / 2)
    assert limit(acsc(I * x + S(1) / 2), x, 0, '-') == pi - acsc(S(1) / 2)
    assert limit(acsc(I * x - S(1) / 2), x, 0) == -pi + acsc(S(1) / 2)
    assert limit(acsc(I * x - S(1) / 2), x, 0, '-') == -acsc(S(1) / 2)

    assert limit(log(I * x - 1), x, 0) == I * pi
    assert limit(log(I * x - 1), x, 0, '-') == -I * pi
    assert limit(log(-I * x - 1), x, 0) == -I * pi
    assert limit(log(-I * x - 1), x, 0, '-') == I * pi

    assert limit(sqrt(I * x - 1), x, 0) == I
    assert limit(sqrt(I * x - 1), x, 0, '-') == -I
    assert limit(sqrt(-I * x - 1), x, 0) == -I
    assert limit(sqrt(-I * x - 1), x, 0, '-') == I

    assert limit(cbrt(I * x - 1), x, 0) == (-1)**(S(1) / 3)
    assert limit(cbrt(I * x - 1), x, 0, '-') == -(-1)**(S(2) / 3)
    assert limit(cbrt(-I * x - 1), x, 0) == -(-1)**(S(2) / 3)
    assert limit(cbrt(-I * x - 1), x, 0, '-') == (-1)**(S(1) / 3)
Ejemplo n.º 16
0
def test_conv7b():
    x = sympy.Symbol("x")
    y = sympy.Symbol("y")
    assert sympify(sympy.sin(x/3)) == sin(Symbol("x") / 3)
    assert sympify(sympy.sin(x/3)) != cos(Symbol("x") / 3)
    assert sympify(sympy.cos(x/3)) == cos(Symbol("x") / 3)
    assert sympify(sympy.tan(x/3)) == tan(Symbol("x") / 3)
    assert sympify(sympy.cot(x/3)) == cot(Symbol("x") / 3)
    assert sympify(sympy.csc(x/3)) == csc(Symbol("x") / 3)
    assert sympify(sympy.sec(x/3)) == sec(Symbol("x") / 3)
    assert sympify(sympy.asin(x/3)) == asin(Symbol("x") / 3)
    assert sympify(sympy.acos(x/3)) == acos(Symbol("x") / 3)
    assert sympify(sympy.atan(x/3)) == atan(Symbol("x") / 3)
    assert sympify(sympy.acot(x/3)) == acot(Symbol("x") / 3)
    assert sympify(sympy.acsc(x/3)) == acsc(Symbol("x") / 3)
    assert sympify(sympy.asec(x/3)) == asec(Symbol("x") / 3)
Ejemplo n.º 17
0
def test_conv7b():
    x = sympy.Symbol("x")
    y = sympy.Symbol("y")
    assert sympify(sympy.sin(x / 3)) == sin(Symbol("x") / 3)
    assert sympify(sympy.sin(x / 3)) != cos(Symbol("x") / 3)
    assert sympify(sympy.cos(x / 3)) == cos(Symbol("x") / 3)
    assert sympify(sympy.tan(x / 3)) == tan(Symbol("x") / 3)
    assert sympify(sympy.cot(x / 3)) == cot(Symbol("x") / 3)
    assert sympify(sympy.csc(x / 3)) == csc(Symbol("x") / 3)
    assert sympify(sympy.sec(x / 3)) == sec(Symbol("x") / 3)
    assert sympify(sympy.asin(x / 3)) == asin(Symbol("x") / 3)
    assert sympify(sympy.acos(x / 3)) == acos(Symbol("x") / 3)
    assert sympify(sympy.atan(x / 3)) == atan(Symbol("x") / 3)
    assert sympify(sympy.acot(x / 3)) == acot(Symbol("x") / 3)
    assert sympify(sympy.acsc(x / 3)) == acsc(Symbol("x") / 3)
    assert sympify(sympy.asec(x / 3)) == asec(Symbol("x") / 3)
Ejemplo n.º 18
0
def test_asec():
    assert asec(nan) == nan
    assert asec(1) == 0
    assert asec(-1) == pi
    assert asec(oo) == pi/2
    assert asec(-oo) == pi/2
    assert asec(zoo) == pi/2

    assert asec(x).diff(x) == 1/(x**2*sqrt(1 - 1/x**2))
    assert asec(x).as_leading_term(x) == log(x)

    assert asec(x).rewrite(log) == I*log(sqrt(1 - 1/x**2) + I/x) + pi/2
    assert asec(x).rewrite(asin) == -asin(1/x) + pi/2
    assert asec(x).rewrite(acos) == acos(1/x)
    assert asec(x).rewrite(atan) == (2*atan(x + sqrt(x**2 - 1)) - pi/2)*sqrt(x**2)/x
    assert asec(x).rewrite(acot) == (2*acot(x - sqrt(x**2 - 1)) - pi/2)*sqrt(x**2)/x
    assert asec(x).rewrite(acsc) == -acsc(x) + pi/2
Ejemplo n.º 19
0
def test_asec():
    assert asec(nan) == nan
    assert asec(1) == 0
    assert asec(-1) == pi
    assert asec(oo) == pi/2
    assert asec(-oo) == pi/2
    assert asec(zoo) == pi/2

    assert asec(x).diff(x) == 1/(x**2*sqrt(1 - 1/x**2))
    assert asec(x).as_leading_term(x) == log(x)

    assert asec(x).rewrite(log) == I*log(sqrt(1 - 1/x**2) + I/x) + pi/2
    assert asec(x).rewrite(asin) == -asin(1/x) + pi/2
    assert asec(x).rewrite(acos) == acos(1/x)
    assert asec(x).rewrite(atan) == (2*atan(x + sqrt(x**2 - 1)) - pi/2)*sqrt(x**2)/x
    assert asec(x).rewrite(acot) == (2*acot(x - sqrt(x**2 - 1)) - pi/2)*sqrt(x**2)/x
    assert asec(x).rewrite(acsc) == -acsc(x) + pi/2
Ejemplo n.º 20
0
def test_csc():
    x = symbols('x', real=True)
    z = symbols('z')

    # https://github.com/sympy/sympy/issues/6707
    cosecant = csc('x')
    alternate = 1/sin('x')
    assert cosecant.equals(alternate) == True
    assert alternate.equals(cosecant) == True

    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 8421
    assert csc(I) == -I/sinh(1)
    assert csc(x*I) == -I/sinh(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(x).is_real == True
    assert csc(z).is_real == None

    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 == False
    assert csc(x).is_finite == None
    assert csc(pi/2).is_finite == True

    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(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
# Funciones para trigonometría (Angulos en radianes)
sp.sin(num)  # Seno
sp.cos(num)  # Coseno
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
Ejemplo n.º 22
0
def test_invert_real():
    x = Symbol('x', real=True)
    y = Symbol('y')
    n = Symbol('n')

    def ireal(x, s=S.Reals):
        return Intersection(s, x)

    minus_n = Intersection(Interval(-oo, 0), FiniteSet(-n))
    plus_n = Intersection(Interval(0, oo), FiniteSet(n))
    assert solveset(abs(x) - n, x, S.Reals) == Union(minus_n, plus_n)

    assert invert_real(exp(x), y, x) == (x, ireal(FiniteSet(log(y))))

    y = Symbol('y', positive=True)
    n = Symbol('n', real=True)
    assert invert_real(x + 3, y, x) == (x, FiniteSet(y - 3))
    assert invert_real(x * 3, y, x) == (x, FiniteSet(y / 3))

    assert invert_real(exp(x), y, x) == (x, FiniteSet(log(y)))
    assert invert_real(exp(3 * x), y, x) == (x, FiniteSet(log(y) / 3))
    assert invert_real(exp(x + 3), y, x) == (x, FiniteSet(log(y) - 3))

    assert invert_real(exp(x) + 3, y, x) == (x, ireal(FiniteSet(log(y - 3))))
    assert invert_real(exp(x) * 3, y, x) == (x, FiniteSet(log(y / 3)))

    assert invert_real(log(x), y, x) == (x, FiniteSet(exp(y)))
    assert invert_real(log(3 * x), y, x) == (x, FiniteSet(exp(y) / 3))
    assert invert_real(log(x + 3), y, x) == (x, FiniteSet(exp(y) - 3))

    minus_y = Intersection(Interval(-oo, 0), FiniteSet(-y))
    plus_y = Intersection(Interval(0, oo), FiniteSet(y))
    assert invert_real(Abs(x), y, x) == (x, Union(minus_y, plus_y))

    assert invert_real(2**x, y, x) == (x, FiniteSet(log(y) / log(2)))
    assert invert_real(2**exp(x), y,
                       x) == (x, ireal(FiniteSet(log(log(y) / log(2)))))

    assert invert_real(x**2, y, x) == (x, FiniteSet(sqrt(y), -sqrt(y)))
    assert invert_real(x**Rational(1, 2), y, x) == (x, FiniteSet(y**2))

    raises(ValueError, lambda: invert_real(x, x, x))
    raises(ValueError, lambda: invert_real(x**pi, y, x))
    raises(ValueError, lambda: invert_real(S.One, y, x))

    assert invert_real(x**31 + x, y, x) == (x**31 + x, FiniteSet(y))

    y_1 = Intersection(Interval(-1, oo), FiniteSet(y - 1))
    y_2 = Intersection(Interval(-oo, -1), FiniteSet(-y - 1))
    assert invert_real(Abs(x**31 + x + 1), y,
                       x) == (x**31 + x, Union(y_1, y_2))

    assert invert_real(sin(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + (-1)**n*asin(y)), S.Integers))

    assert invert_real(sin(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log((-1)**n*asin(y) + n*pi)), S.Integers))

    assert invert_real(csc(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + (-1)**n*acsc(y)), S.Integers))

    assert invert_real(csc(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log((-1)**n*acsc(y) + n*pi)), S.Integers))

    assert invert_real(cos(x), y, x) == \
        (x, Union(imageset(Lambda(n, 2*n*pi + acos(y)), S.Integers), \
                imageset(Lambda(n, 2*n*pi - acos(y)), S.Integers)))

    assert invert_real(cos(exp(x)), y, x) == \
        (x, Union(imageset(Lambda(n, log(2*n*pi + acos(y))), S.Integers), \
                imageset(Lambda(n, log(2*n*pi - acos(y))), S.Integers)))

    assert invert_real(sec(x), y, x) == \
        (x, Union(imageset(Lambda(n, 2*n*pi + asec(y)), S.Integers), \
                imageset(Lambda(n, 2*n*pi - asec(y)), S.Integers)))

    assert invert_real(sec(exp(x)), y, x) == \
        (x, Union(imageset(Lambda(n, log(2*n*pi + asec(y))), S.Integers), \
                imageset(Lambda(n, log(2*n*pi - asec(y))), S.Integers)))

    assert invert_real(tan(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + atan(y)), S.Integers))

    assert invert_real(tan(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log(n*pi + atan(y))), S.Integers))

    assert invert_real(cot(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + acot(y)), S.Integers))

    assert invert_real(cot(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log(n*pi + acot(y))), S.Integers))

    assert invert_real(tan(tan(x)), y, x) == \
        (tan(x), imageset(Lambda(n, n*pi + atan(y)), S.Integers))

    x = Symbol('x', positive=True)
    assert invert_real(x**pi, y, x) == (x, FiniteSet(y**(1 / pi)))

    # Test for ``set_h`` containing information about the domain

    n = Dummy('n')
    x = Symbol('x')

    h1 = Intersection(Interval(-oo, -3), FiniteSet(-a + b - 3),
                      imageset(Lambda(n, n - a - 3), Interval(0, oo)))

    h2 = Intersection(Interval(-3, oo), FiniteSet(a - b - 3),
                      imageset(Lambda(n, -n + a - 3), Interval(0, oo)))

    assert invert_real(Abs(Abs(x + 3) - a) - b, 0, x) == (x, Union(h1, h2))
Ejemplo n.º 23
0
def test_csc():
    x = symbols('x', real=True)
    z = symbols('z')

    # https://github.com/sympy/sympy/issues/6707
    cosecant = csc('x')
    alternate = 1 / sin('x')
    assert cosecant.equals(alternate) == True
    assert alternate.equals(cosecant) == True

    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 8421
    assert csc(I) == -I / sinh(1)
    assert csc(x * I) == -I / sinh(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(x).is_real == True
    assert csc(z).is_real == None

    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 == False
    assert csc(x).is_finite == None
    assert csc(pi / 2).is_finite == True

    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(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
Ejemplo n.º 24
0
def test_invert_real():
    x = Dummy(real=True)
    n = Symbol('n')

    minus_n = Intersection(Interval(-oo, 0), FiniteSet(-n))
    plus_n = Intersection(Interval(0, oo), FiniteSet(n))
    assert solveset(abs(x) - n, x, S.Reals) == Union(minus_n, plus_n)

    n = Symbol('n', real=True)
    assert invert_real(x + 3, y, x) == (x, FiniteSet(y - 3))
    assert invert_real(x*3, y, x) == (x, FiniteSet(y / 3))

    assert invert_real(exp(x), y, x) == (x, FiniteSet(log(y)))
    assert invert_real(exp(3*x), y, x) == (x, FiniteSet(log(y) / 3))
    assert invert_real(exp(x + 3), y, x) == (x, FiniteSet(log(y) - 3))

    assert invert_real(exp(x) + 3, y, x) == (x, FiniteSet(log(y - 3)))
    assert invert_real(exp(x)*3, y, x) == (x, FiniteSet(log(y / 3)))

    assert invert_real(log(x), y, x) == (x, FiniteSet(exp(y)))
    assert invert_real(log(3*x), y, x) == (x, FiniteSet(exp(y) / 3))
    assert invert_real(log(x + 3), y, x) == (x, FiniteSet(exp(y) - 3))

    minus_y = Intersection(Interval(-oo, 0), FiniteSet(-y))
    plus_y = Intersection(Interval(0, oo), FiniteSet(y))
    assert invert_real(Abs(x), y, x) == (x, Union(minus_y, plus_y))

    assert invert_real(2**x, y, x) == (x, FiniteSet(log(y)/log(2)))
    assert invert_real(2**exp(x), y, x) == (x, FiniteSet(log(log(y)/log(2))))

    assert invert_real(x**2, y, x) == (x, FiniteSet(sqrt(y), -sqrt(y)))
    assert invert_real(x**Rational(1, 2), y, x) == (x, FiniteSet(y**2))

    raises(ValueError, lambda: invert_real(x, x, x))
    raises(ValueError, lambda: invert_real(x**pi, y, x))
    raises(ValueError, lambda: invert_real(S.One, y, x))

    assert invert_real(x**31 + x, y, x) == (x**31 + x, FiniteSet(y))

    y_1 = Intersection(Interval(-1, oo), FiniteSet(y - 1))
    y_2 = Intersection(Interval(-oo, -1), FiniteSet(-y - 1))
    assert invert_real(Abs(x**31 + x + 1), y, x) == (x**31 + x,
                                                     Union(y_1, y_2))

    assert invert_real(sin(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + (-1)**n*asin(y)), S.Integers))

    assert invert_real(sin(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log((-1)**n*asin(y) + n*pi)), S.Integers))

    assert invert_real(csc(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + (-1)**n*acsc(y)), S.Integers))

    assert invert_real(csc(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log((-1)**n*acsc(y) + n*pi)), S.Integers))

    assert invert_real(cos(x), y, x) == \
        (x, Union(imageset(Lambda(n, 2*n*pi + acos(y)), S.Integers), \
                imageset(Lambda(n, 2*n*pi - acos(y)), S.Integers)))

    assert invert_real(cos(exp(x)), y, x) == \
        (x, Union(imageset(Lambda(n, log(2*n*pi + acos(y))), S.Integers), \
                imageset(Lambda(n, log(2*n*pi - acos(y))), S.Integers)))

    assert invert_real(sec(x), y, x) == \
        (x, Union(imageset(Lambda(n, 2*n*pi + asec(y)), S.Integers), \
                imageset(Lambda(n, 2*n*pi - asec(y)), S.Integers)))

    assert invert_real(sec(exp(x)), y, x) == \
        (x, Union(imageset(Lambda(n, log(2*n*pi + asec(y))), S.Integers), \
                imageset(Lambda(n, log(2*n*pi - asec(y))), S.Integers)))

    assert invert_real(tan(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + atan(y)), S.Integers))

    assert invert_real(tan(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log(n*pi + atan(y))), S.Integers))

    assert invert_real(cot(x), y, x) == \
        (x, imageset(Lambda(n, n*pi + acot(y)), S.Integers))

    assert invert_real(cot(exp(x)), y, x) == \
        (x, imageset(Lambda(n, log(n*pi + acot(y))), S.Integers))

    assert invert_real(tan(tan(x)), y, x) == \
        (tan(x), imageset(Lambda(n, n*pi + atan(y)), S.Integers))

    x = Symbol('x', positive=True)
    assert invert_real(x**pi, y, x) == (x, FiniteSet(y**(1/pi)))

    # Test for ``set_h`` containing information about the domain

    n = Dummy('n')
    x = Symbol('x')

    h1 = Intersection(Interval(-3, oo), FiniteSet(a + b - 3),
                      imageset(Lambda(n, -n + a - 3), Interval(-oo, 0)))

    h2 = Intersection(Interval(-oo, -3), FiniteSet(-a + b - 3),
                      imageset(Lambda(n, n - a - 3), Interval(0, oo)))

    h3 = Intersection(Interval(-3, oo), FiniteSet(a - b - 3),
                      imageset(Lambda(n, -n + a - 3), Interval(0, oo)))

    h4 = Intersection(Interval(-oo, -3), FiniteSet(-a - b - 3),
                      imageset(Lambda(n, n - a - 3), Interval(-oo, 0)))

    assert invert_real(Abs(Abs(x + 3) - a) - b, 0, x) == (x, Union(h1, h2, h3, h4))
Ejemplo n.º 25
0
def test_manualintegrate_inversetrig():
    # atan
    assert manualintegrate(exp(x) / (1 + exp(2 * x)), x) == atan(exp(x))
    assert manualintegrate(1 / (4 + 9 * x**2), x) == atan(3 * x / 2) / 6
    assert manualintegrate(1 / (16 + 16 * x**2), x) == atan(x) / 16
    assert manualintegrate(1 / (4 + x**2), x) == atan(x / 2) / 2
    assert manualintegrate(1 / (1 + 4 * x**2), x) == atan(2 * x) / 2
    ra = Symbol('a', real=True)
    rb = Symbol('b', real=True)
    assert manualintegrate(1/(ra + rb*x**2), x) == \
        Piecewise((atan(x/sqrt(ra/rb))/(rb*sqrt(ra/rb)), ra/rb > 0),
                  (-acoth(x/sqrt(-ra/rb))/(rb*sqrt(-ra/rb)), And(ra/rb < 0, x**2 > -ra/rb)),
                  (-atanh(x/sqrt(-ra/rb))/(rb*sqrt(-ra/rb)), And(ra/rb < 0, x**2 < -ra/rb)))
    assert manualintegrate(1/(4 + rb*x**2), x) == \
        Piecewise((atan(x/(2*sqrt(1/rb)))/(2*rb*sqrt(1/rb)), 4/rb > 0),
                  (-acoth(x/(2*sqrt(-1/rb)))/(2*rb*sqrt(-1/rb)), And(4/rb < 0, x**2 > -4/rb)),
                  (-atanh(x/(2*sqrt(-1/rb)))/(2*rb*sqrt(-1/rb)), And(4/rb < 0, x**2 < -4/rb)))
    assert manualintegrate(1/(ra + 4*x**2), x) == \
        Piecewise((atan(2*x/sqrt(ra))/(2*sqrt(ra)), ra/4 > 0),
                  (-acoth(2*x/sqrt(-ra))/(2*sqrt(-ra)), And(ra/4 < 0, x**2 > -ra/4)),
                  (-atanh(2*x/sqrt(-ra))/(2*sqrt(-ra)), And(ra/4 < 0, x**2 < -ra/4)))
    assert manualintegrate(1 / (4 + 4 * x**2), x) == atan(x) / 4

    assert manualintegrate(1 / (a + b * x**2),
                           x) == atan(x / sqrt(a / b)) / (b * sqrt(a / b))

    # asin
    assert manualintegrate(1 / sqrt(1 - x**2), x) == asin(x)
    assert manualintegrate(1 / sqrt(4 - 4 * x**2), x) == asin(x) / 2
    assert manualintegrate(3 / sqrt(1 - 9 * x**2), x) == asin(3 * x)
    assert manualintegrate(1 / sqrt(4 - 9 * x**2),
                           x) == asin(x * Rational(3, 2)) / 3

    # asinh
    assert manualintegrate(1/sqrt(x**2 + 1), x) == \
        asinh(x)
    assert manualintegrate(1/sqrt(x**2 + 4), x) == \
        asinh(x/2)
    assert manualintegrate(1/sqrt(4*x**2 + 4), x) == \
        asinh(x)/2
    assert manualintegrate(1/sqrt(4*x**2 + 1), x) == \
        asinh(2*x)/2
    assert manualintegrate(1/sqrt(a*x**2 + 1), x) == \
        Piecewise((sqrt(-1/a)*asin(x*sqrt(-a)), a < 0), (sqrt(1/a)*asinh(sqrt(a)*x), a > 0))
    assert manualintegrate(1/sqrt(a + x**2), x) == \
        Piecewise((asinh(x*sqrt(1/a)), a > 0), (acosh(x*sqrt(-1/a)), a < 0))

    # acosh
    assert manualintegrate(1/sqrt(x**2 - 1), x) == \
        acosh(x)
    assert manualintegrate(1/sqrt(x**2 - 4), x) == \
        acosh(x/2)
    assert manualintegrate(1/sqrt(4*x**2 - 4), x) == \
        acosh(x)/2
    assert manualintegrate(1/sqrt(9*x**2 - 1), x) == \
        acosh(3*x)/3
    assert manualintegrate(1/sqrt(a*x**2 - 4), x) == \
        Piecewise((sqrt(1/a)*acosh(sqrt(a)*x/2), a > 0))
    assert manualintegrate(1/sqrt(-a + 4*x**2), x) == \
        Piecewise((asinh(2*x*sqrt(-1/a))/2, -a > 0), (acosh(2*x*sqrt(1/a))/2, -a < 0))

    # From https://www.wikiwand.com/en/List_of_integrals_of_inverse_trigonometric_functions
    # asin
    assert manualintegrate(asin(x), x) == x * asin(x) + sqrt(1 - x**2)
    assert manualintegrate(asin(a * x), x) == Piecewise(
        ((a * x * asin(a * x) + sqrt(-a**2 * x**2 + 1)) / a, Ne(a, 0)),
        (0, True))
    assert manualintegrate(x * asin(a * x), x) == -a * Integral(
        x**2 / sqrt(-a**2 * x**2 + 1), x) / 2 + x**2 * asin(a * x) / 2
    # acos
    assert manualintegrate(acos(x), x) == x * acos(x) - sqrt(1 - x**2)
    assert manualintegrate(acos(a * x), x) == Piecewise(
        ((a * x * acos(a * x) - sqrt(-a**2 * x**2 + 1)) / a, Ne(a, 0)),
        (pi * x / 2, True))
    assert manualintegrate(x * acos(a * x), x) == a * Integral(
        x**2 / sqrt(-a**2 * x**2 + 1), x) / 2 + x**2 * acos(a * x) / 2
    # atan
    assert manualintegrate(atan(x), x) == x * atan(x) - log(x**2 + 1) / 2
    assert manualintegrate(atan(a * x), x) == Piecewise(
        ((a * x * atan(a * x) - log(a**2 * x**2 + 1) / 2) / a, Ne(a, 0)),
        (0, True))
    assert manualintegrate(
        x * atan(a * x),
        x) == -a * (x / a**2 - atan(x / sqrt(a**(-2))) /
                    (a**4 * sqrt(a**(-2)))) / 2 + x**2 * atan(a * x) / 2
    # acsc
    assert manualintegrate(
        acsc(x), x) == x * acsc(x) + Integral(1 / (x * sqrt(1 - 1 / x**2)), x)
    assert manualintegrate(
        acsc(a * x),
        x) == x * acsc(a * x) + Integral(1 / (x * sqrt(1 - 1 /
                                                       (a**2 * x**2))), x) / a
    assert manualintegrate(x * acsc(a * x),
                           x) == x**2 * acsc(a * x) / 2 + Integral(
                               1 / sqrt(1 - 1 / (a**2 * x**2)), x) / (2 * a)
    # asec
    assert manualintegrate(
        asec(x), x) == x * asec(x) - Integral(1 / (x * sqrt(1 - 1 / x**2)), x)
    assert manualintegrate(
        asec(a * x),
        x) == x * asec(a * x) - Integral(1 / (x * sqrt(1 - 1 /
                                                       (a**2 * x**2))), x) / a
    assert manualintegrate(x * asec(a * x),
                           x) == x**2 * asec(a * x) / 2 - Integral(
                               1 / sqrt(1 - 1 / (a**2 * x**2)), x) / (2 * a)
    # acot
    assert manualintegrate(acot(x), x) == x * acot(x) + log(x**2 + 1) / 2
    assert manualintegrate(acot(a * x), x) == Piecewise(
        ((a * x * acot(a * x) + log(a**2 * x**2 + 1) / 2) / a, Ne(a, 0)),
        (pi * x / 2, True))
    assert manualintegrate(
        x * acot(a * x),
        x) == a * (x / a**2 - atan(x / sqrt(a**(-2))) /
                   (a**4 * sqrt(a**(-2)))) / 2 + x**2 * acot(a * x) / 2

    # piecewise
    assert manualintegrate(1/sqrt(a-b*x**2), x) == \
        Piecewise((sqrt(a/b)*asin(x*sqrt(b/a))/sqrt(a), And(-b < 0, a > 0)),
                  (sqrt(-a/b)*asinh(x*sqrt(-b/a))/sqrt(a), And(-b > 0, a > 0)),
                  (sqrt(a/b)*acosh(x*sqrt(b/a))/sqrt(-a), And(-b > 0, a < 0)))
    assert manualintegrate(1/sqrt(a + b*x**2), x) == \
        Piecewise((sqrt(-a/b)*asin(x*sqrt(-b/a))/sqrt(a), And(a > 0, b < 0)),
                  (sqrt(a/b)*asinh(x*sqrt(b/a))/sqrt(a), And(a > 0, b > 0)),
                  (sqrt(-a/b)*acosh(x*sqrt(-b/a))/sqrt(-a), And(a < 0, b > 0)))