示例#1
0
def test_manualintegrate_rational():
    assert manualintegrate(1 / (4 - x ** 2), x) == Piecewise(
        (acoth(x / 2) / 2, x ** 2 > 4), (atanh(x / 2) / 2, x ** 2 < 4)
    )
    assert manualintegrate(1 / (-1 + x ** 2), x) == Piecewise(
        (-acoth(x), x ** 2 > 1), (-atanh(x), x ** 2 < 1)
    )
示例#2
0
def test_issue_10847():
    assert manualintegrate(x**2 / (x**2 - c), x) == c*Piecewise((atan(x/sqrt(-c))/sqrt(-c), -c > 0), \
                                                                (-acoth(x/sqrt(c))/sqrt(c), And(-c < 0, x**2 > c)), \
                                                                (-atanh(x/sqrt(c))/sqrt(c), And(-c < 0, x**2 < c))) + x
    assert manualintegrate(sqrt(x - y) * log(z / x), x) == 4*y**2*Piecewise((atan(sqrt(x - y)/sqrt(y))/sqrt(y), y > 0), \
                                                                            (-acoth(sqrt(x - y)/sqrt(-y))/sqrt(-y), \
                                                                             And(x - y > -y, y < 0)), \
                                                                            (-atanh(sqrt(x - y)/sqrt(-y))/sqrt(-y), \
                                                                             And(x - y < -y, y < 0)))/3 \
                                                                             - 4*y*sqrt(x - y)/3 + 2*(x - y)**(3/2)*log(z/x)/3 \
                                                                             + 4*(x - y)**(3/2)/9

    assert manualintegrate(sqrt(x) * log(x), x) == 2*x**(3/2)*log(x)/3 - 4*x**(3/2)/9
    assert manualintegrate(sqrt(a*x + b) / x, x) == -2*b*Piecewise((-atan(sqrt(a*x + b)/sqrt(-b))/sqrt(-b), -b > 0), \
                                                               (acoth(sqrt(a*x + b)/sqrt(b))/sqrt(b), And(-b < 0, a*x + b > b)), \
                                                               (atanh(sqrt(a*x + b)/sqrt(b))/sqrt(b), And(-b < 0, a*x + b < b))) \
                                                               + 2*sqrt(a*x + b)

    assert expand(manualintegrate(sqrt(a*x + b) / (x + c), x)) == -2*a*c*Piecewise((atan(sqrt(a*x + b)/sqrt(a*c - b))/sqrt(a*c - b), \
        a*c - b > 0), (-acoth(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b > -a*c + b)), \
        (-atanh(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b < -a*c + b))) \
        + 2*b*Piecewise((atan(sqrt(a*x + b)/sqrt(a*c - b))/sqrt(a*c - b), a*c - b > 0), \
        (-acoth(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b > -a*c + b)), \
        (-atanh(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b < -a*c + b))) + 2*sqrt(a*x + b)

    assert manualintegrate((4*x**4 + 4*x**3 + 16*x**2 + 12*x + 8) \
                           / (x**6 + 2*x**5 + 3*x**4 + 4*x**3 + 3*x**2 + 2*x + 1), x) == \
                           2*x/(x**2 + 1) + 3*atan(x) - 1/(x**2 + 1) - 3/(x + 1)
    assert manualintegrate(sqrt(2*x + 3) / (x + 1), x) == 2*sqrt(2*x + 3) - log(sqrt(2*x + 3) + 1) + log(sqrt(2*x + 3) - 1)
    assert manualintegrate(sqrt(2*x + 3) / 2 * x, x) == (2*x + 3)**(5/2)/20 - (2*x + 3)**(3/2)/4
    assert manualintegrate(x**Rational(3,2) * log(x), x) == 2*x**Rational(5,2)*log(x)/5 - 4*x**Rational(5/2)/25
    assert manualintegrate(x**(-3) * log(x), x) == -log(x)/(2*x**2) - 1/(4*x**2)
    assert manualintegrate(log(y)/(y**2*(1 - 1/y)), y) == (-log(y) + log(y - 1))*log(y) + log(y)**2/2 - Integral(log(y - 1)/y, y)
示例#3
0
def test_issue_10847():
    assert manualintegrate(x**2 / (x**2 - c), x) == c*Piecewise((atan(x/sqrt(-c))/sqrt(-c), -c > 0), \
                                                                (-acoth(x/sqrt(c))/sqrt(c), And(-c < 0, x**2 > c)), \
                                                                (-atanh(x/sqrt(c))/sqrt(c), And(-c < 0, x**2 < c))) + x
    assert manualintegrate(sqrt(x - y) * log(z / x), x) == 4*y**2*Piecewise((atan(sqrt(x - y)/sqrt(y))/sqrt(y), y > 0), \
                                                                            (-acoth(sqrt(x - y)/sqrt(-y))/sqrt(-y), \
                                                                             And(x - y > -y, y < 0)), \
                                                                            (-atanh(sqrt(x - y)/sqrt(-y))/sqrt(-y), \
                                                                             And(x - y < -y, y < 0)))/3 \
                                                                             - 4*y*sqrt(x - y)/3 + 2*(x - y)**(S(3)/2)*log(z/x)/3 \
                                                                             + 4*(x - y)**(S(3)/2)/9

    assert manualintegrate(sqrt(x) * log(x), x) == 2*x**(S(3)/2)*log(x)/3 - 4*x**(S(3)/2)/9
    assert manualintegrate(sqrt(a*x + b) / x, x) == -2*b*Piecewise((-atan(sqrt(a*x + b)/sqrt(-b))/sqrt(-b), -b > 0), \
                                                               (acoth(sqrt(a*x + b)/sqrt(b))/sqrt(b), And(-b < 0, a*x + b > b)), \
                                                               (atanh(sqrt(a*x + b)/sqrt(b))/sqrt(b), And(-b < 0, a*x + b < b))) \
                                                               + 2*sqrt(a*x + b)

    assert expand(manualintegrate(sqrt(a*x + b) / (x + c), x)) == -2*a*c*Piecewise((atan(sqrt(a*x + b)/sqrt(a*c - b))/sqrt(a*c - b), \
        a*c - b > 0), (-acoth(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b > -a*c + b)), \
        (-atanh(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b < -a*c + b))) \
        + 2*b*Piecewise((atan(sqrt(a*x + b)/sqrt(a*c - b))/sqrt(a*c - b), a*c - b > 0), \
        (-acoth(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b > -a*c + b)), \
        (-atanh(sqrt(a*x + b)/sqrt(-a*c + b))/sqrt(-a*c + b), And(a*c - b < 0, a*x + b < -a*c + b))) + 2*sqrt(a*x + b)

    assert manualintegrate((4*x**4 + 4*x**3 + 16*x**2 + 12*x + 8) \
                           / (x**6 + 2*x**5 + 3*x**4 + 4*x**3 + 3*x**2 + 2*x + 1), x) == \
                           2*x/(x**2 + 1) + 3*atan(x) - 1/(x**2 + 1) - 3/(x + 1)
    assert manualintegrate(sqrt(2*x + 3) / (x + 1), x) == 2*sqrt(2*x + 3) - log(sqrt(2*x + 3) + 1) + log(sqrt(2*x + 3) - 1)
    assert manualintegrate(sqrt(2*x + 3) / 2 * x, x) == (2*x + 3)**(S(5)/2)/20 - (2*x + 3)**(S(3)/2)/4
    assert manualintegrate(x**Rational(3,2) * log(x), x) == 2*x**Rational(5,2)*log(x)/5 - 4*x**Rational(5,2)/25
    assert manualintegrate(x**(-3) * log(x), x) == -log(x)/(2*x**2) - 1/(4*x**2)
    assert manualintegrate(log(y)/(y**2*(1 - 1/y)), y) == \
        log(y)*log(-1 + 1/y) - Integral(log(-1 + 1/y)/y, y)
示例#4
0
文件: hyper.py 项目: ness01/sympy
    def _expr_big(cls, x, n):
        from sympy import acoth, sqrt, pi, I

        if n.is_even:
            return (acoth(sqrt(x)) + I * pi / 2) / sqrt(x)
        else:
            return (acoth(sqrt(x)) - I * pi / 2) / sqrt(x)
示例#5
0
def test_issue_10847():

    assert manualintegrate(x**2 / (x**2 - c),
                           x) == c * atan(x / sqrt(-c)) / sqrt(-c) + x

    rc = Symbol('c', real=True)
    assert manualintegrate(x**2 / (x**2 - rc), x) == \
        rc*Piecewise((atan(x/sqrt(-rc))/sqrt(-rc), -rc > 0),
                     (-acoth(x/sqrt(rc))/sqrt(rc), And(-rc < 0, x**2 > rc)),
                     (-atanh(x/sqrt(rc))/sqrt(rc), And(-rc < 0, x**2 < rc))) + x

    assert manualintegrate(sqrt(x - y) * log(z / x), x) == \
        4*y**Rational(3, 2)*atan(sqrt(x - y)/sqrt(y))/3 - 4*y*sqrt(x - y)/3 +\
        2*(x - y)**Rational(3, 2)*log(z/x)/3 + 4*(x - y)**Rational(3, 2)/9
    ry = Symbol('y', real=True)
    rz = Symbol('z', real=True)
    assert manualintegrate(sqrt(x - ry) * log(rz / x), x) == \
        4*ry**2*Piecewise((atan(sqrt(x - ry)/sqrt(ry))/sqrt(ry), ry > 0),
                         (-acoth(sqrt(x - ry)/sqrt(-ry))/sqrt(-ry), And(x - ry > -ry, ry < 0)),
                         (-atanh(sqrt(x - ry)/sqrt(-ry))/sqrt(-ry), And(x - ry < -ry, ry < 0)))/3 \
                         - 4*ry*sqrt(x - ry)/3 + 2*(x - ry)**Rational(3, 2)*log(rz/x)/3 \
                         + 4*(x - ry)**Rational(3, 2)/9

    assert manualintegrate(
        sqrt(x) * log(x),
        x) == 2 * x**Rational(3, 2) * log(x) / 3 - 4 * x**Rational(3, 2) / 9
    assert manualintegrate(sqrt(a*x + b) / x, x) == \
        2*b*atan(sqrt(a*x + b)/sqrt(-b))/sqrt(-b) + 2*sqrt(a*x + b)
    ra = Symbol('a', real=True)
    rb = Symbol('b', real=True)
    assert manualintegrate(sqrt(ra*x + rb) / x, x) == \
        -2*rb*Piecewise((-atan(sqrt(ra*x + rb)/sqrt(-rb))/sqrt(-rb), -rb > 0),
                        (acoth(sqrt(ra*x + rb)/sqrt(rb))/sqrt(rb), And(-rb < 0, ra*x + rb > rb)),
                        (atanh(sqrt(ra*x + rb)/sqrt(rb))/sqrt(rb), And(-rb < 0, ra*x + rb < rb))) \
                        + 2*sqrt(ra*x + rb)

    assert expand(manualintegrate(sqrt(ra*x + rb) / (x + rc), x)) == -2*ra*rc*Piecewise((atan(sqrt(ra*x + rb)/sqrt(ra*rc - rb))/sqrt(ra*rc - rb), \
        ra*rc - rb > 0), (-acoth(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb > -ra*rc + rb)), \
        (-atanh(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb < -ra*rc + rb))) \
        + 2*rb*Piecewise((atan(sqrt(ra*x + rb)/sqrt(ra*rc - rb))/sqrt(ra*rc - rb), ra*rc - rb > 0), \
        (-acoth(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb > -ra*rc + rb)), \
        (-atanh(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb < -ra*rc + rb))) + 2*sqrt(ra*x + rb)

    assert manualintegrate(
        sqrt(2 * x + 3) / (x + 1),
        x) == 2 * sqrt(2 * x + 3) - log(sqrt(2 * x + 3) +
                                        1) + log(sqrt(2 * x + 3) - 1)
    assert manualintegrate(
        sqrt(2 * x + 3) / 2 * x, x
    ) == (2 * x + 3)**Rational(5, 2) / 20 - (2 * x + 3)**Rational(3, 2) / 4
    assert manualintegrate(
        x**Rational(3, 2) * log(x),
        x) == 2 * x**Rational(5, 2) * log(x) / 5 - 4 * x**Rational(5, 2) / 25
    assert manualintegrate(x**(-3) * log(x),
                           x) == -log(x) / (2 * x**2) - 1 / (4 * x**2)
    assert manualintegrate(log(y)/(y**2*(1 - 1/y)), y) == \
        log(y)*log(-1 + 1/y) - Integral(log(-1 + 1/y)/y, y)
示例#6
0
def test_messy():
    from sympy import (laplace_transform, Si, Shi, Chi, atan, Piecewise,
                       acoth, E1, besselj, acosh, asin, And, re,
                       fourier_transform, sqrt)
    assert laplace_transform(Si(x), x, s) == ((-atan(s) + pi/2)/s, 0, True)

    assert laplace_transform(Shi(x), x, s) == (acoth(s)/s, 1, True)

    # where should the logs be simplified?
    assert laplace_transform(Chi(x), x, s) == \
        ((log(s**(-2)) - log((s**2 - 1)/s**2))/(2*s), 1, True)

    # TODO maybe simplify the inequalities?
    assert laplace_transform(besselj(a, x), x, s)[1:] == \
        (0, And(S(0) < re(a/2) + S(1)/2, S(0) < re(a/2) + 1))

    # NOTE s < 0 can be done, but argument reduction is not good enough yet
    assert fourier_transform(besselj(1, x)/x, x, s, noconds=False) == \
        (Piecewise((0, 4*abs(pi**2*s**2) > 1),
                   (2*sqrt(-4*pi**2*s**2 + 1), True)), s > 0)
    # TODO FT(besselj(0,x)) - conditions are messy (but for acceptable reasons)
    #                       - folding could be better

    assert integrate(E1(x)*besselj(0, x), (x, 0, oo), meijerg=True) == \
        log(1 + sqrt(2))
    assert integrate(E1(x)*besselj(1, x), (x, 0, oo), meijerg=True) == \
        log(S(1)/2 + sqrt(2)/2)

    assert integrate(1/x/sqrt(1 - x**2), x, meijerg=True) == \
        Piecewise((-acosh(1/x), 1 < abs(x**(-2))), (I*asin(1/x), True))
示例#7
0
def test_issue_6746():
    y = Symbol('y')
    n = Symbol('n')
    assert manualintegrate(y**x, x) == \
        Piecewise((x, Eq(log(y), 0)), (y**x/log(y), True))
    assert manualintegrate(y**(n*x), x) == \
        Piecewise(
            (x, Eq(n, 0)),
            (Piecewise(
                (n*x, Eq(log(y), 0)),
                (y**(n*x)/log(y), True))/n, True))
    assert manualintegrate(exp(n*x), x) == \
        Piecewise((x, Eq(n, 0)), (exp(n*x)/n, True))

    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**x, x) == (y + 1)**x/log(y + 1)
    y = Symbol('y', zero=True)
    assert manualintegrate((y + 1)**x, x) == x
    y = Symbol('y')
    n = Symbol('n', nonzero=True)
    assert manualintegrate(y**(n*x), x) == \
        Piecewise((n*x, Eq(log(y), 0)), (y**(n*x)/log(y), True))/n
    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**(n*x), x) == \
        (y + 1)**(n*x)/(n*log(y + 1))
    a = Symbol('a', negative=True)
    assert manualintegrate(1 / (a + b*x**2), x) == \
        Piecewise((atan(x/sqrt(a/b))/(b*sqrt(a/b)), a/b > 0), \
        (-acoth(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 > -a/b)), \
        (-atanh(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 < -a/b)))
示例#8
0
def test_messy():
    from sympy import (laplace_transform, Si, Shi, Chi, atan, Piecewise, acoth,
                       E1, besselj, acosh, asin, And, re, fourier_transform,
                       sqrt)
    assert laplace_transform(Si(x), x, s) == ((-atan(s) + pi / 2) / s, 0, True)

    assert laplace_transform(Shi(x), x, s) == (acoth(s) / s, 1, True)

    # where should the logs be simplified?
    assert laplace_transform(Chi(x), x, s) == \
        ((log(s**(-2)) - log((s**2 - 1)/s**2))/(2*s), 1, True)

    # TODO maybe simplify the inequalities?
    assert laplace_transform(besselj(a, x), x, s)[1:] == \
        (0, And(S(0) < re(a/2) + S(1)/2, S(0) < re(a/2) + 1))

    # NOTE s < 0 can be done, but argument reduction is not good enough yet
    assert fourier_transform(besselj(1, x)/x, x, s, noconds=False) == \
        (Piecewise((0, 4*abs(pi**2*s**2) > 1),
                   (2*sqrt(-4*pi**2*s**2 + 1), True)), s > 0)
    # TODO FT(besselj(0,x)) - conditions are messy (but for acceptable reasons)
    #                       - folding could be better

    assert integrate(E1(x)*besselj(0, x), (x, 0, oo), meijerg=True) == \
        log(1 + sqrt(2))
    assert integrate(E1(x)*besselj(1, x), (x, 0, oo), meijerg=True) == \
        log(S(1)/2 + sqrt(2)/2)

    assert integrate(1/x/sqrt(1 - x**2), x, meijerg=True) == \
        Piecewise((-acosh(1/x), 1 < abs(x**(-2))), (I*asin(1/x), True))
    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)'
示例#10
0
def test_issue_6746():
    y = Symbol('y')
    n = Symbol('n')
    assert manualintegrate(y**x, x) == \
        Piecewise((x, Eq(log(y), 0)), (y**x/log(y), True))
    assert manualintegrate(y**(n*x), x) == \
        Piecewise(
            (x, Eq(n, 0)),
            (Piecewise(
                (n*x, Eq(log(y), 0)),
                (y**(n*x)/log(y), True))/n, True))
    assert manualintegrate(exp(n*x), x) == \
        Piecewise((x, Eq(n, 0)), (exp(n*x)/n, True))

    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**x, x) == (y + 1)**x / log(y + 1)
    y = Symbol('y', zero=True)
    assert manualintegrate((y + 1)**x, x) == x
    y = Symbol('y')
    n = Symbol('n', nonzero=True)
    assert manualintegrate(y**(n*x), x) == \
        Piecewise((n*x, Eq(log(y), 0)), (y**(n*x)/log(y), True))/n
    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**(n*x), x) == \
        (y + 1)**(n*x)/(n*log(y + 1))
    a = Symbol('a', negative=True)
    assert manualintegrate(1 / (a + b*x**2), x) == \
        Piecewise((atan(x/sqrt(a/b))/(b*sqrt(a/b)), a/b > 0), \
        (-acoth(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 > -a/b)), \
        (-atanh(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 < -a/b)))
示例#11
0
def test_acot():
    assert acot(nan) == nan

    assert acot(-oo) == 0
    assert acot(oo) == 0
    assert acot(1) == pi / 4
    assert acot(0) == pi / 2
    assert acot(sqrt(3) / 3) == pi / 3
    assert acot(1 / sqrt(3)) == pi / 3
    assert acot(-1 / sqrt(3)) == -pi / 3
    assert acot(x).diff(x) == -1 / (1 + x**2)

    assert acot(r).is_real is True

    assert acot(I * pi) == -I * acoth(pi)
    assert acot(-2 * I) == I * acoth(2)
示例#12
0
def test_acot():
    assert acot(nan) == nan

    assert acot(-oo) == 0
    assert acot(oo) == 0
    assert acot(1) == pi/4
    assert acot(0) == pi/2
    assert acot(sqrt(3)/3) == pi/3
    assert acot(1/sqrt(3)) == pi/3
    assert acot(-1/sqrt(3)) == -pi/3
    assert acot(x).diff(x) == -1/(1 + x**2)

    assert acot(r).is_real is True

    assert acot(I*pi) == -I*acoth(pi)
    assert acot(-2*I) == I*acoth(2)
示例#13
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)
示例#14
0
def test_hyperbolic():
    x = Symbol("x")
    assert sinh(x).nseries(x, 0, 6) == x + x**3/6 + x**5/120 + O(x**6)
    assert cosh(x).nseries(x, 0, 5) == 1 + x**2/2 + x**4/24 + O(x**5)
    assert tanh(x).nseries(x, 0, 6) == x - x**3/3 + 2*x**5/15 + O(x**6)
    assert coth(x).nseries(x, 0, 6) == 1/x - x**3/45 + x/3 + 2*x**5/945 + O(x**6)
    assert asinh(x).nseries(x, 0, 6) == x - x**3/6 + 3*x**5/40 + O(x**6)
    assert acosh(x).nseries(x, 0, 6) == pi*I/2 - I*x - 3*I*x**5/40 - I*x**3/6 + O(x**6)
    assert atanh(x).nseries(x, 0, 6) == x + x**3/3 + x**5/5 + O(x**6)
    assert acoth(x).nseries(x, 0, 6) == x + x**3/3 + x**5/5 + pi*I/2 + O(x**6)
示例#15
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
示例#16
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 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)
示例#17
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
示例#18
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 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)
示例#19
0
def test_conv12b():
    x = sympy.Symbol("x")
    y = sympy.Symbol("y")
    assert sympify(sympy.sinh(x/3)) == sinh(Symbol("x") / 3)
    assert sympify(sympy.cosh(x/3)) == cosh(Symbol("x") / 3)
    assert sympify(sympy.tanh(x/3)) == tanh(Symbol("x") / 3)
    assert sympify(sympy.coth(x/3)) == coth(Symbol("x") / 3)
    assert sympify(sympy.asinh(x/3)) == asinh(Symbol("x") / 3)
    assert sympify(sympy.acosh(x/3)) == acosh(Symbol("x") / 3)
    assert sympify(sympy.atanh(x/3)) == atanh(Symbol("x") / 3)
    assert sympify(sympy.acoth(x/3)) == acoth(Symbol("x") / 3)
示例#20
0
def test_conv12b():
    x = sympy.Symbol("x")
    y = sympy.Symbol("y")
    assert sympify(sympy.sinh(x / 3)) == sinh(Symbol("x") / 3)
    assert sympify(sympy.cosh(x / 3)) == cosh(Symbol("x") / 3)
    assert sympify(sympy.tanh(x / 3)) == tanh(Symbol("x") / 3)
    assert sympify(sympy.coth(x / 3)) == coth(Symbol("x") / 3)
    assert sympify(sympy.asinh(x / 3)) == asinh(Symbol("x") / 3)
    assert sympify(sympy.acosh(x / 3)) == acosh(Symbol("x") / 3)
    assert sympify(sympy.atanh(x / 3)) == atanh(Symbol("x") / 3)
    assert sympify(sympy.acoth(x / 3)) == acoth(Symbol("x") / 3)
示例#21
0
def test_acot():
    assert acot(nan) == nan

    assert acot.nargs == FiniteSet(1)
    assert acot(-oo) == 0
    assert acot(oo) == 0
    assert acot(1) == pi/4
    assert acot(0) == pi/2
    assert acot(sqrt(3)/3) == pi/3
    assert acot(1/sqrt(3)) == pi/3
    assert acot(-1/sqrt(3)) == -pi/3
    assert acot(x).diff(x) == -1/(1 + x**2)

    assert acot(r).is_real is True

    assert acot(I*pi) == -I*acoth(pi)
    assert acot(-2*I) == I*acoth(2)
    assert acot(x).is_positive is None
    assert acot(r).is_positive is True
    assert acot(p).is_positive is True
    assert acot(I).is_positive is False
示例#22
0
def test_leading_term():
    x = Symbol('x')
    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, S.Half):
            eq = func(arg)
            assert eq.as_leading_term(x) == eq
示例#23
0
def test_leading_term():
    x = Symbol('x')
    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, S.Half):
            eq = func(arg)
            assert eq.as_leading_term(x) == eq
示例#24
0
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
示例#25
0
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
示例#26
0
def test_acot():
    assert acot(nan) == nan

    assert acot.nargs == FiniteSet(1)
    assert acot(-oo) == 0
    assert acot(oo) == 0
    assert acot(1) == pi / 4
    assert acot(0) == pi / 2
    assert acot(sqrt(3) / 3) == pi / 3
    assert acot(1 / sqrt(3)) == pi / 3
    assert acot(-1 / sqrt(3)) == -pi / 3
    assert acot(x).diff(x) == -1 / (1 + x**2)

    assert acot(r).is_real is True

    assert acot(I * pi) == -I * acoth(pi)
    assert acot(-2 * I) == I * acoth(2)
    assert acot(x).is_positive is None
    assert acot(r).is_positive is True
    assert acot(p).is_positive is True
    assert acot(I).is_positive is False
示例#27
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))
    assert acsch(x).diff(x) == -1 / (x**2 * sqrt(1 + x**(-2)))
示例#28
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))
    assert acsch(x).diff(x) == -1/(x**2*sqrt(1 + x**(-2)))
示例#29
0
def test_conv12():
    x = Symbol("x")
    y = Symbol("y")
    assert sinh(x / 3) == sinh(sympy.Symbol("x") / 3)
    assert cosh(x / 3) == cosh(sympy.Symbol("x") / 3)
    assert tanh(x / 3) == tanh(sympy.Symbol("x") / 3)
    assert coth(x / 3) == coth(sympy.Symbol("x") / 3)
    assert asinh(x / 3) == asinh(sympy.Symbol("x") / 3)
    assert acosh(x / 3) == acosh(sympy.Symbol("x") / 3)
    assert atanh(x / 3) == atanh(sympy.Symbol("x") / 3)
    assert acoth(x / 3) == acoth(sympy.Symbol("x") / 3)

    assert sinh(x / 3)._sympy_() == sympy.sinh(sympy.Symbol("x") / 3)
    assert cosh(x / 3)._sympy_() == sympy.cosh(sympy.Symbol("x") / 3)
    assert tanh(x / 3)._sympy_() == sympy.tanh(sympy.Symbol("x") / 3)
    assert coth(x / 3)._sympy_() == sympy.coth(sympy.Symbol("x") / 3)
    assert asinh(x / 3)._sympy_() == sympy.asinh(sympy.Symbol("x") / 3)
    assert acosh(x / 3)._sympy_() == sympy.acosh(sympy.Symbol("x") / 3)
    assert atanh(x / 3)._sympy_() == sympy.atanh(sympy.Symbol("x") / 3)
    assert acoth(x / 3)._sympy_() == sympy.acoth(sympy.Symbol("x") / 3)
示例#30
0
def test_conv12():
    x = Symbol("x")
    y = Symbol("y")
    assert sinh(x/3) == sinh(sympy.Symbol("x") / 3)
    assert cosh(x/3) == cosh(sympy.Symbol("x") / 3)
    assert tanh(x/3) == tanh(sympy.Symbol("x") / 3)
    assert coth(x/3) == coth(sympy.Symbol("x") / 3)
    assert asinh(x/3) == asinh(sympy.Symbol("x") / 3)
    assert acosh(x/3) == acosh(sympy.Symbol("x") / 3)
    assert atanh(x/3) == atanh(sympy.Symbol("x") / 3)
    assert acoth(x/3) == acoth(sympy.Symbol("x") / 3)

    assert sinh(x/3)._sympy_() == sympy.sinh(sympy.Symbol("x") / 3)
    assert cosh(x/3)._sympy_() == sympy.cosh(sympy.Symbol("x") / 3)
    assert tanh(x/3)._sympy_() == sympy.tanh(sympy.Symbol("x") / 3)
    assert coth(x/3)._sympy_() == sympy.coth(sympy.Symbol("x") / 3)
    assert asinh(x/3)._sympy_() == sympy.asinh(sympy.Symbol("x") / 3)
    assert acosh(x/3)._sympy_() == sympy.acosh(sympy.Symbol("x") / 3)
    assert atanh(x/3)._sympy_() == sympy.atanh(sympy.Symbol("x") / 3)
    assert acoth(x/3)._sympy_() == sympy.acoth(sympy.Symbol("x") / 3)
示例#31
0
def test_issue_6746():
    y = Symbol('y')
    n = Symbol('n')
    assert manualintegrate(y**x, x) == \
        Piecewise((x, Eq(log(y), 0)), (y**x/log(y), True))
    assert manualintegrate(y**(n*x), x) == \
        Piecewise(
            (x, Eq(n, 0)),
            (Piecewise(
                (n*x, Eq(log(y), 0)),
                (y**(n*x)/log(y), True))/n, True))
    assert manualintegrate(exp(n*x), x) == \
        Piecewise((x, Eq(n, 0)), (exp(n*x)/n, True))

    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**x, x) == (y + 1)**x / log(y + 1)
    y = Symbol('y', zero=True)
    assert manualintegrate((y + 1)**x, x) == x
    y = Symbol('y')
    n = Symbol('n', nonzero=True)
    assert manualintegrate(y**(n*x), x) == \
        Piecewise((n*x, Eq(log(y), 0)), (y**(n*x)/log(y), True))/n
    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**(n*x), x) == \
        (y + 1)**(n*x)/(n*log(y + 1))
    a = Symbol('a', negative=True)
    b = Symbol('b')
    assert manualintegrate(1/(a + b*x**2), x) == \
        Piecewise((atan(x/sqrt(a/b))/(b*sqrt(a/b)), a/b > 0), \
        (-acoth(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 > -a/b)), \
        (-atanh(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 < -a/b)))
    b = Symbol('b', negative=True)
    assert manualintegrate(1/(a + b*x**2), x) == \
        atan(x/(sqrt(-a)*sqrt(-1/b)))/(b*sqrt(-a)*sqrt(-1/b))
    assert manualintegrate(1/((x**a + y**b + 4)*sqrt(a*x**2 + 1)), x) == \
        y**(-b)*Integral(x**(-a)/(y**(-b)*sqrt(a*x**2 + 1) +
        x**(-a)*sqrt(a*x**2 + 1) + 4*x**(-a)*y**(-b)*sqrt(a*x**2 + 1)), x)
    assert manualintegrate(1/((x**2 + 4)*sqrt(4*x**2 + 1)), x) == \
        Integral(1/((x**2 + 4)*sqrt(4*x**2 + 1)), x)
    assert manualintegrate(1/(x - a**x + x*b**2), x) == \
        Integral(1/(-a**x + b**2*x + x), x)
示例#32
0
def test_issue_6746():
    y = Symbol('y')
    n = Symbol('n')
    assert manualintegrate(y**x, x) == Piecewise(
        (y**x/log(y), Ne(log(y), 0)), (x, True))
    assert manualintegrate(y**(n*x), x) == Piecewise(
        (Piecewise(
            (y**(n*x)/log(y), Ne(log(y), 0)),
            (n*x, True)
        )/n, Ne(n, 0)),
        (x, True))
    assert manualintegrate(exp(n*x), x) == Piecewise(
        (exp(n*x)/n, Ne(n, 0)), (x, True))

    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**x, x) == (y + 1)**x/log(y + 1)
    y = Symbol('y', zero=True)
    assert manualintegrate((y + 1)**x, x) == x
    y = Symbol('y')
    n = Symbol('n', nonzero=True)
    assert manualintegrate(y**(n*x), x) == Piecewise(
        (y**(n*x)/log(y), Ne(log(y), 0)), (n*x, True))/n
    y = Symbol('y', positive=True)
    assert manualintegrate((y + 1)**(n*x), x) == \
        (y + 1)**(n*x)/(n*log(y + 1))
    a = Symbol('a', negative=True)
    b = Symbol('b')
    assert manualintegrate(1/(a + b*x**2), x) == \
        Piecewise((atan(x/sqrt(a/b))/(b*sqrt(a/b)), a/b > 0), \
        (-acoth(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 > -a/b)), \
        (-atanh(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 < -a/b)))
    b = Symbol('b', negative=True)
    assert manualintegrate(1/(a + b*x**2), x) == \
        atan(x/(sqrt(-a)*sqrt(-1/b)))/(b*sqrt(-a)*sqrt(-1/b))
    assert manualintegrate(1/((x**a + y**b + 4)*sqrt(a*x**2 + 1)), x) == \
        y**(-b)*Integral(x**(-a)/(y**(-b)*sqrt(a*x**2 + 1) +
        x**(-a)*sqrt(a*x**2 + 1) + 4*x**(-a)*y**(-b)*sqrt(a*x**2 + 1)), x)
    assert manualintegrate(1/((x**2 + 4)*sqrt(4*x**2 + 1)), x) == \
        Integral(1/((x**2 + 4)*sqrt(4*x**2 + 1)), x)
    assert manualintegrate(1/(x - a**x + x*b**2), x) == \
        Integral(1/(-a**x + b**2*x + x), x)
示例#33
0
def eval_arccoth(a, b, c, integrand, symbol):
    return -a / b * 1 / sympy.sqrt(-c / b) * sympy.acoth(symbol / sympy.sqrt(-c / b))
示例#34
0
def test_acoth_rewrite():
    x = Symbol('x')
    assert acoth(x).rewrite(log) == (log(1 + 1/x) - log(1 - 1/x)) / 2
示例#35
0
def test_acoth():
    x = Symbol('x')

    #at specific points
    assert acoth(0) == I * pi / 2
    assert acoth(I) == -I * pi / 4
    assert acoth(-I) == I * pi / 4
    assert acoth(1) == oo
    assert acoth(-1) == -oo
    assert acoth(nan) == nan

    # at infinites
    assert acoth(oo) == 0
    assert acoth(-oo) == 0
    assert acoth(I * oo) == 0
    assert acoth(-I * oo) == 0
    assert acoth(zoo) == 0

    #properties
    assert acoth(-x) == -acoth(x)

    assert acoth(I / sqrt(3)) == -I * pi / 3
    assert acoth(-I / sqrt(3)) == I * pi / 3
    assert acoth(I * sqrt(3)) == -I * pi / 6
    assert acoth(-I * sqrt(3)) == I * pi / 6
    assert acoth(I * (1 + sqrt(2))) == -pi * I / 8
    assert acoth(-I * (sqrt(2) + 1)) == pi * I / 8
    assert acoth(I * (1 - sqrt(2))) == 3 * pi * I / 8
    assert acoth(I * (sqrt(2) - 1)) == -3 * pi * I / 8
    assert acoth(I * sqrt(5 + 2 * sqrt(5))) == -I * pi / 10
    assert acoth(-I * sqrt(5 + 2 * sqrt(5))) == I * pi / 10
    assert acoth(I * (2 + sqrt(3))) == -pi * I / 12
    assert acoth(-I * (2 + sqrt(3))) == pi * I / 12
    assert acoth(I * (2 - sqrt(3))) == -5 * pi * I / 12
    assert acoth(I * (sqrt(3) - 2)) == 5 * pi * I / 12

    # Symmetry
    assert acoth(-S.Half) == -acoth(S.Half)
示例#36
0
def test_acoth_rewrite():
    x = Symbol('x')
    assert acoth(x).rewrite(log) == (log(1 + 1 / x) - log(1 - 1 / x)) / 2
示例#37
0
文件: hyper.py 项目: hunteke/sympy
 def _expr_big(cls, x, n):
     from sympy import acoth, sqrt, pi, I
     if n.is_even:
         return (acoth(sqrt(x)) + I*pi/2)/sqrt(x)
     else:
         return (acoth(sqrt(x)) - I*pi/2)/sqrt(x)
示例#38
0
def test_acoth():
    x = Symbol("x")
    assert acoth(0) == I * pi / 2
    assert acoth(I) == -I * pi / 4
    assert acoth(-I) == I * pi / 4
    assert acoth(-x) == -acoth(x)
示例#39
0
def test_acoth():
    x = Symbol('x')

    #at specific points
    assert acoth(0) == I*pi/2
    assert acoth(I) == -I*pi/4
    assert acoth(-I) == I*pi/4
    assert acoth(1) is oo
    assert acoth(-1) is -oo
    assert acoth(nan) is nan

    # at infinites
    assert acoth(oo) == 0
    assert acoth(-oo) == 0
    assert acoth(I*oo) == 0
    assert acoth(-I*oo) == 0
    assert acoth(zoo) == 0

    #properties
    assert acoth(-x) == -acoth(x)

    assert acoth(I/sqrt(3)) == -I*pi/3
    assert acoth(-I/sqrt(3)) == I*pi/3
    assert acoth(I*sqrt(3)) == -I*pi/6
    assert acoth(-I*sqrt(3)) == I*pi/6
    assert acoth(I*(1 + sqrt(2))) == -pi*I/8
    assert acoth(-I*(sqrt(2) + 1)) == pi*I/8
    assert acoth(I*(1 - sqrt(2))) == pi*I*Rational(3, 8)
    assert acoth(I*(sqrt(2) - 1)) == pi*I*Rational(-3, 8)
    assert acoth(I*sqrt(5 + 2*sqrt(5))) == -I*pi/10
    assert acoth(-I*sqrt(5 + 2*sqrt(5))) == I*pi/10
    assert acoth(I*(2 + sqrt(3))) == -pi*I/12
    assert acoth(-I*(2 + sqrt(3))) == pi*I/12
    assert acoth(I*(2 - sqrt(3))) == pi*I*Rational(-5, 12)
    assert acoth(I*(sqrt(3) - 2)) == pi*I*Rational(5, 12)

    # Symmetry
    assert acoth(Rational(-1, 2)) == -acoth(S.Half)
示例#40
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))

    # 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)))
示例#41
0
def test_acoth():
    x = Symbol('x')

    #at specific points
    assert acoth(0) == I*pi/2
    assert acoth(I) == -I*pi/4
    assert acoth(-I) == I*pi/4
    assert acoth(1) == oo
    assert acoth(-1) == -oo

    # at infinites
    assert acoth(oo) == 0
    assert acoth(-oo) == 0
    assert acoth(I*oo) == 0
    assert acoth(-I*oo) == 0
    assert acoth(zoo) == 0

    #properties
    assert acoth(-x) == -acoth(x)

    assert acoth(I/sqrt(3)) == -I*pi/3
    assert acoth(-I/sqrt(3)) == I*pi/3
    assert acoth(I*sqrt(3)) == -I*pi/6
    assert acoth(-I*sqrt(3)) == I*pi/6
    assert acoth(I*(1 + sqrt(2))) == -pi*I/8
    assert acoth(-I*(sqrt(2) + 1)) == pi*I/8
    assert acoth(I*(1 - sqrt(2))) == 3*pi*I/8
    assert acoth(I*(sqrt(2) - 1)) == -3*pi*I/8
    assert acoth(I*sqrt(5 + 2*sqrt(5))) == -I*pi/10
    assert acoth(-I*sqrt(5 + 2*sqrt(5))) == I*pi/10
    assert acoth(I*(2 + sqrt(3))) == -pi*I/12
    assert acoth(-I*(2 + sqrt(3))) == pi*I/12
    assert acoth(I*(2 - sqrt(3))) == -5*pi*I/12
    assert acoth(I*(sqrt(3) - 2)) == 5*pi*I/12
示例#42
0
def test_acoth_series():
    x = Symbol('x')
    assert acoth(x).series(x, 0, 10) == \
        I*pi/2 + x + x**3/3 + x**5/5 + x**7/7 + x**9/9 + O(x**10)
示例#43
0
def test_acoth_noimpl():
    assert acoth(I / sqrt(3)) == -I * pi / 3
    assert acoth(-I / sqrt(3)) == I * pi / 3
    assert acoth(I * sqrt(3)) == -I * pi / 6
    assert acoth(-I * sqrt(3)) == I * pi / 6
    assert acoth(I * (1 + sqrt(2))) == -pi * I / 8
    assert acoth(-I * (sqrt(2) + 1)) == pi * I / 8
    assert acoth(I * (1 - sqrt(2))) == 3 * pi * I / 8
    assert acoth(I * (sqrt(2) - 1)) == -3 * pi * I / 8
    assert acoth(I * sqrt(5 + 2 * sqrt(5))) == -I * pi / 10
    assert acoth(-I * sqrt(5 + 2 * sqrt(5))) == I * pi / 10
    assert acoth(I * (2 + sqrt(3))) == -pi * I / 12
    assert acoth(-I * (2 + sqrt(3))) == pi * I / 12
    assert acoth(I * (2 - sqrt(3))) == -5 * pi * I / 12
    assert acoth(I * (sqrt(3) - 2)) == 5 * pi * I / 12
示例#44
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
    assert manualintegrate(1/(a + b*x**2), x) == \
        Piecewise((atan(x/sqrt(a/b))/(b*sqrt(a/b)), a/b > 0), \
                  (-acoth(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 > -a/b)), \
                  (-atanh(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 < -a/b)))
    assert manualintegrate(1/(4 + b*x**2), x) == \
        Piecewise((atan(x/(2*sqrt(1/b)))/(2*b*sqrt(1/b)), 4/b > 0), \
                  (-acoth(x/(2*sqrt(-1/b)))/(2*b*sqrt(-1/b)), And(4/b < 0, x**2 > -4/b)), \
                  (-atanh(x/(2*sqrt(-1/b)))/(2*b*sqrt(-1/b)), And(4/b < 0, x**2 < -4/b)))
    assert manualintegrate(1/(a + 4*x**2), x) == \
        Piecewise((atan(2*x/sqrt(a))/(2*sqrt(a)), a/4 > 0), \
                  (-acoth(2*x/sqrt(-a))/(2*sqrt(-a)), And(a/4 < 0, x**2 > -a/4)), \
                  (-atanh(2*x/sqrt(-a))/(2*sqrt(-a)), And(a/4 < 0, x**2 < -a/4)))
    assert manualintegrate(1 / (4 + 4 * x**2), x) == atan(x) / 4

    # 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(3 * x / 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))

    # 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)))
示例#45
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
    assert manualintegrate(1/(a + b*x**2), x) == \
        Piecewise((atan(x/sqrt(a/b))/(b*sqrt(a/b)), a/b > 0), \
                  (-acoth(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 > -a/b)), \
                  (-atanh(x/sqrt(-a/b))/(b*sqrt(-a/b)), And(a/b < 0, x**2 < -a/b)))
    assert manualintegrate(1/(4 + b*x**2), x) == \
        Piecewise((atan(x/(2*sqrt(1/b)))/(2*b*sqrt(1/b)), 4/b > 0), \
                  (-acoth(x/(2*sqrt(-1/b)))/(2*b*sqrt(-1/b)), And(4/b < 0, x**2 > -4/b)), \
                  (-atanh(x/(2*sqrt(-1/b)))/(2*b*sqrt(-1/b)), And(4/b < 0, x**2 < -4/b)))
    assert manualintegrate(1/(a + 4*x**2), x) == \
        Piecewise((atan(2*x/sqrt(a))/(2*sqrt(a)), a/4 > 0), \
                  (-acoth(2*x/sqrt(-a))/(2*sqrt(-a)), And(a/4 < 0, x**2 > -a/4)), \
                  (-atanh(2*x/sqrt(-a))/(2*sqrt(-a)), And(a/4 < 0, x**2 < -a/4)))
    assert manualintegrate(1/(4 + 4*x**2), x) == atan(x) / 4

    # 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(3*x/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))

    # 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)))
示例#46
0
def test_acoth():
    # TODO please write more tests  -- see issue 3751
    # From http://functions.wolfram.com/ElementaryFunctions/ArcCoth/03/01/
    # at specific points
    x = Symbol('x')

    #at specific points
    assert acoth(0) == I * pi / 2
    assert acoth(I) == -I * pi / 4
    assert acoth(-I) == I * pi / 4
    assert acoth(1) == oo
    assert acoth(-1) == -oo

    # at infinites
    assert acoth(oo) == 0
    assert acoth(-oo) == 0
    assert acoth(I * oo) == 0
    assert acoth(-I * oo) == 0
    assert acoth(zoo) == 0

    #properties
    assert acoth(-x) == -acoth(x)

    assert acoth(I / sqrt(3)) == -I * pi / 3
    assert acoth(-I / sqrt(3)) == I * pi / 3
    assert acoth(I * sqrt(3)) == -I * pi / 6
    assert acoth(-I * sqrt(3)) == I * pi / 6
    assert acoth(I * (1 + sqrt(2))) == -pi * I / 8
    assert acoth(-I * (sqrt(2) + 1)) == pi * I / 8
    assert acoth(I * (1 - sqrt(2))) == 3 * pi * I / 8
    assert acoth(I * (sqrt(2) - 1)) == -3 * pi * I / 8
    assert acoth(I * sqrt(5 + 2 * sqrt(5))) == -I * pi / 10
    assert acoth(-I * sqrt(5 + 2 * sqrt(5))) == I * pi / 10
    assert acoth(I * (2 + sqrt(3))) == -pi * I / 12
    assert acoth(-I * (2 + sqrt(3))) == pi * I / 12
    assert acoth(I * (2 - sqrt(3))) == -5 * pi * I / 12
    assert acoth(I * (sqrt(3) - 2)) == 5 * pi * I / 12
示例#47
0
def test_manualintegrate_rational():
    assert manualintegrate(1/(4 - x**2), x) == Piecewise((acoth(x/2)/2, x**2 > 4), (atanh(x/2)/2, x**2 < 4))
    assert manualintegrate(1/(-1 + x**2), x) == Piecewise((-acoth(x), x**2 > 1), (-atanh(x), x**2 < 1))
示例#48
0
def test_acoth_series():
    x = Symbol('x')
    assert acoth(x).series(x, 0, 10) == \
        I*pi/2 + x + x**3/3 + x**5/5 + x**7/7 + x**9/9 + O(x**10)
示例#49
0
def test_acoth():
    # TODO please write more tests  -- see #652
    # From http://functions.wolfram.com/ElementaryFunctions/ArcCoth/03/01/
    # at specific points
    x = Symbol('x')

    #at specific points
    assert acoth(0) == I*pi/2
    assert acoth(I) == -I*pi/4
    assert acoth(-I) == I*pi/4
    assert acoth(1) == oo
    assert acoth(-1) == -oo

    # at infinites
    assert acoth(oo) == 0
    assert acoth(-oo) == 0
    assert acoth(I*oo) == 0
    assert acoth(-I*oo) == 0

    #properties
    assert acoth(-x) == -acoth(x)
示例#50
0
def test_acoth():
    # TODO please write more tests  -- see #652
    # From http://functions.wolfram.com/ElementaryFunctions/ArcCoth/03/01/
    # at specific points
    x = Symbol('x')

    #at specific points
    assert acoth(0) == I * pi / 2
    assert acoth(I) == -I * pi / 4
    assert acoth(-I) == I * pi / 4
    assert acoth(1) == oo
    assert acoth(-1) == -oo

    # at infinites
    assert acoth(oo) == 0
    assert acoth(-oo) == 0
    assert acoth(I * oo) == 0
    assert acoth(-I * oo) == 0

    #properties
    assert acoth(-x) == -acoth(x)
示例#51
0
def test_acoth_fdiff():
    x = Symbol('x')
    raises(ArgumentIndexError, lambda: acoth(x).fdiff(2))
示例#52
0
def test_acoth_noimpl():
    assert acoth(I/sqrt(3)) == -I*pi/3
    assert acoth(-I/sqrt(3)) == I*pi/3
    assert acoth(I*sqrt(3)) == -I*pi/6
    assert acoth(-I*sqrt(3)) == I*pi/6
    assert acoth(I*(1+sqrt(2))) == -pi*I/8
    assert acoth(-I*(sqrt(2)+1)) == pi*I/8
    assert acoth(I*(1-sqrt(2))) == 3*pi*I/8
    assert acoth(I*(sqrt(2)-1)) == -3*pi*I/8
    assert acoth(I*sqrt(5+2*sqrt(5))) == -I*pi/10
    assert acoth(-I*sqrt(5+2*sqrt(5))) == I*pi/10
    assert acoth(I*(2+sqrt(3))) == -pi*I/12
    assert acoth(-I*(2+sqrt(3))) == pi*I/12
    assert acoth(I*(2-sqrt(3))) == -5*pi*I/12
    assert acoth(I*(sqrt(3)-2)) == 5*pi*I/12
示例#53
0
def eval_arccoth(a, b, c, integrand, symbol):
    return -a / b * 1 / sympy.sqrt(-c / b) * sympy.acoth(
        symbol / sympy.sqrt(-c / b))
示例#54
0
def test_acoth():
    # TODO please write more tests  -- see issue 3751
    # From http://functions.wolfram.com/ElementaryFunctions/ArcCoth/03/01/
    # at specific points
    x = Symbol('x')

    #at specific points
    assert acoth(0) == I*pi/2
    assert acoth(I) == -I*pi/4
    assert acoth(-I) == I*pi/4
    assert acoth(1) == oo
    assert acoth(-1) == -oo

    # at infinites
    assert acoth(oo) == 0
    assert acoth(-oo) == 0
    assert acoth(I*oo) == 0
    assert acoth(-I*oo) == 0
    assert acoth(zoo) == 0

    #properties
    assert acoth(-x) == -acoth(x)

    assert acoth(I/sqrt(3)) == -I*pi/3
    assert acoth(-I/sqrt(3)) == I*pi/3
    assert acoth(I*sqrt(3)) == -I*pi/6
    assert acoth(-I*sqrt(3)) == I*pi/6
    assert acoth(I*(1 + sqrt(2))) == -pi*I/8
    assert acoth(-I*(sqrt(2) + 1)) == pi*I/8
    assert acoth(I*(1 - sqrt(2))) == 3*pi*I/8
    assert acoth(I*(sqrt(2) - 1)) == -3*pi*I/8
    assert acoth(I*sqrt(5 + 2*sqrt(5))) == -I*pi/10
    assert acoth(-I*sqrt(5 + 2*sqrt(5))) == I*pi/10
    assert acoth(I*(2 + sqrt(3))) == -pi*I/12
    assert acoth(-I*(2 + sqrt(3))) == pi*I/12
    assert acoth(I*(2 - sqrt(3))) == -5*pi*I/12
    assert acoth(I*(sqrt(3) - 2)) == 5*pi*I/12