Esempio n. 1
0
    def _code_val(x):
        "Génère le code correspondant à une valeur `x` remarquable."
        if x in ens_def:
            # On calcule simplement f(x).
            fx = nice_str2(expr.subs(var, x))
        else:
            # x est une valeur interdite ou -oo ou +oo.
            symb = ('|' if x not in (-oo, oo) else '')
            gauche = droite = ''
            if limites:
                # On calcule la limite à gauche et/ou à droite.
                if x in sups:
                    gauche = nice_str2(limit(expr, var, x, dir = '-'))
                if x in infs:
                    droite = nice_str2(limit(expr, var, x, dir = '+'))
            fx = '%s%s%s' % (gauche, symb, droite)

        # Affichage de f'(x) (seulement si f'(x)=0 ou f'(x) non défini).
        if x in (-oo, oo):
            dfx = ''
        elif x in ens_def_df: # `oo in ens_def_df` plante actuellement (05/2014)
            dfx = ('0' if abs(df.subs(var, x).evalf()) < param.tolerance else '')
        else:
            dfx = '|'
        if dfx and derivee:
            return '(%s;%s;%s)' % (nice_str2(x), fx, dfx)
        else:
            return '(%s;%s)' % (nice_str2(x), fx)
Esempio n. 2
0
def test_Limits_simple_4a():
    a = Symbol('a', real=True)
    assert limit((sqrt(x)-sqrt(a))/(x-a),x,a)==1/(2*sqrt(a))  #Primer 5
    assert limit((sqrt(x)-1)/(sqrt3(x)-1),x,1)==Rational(3)/2  #205
    assert limit((sqrt(1+x)-sqrt(1-x))/x,x,0)==1  #207
    assert limit(sqrt(x**2-5*x+6)-x,x,oo)==-Rational(5)/2  #213
    assert limit(x*(sqrt(x**2+1)-x),x,oo)==Rational(1)/2  #214
Esempio n. 3
0
File: core.py Progetto: bcbnz/lcapy
    def residue(self, pole, poles):

        expr, var = self.expr, self.var

        # Remove pole from list of poles; sym.cancel
        # doesn't always work, for example, for complex poles.
        poles2 = poles.copy()
        poles2[pole] -= 1

        numer, denom = expr.as_numer_denom()
        D = sym.Poly(denom, var)
        K = D.LC()

        D = [(var - p) ** poles2[p] for p in poles2]
        denom = sym.Mul(K, *D)

        d = sym.limit(denom, var, pole)

        if d != 0:
            tmp = numer / denom
            return sym.limit(tmp, var, pole)

        print("Trying l'hopital's rule")
        tmp = numer / denom
        tmp = sym.diff(tmp, var)

        return sym.limit(tmp, var, pole)
Esempio n. 4
0
 def _calc_horizontal_asym(self, q, expr):
     # if the limit(x->+oo)=a, or limit(x->-oo)=a, then
     # y=a is a horizontal asymptote.
     debug('Looking for horizontal asymptotes for: ' +
           str(expr))
     try:
         poi = []
         lr = limit(expr, 'x', 'oo')
         ll = limit(expr, 'x', '-oo')
         if 'oo' not in str(lr):
             debug('Found a horizontal asymptote at y=' +
                   str(lr) + ' as x->+oo.')
             poi.append(POI(0, lr, 7))
         if 'oo' not in str(ll):
             if ll == lr:
                 debug('Same horizontal asymptote as x->-oo.')
             else:
                 debug('Found a horizontal asymptote at y=' +
                       str(ll) + ' as x->-oo')
                 poi.append(POI(0, ll, 7))
         q.put(poi)
     except NotImplementedError:
         debug('NotImplementedError for finding limit of "' +
               str(expr) + '"')
     if poi == []:
         debug('Done calculating horizontal asymptotes.' +
               'None found.')
     else:
         debug('Done calculating horizontal asymptotes')
Esempio n. 5
0
def test_exponential():
    n = Symbol('n')
    x = Symbol('x', real=True)
    assert limit((1+x/n)**n,n,oo) == exp(x)
    assert limit((1+x/(2*n))**n,n,oo) == exp(x/2)
    assert limit((1+x/(2*n+1))**n,n,oo) == exp(x/2)
    assert limit(((x-1)/(x+1))**x,x,oo) == exp(-2)
Esempio n. 6
0
def test_limit_seq():
    assert limit(Sum(1/x, (x, 1, y)) - log(y), y, oo) == EulerGamma
    assert limit(Sum(1/x, (x, 1, y)) - 1/y, y, oo) == S.Infinity
    assert (limit(binomial(2*x, x) / Sum(binomial(2*y, y), (y, 1, x)), x, oo) ==
            S(3) / 4)
    assert (limit(Sum(y**2 * Sum(2**z/z, (z, 1, y)), (y, 1, x)) /
                  (2**x*x), x, oo) == 4)
def test_erf():
    assert erf(nan) == nan

    assert erf(oo) == 1
    assert erf(-oo) == -1

    assert erf(0) == 0

    assert erf(I*oo) == oo*I
    assert erf(-I*oo) == -oo*I

    assert erf(-2) == -erf(2)
    assert erf(-x*y) == -erf(x*y)
    assert erf(-x - y) == -erf(x + y)

    assert erf(I).is_real == False
    assert erf(0).is_real == True

    assert conjugate(erf(z)) == erf(conjugate(z))

    assert erf(x).as_leading_term(x) == x
    assert erf(1/x).as_leading_term(x) == erf(1/x)

    assert erf(z).rewrite('uppergamma') == sqrt(z**2)*erf(sqrt(z**2))/z

    assert limit(exp(x)*exp(x**2)*(erf(x+1/exp(x))-erf(x)), x, oo) == 2/sqrt(pi)
    assert limit((1-erf(z))*exp(z**2)*z, z, oo) == 1/sqrt(pi)
    assert limit((1-erf(x))*exp(x**2)*sqrt(pi)*x, x, oo) == 1
    assert limit(((1-erf(x))*exp(x**2)*sqrt(pi)*x-1)*2*x**2, x, oo) == -1

    raises(ArgumentIndexError, 'erf(x).fdiff(2)')
Esempio n. 8
0
    def codomain_interval(f, set_val, *sym):
        symb = sym[0]
        df1 = diff(f, symb)
        df2 = diff(df1, symb)
        der_zero = solveset(df1, symb, domain=S.Reals)
        der_zero_in_dom = closure_handle(set_val, der_zero)

        local_maxima = set()
        local_minima = set()
        start_val = limit(f, symb, set_val.start)
        end_val = limit(f, symb, set_val.end, '-')

        if start_val is S.Infinity or end_val is S.Infinity:
            local_maxima = set([(oo, True)])
        elif start_val is S.NegativeInfinity or end_val is S.NegativeInfinity:
            local_minima = set([(-oo, True)])

        if (not start_val.is_real) or (not end_val.is_real):
            raise ValueError('Function does not contain all points of %s '
                            'as its domain' % (domain))

        if local_maxima == set():
            if start_val > end_val:
                local_maxima = set([(start_val, set_val.left_open)])
            elif start_val < end_val:
                local_maxima = set([(end_val, set_val.right_open)])
            else:
                local_maxima = set([(start_val, set_val.left_open and set_val.right_open)])

        if local_minima == set():
            if start_val < end_val:
                local_minima = set([(start_val, set_val.left_open)])
            elif start_val > end_val:
                local_minima = set([(end_val, set_val.right_open)])
            else:
                local_minima = set([(start_val, set_val.left_open and set_val.right_open)])

        for i in der_zero_in_dom:
            exist = not i in set_val
            if df2.subs({symb: i}) < 0:
                local_maxima.add((f.subs({symb: i}), exist))
            elif df2.subs({symb: i}) > 0:
                local_minima.add((f.subs({symb: i}), exist))

        maximum = (-oo, True)
        minimum = (oo, True)

        for i in local_maxima:
            if i[0] > maximum[0]:
                maximum = i
            elif i[0] == maximum[0]:
                maximum = (maximum[0], i[1] and maximum[1])

        for i in local_minima:
            if i[0] < minimum[0]:
                minimum = i
            elif i[0] == minimum[0]:
                minimum = (minimum[0], i[1] and minimum[1])

        return Union(Interval(minimum[0], maximum[0], minimum[1], maximum[1]))
def _limit(eq, *args, **kwargs):
    if isinstance(eq, sp.Eq):
        # The provided equation is an equality, so we need to process the limit
        # of each side independently.
        return sp.Eq(sp.limit(eq.lhs, *args, **kwargs),
                     sp.limit(eq.rhs, *args, **kwargs))
    else:
        return sp.limit(*args, **kwargs)
Esempio n. 10
0
def test_exponential():
    n = Symbol("n")
    x = Symbol("x", real=True)
    assert limit((1 + x / n) ** n, n, oo) == exp(x)
    assert limit((1 + x / (2 * n)) ** n, n, oo) == exp(x / 2)
    assert limit((1 + x / (2 * n + 1)) ** n, n, oo) == exp(x / 2)
    assert limit(((x - 1) / (x + 1)) ** x, x, oo) == exp(-2)
    assert limit(1 + (1 + 1 / x) ** x, x, oo) == 1 + S.Exp1
Esempio n. 11
0
def test_f1a():
    h = Symbol("h")
    #needs a special logic for deciding that sin(x) is bounded:
    assert limit(sin(x)/x,x,oo) == 0 #216b
    #needs a special logic for deciding that sin(x) is bounded:
    assert limit(x*sin(1/x),x,0) == 0 #227a
    #issue 409:
    assert limit((sin(2*x)/x)**(1+x),x,0) == 2 #Primer 7
    #issue 410:
    assert limit(((x-1)/(x+1))**x,x,oo) == exp(-2) #Primer 9
Esempio n. 12
0
def test_sympy():
    x = Symbol('x', real = True)
    assert -oo < oo
    assert not(-1.5 < -oo)
    assert (1 - exp(x)).is_negative is None
    assert Matrix([[1, 2], [3, 4]])**Integer(2) == Matrix([[7, 10], [15, 22]])
    assertAlmostEqual(E._evalf(50), math.e)
    assert solve(1/x, x) == [] # issue 1694
    assert solve(-(1 + x)/(2 + x)**2 + 1/(2 + x), x) == [] # issue 1694
    assert limit(1 + 1/x, x, 0, dir='-') == -oo
    assert limit(1/x**2, x, 0, dir='-') == oo
    assert sympify(u'45') == 45 # issue 2508
def test_erf():
    assert erf(nan) == nan

    assert erf(oo) == 1
    assert erf(-oo) == -1

    assert erf(0) == 0

    assert erf(I*oo) == oo*I
    assert erf(-I*oo) == -oo*I

    assert erf(-2) == -erf(2)
    assert erf(-x*y) == -erf(x*y)
    assert erf(-x - y) == -erf(x + y)

    assert erf(erfinv(x)) == x
    assert erf(erfcinv(x)) == 1 - x
    assert erf(erf2inv(0, x)) == x
    assert erf(erf2inv(0, erf(erfcinv(1 - erf(erfinv(x)))))) == x

    assert erf(I).is_real is False
    assert erf(0).is_real is True

    assert conjugate(erf(z)) == erf(conjugate(z))

    assert erf(x).as_leading_term(x) == 2*x/sqrt(pi)
    assert erf(1/x).as_leading_term(x) == erf(1/x)

    assert erf(z).rewrite('uppergamma') == sqrt(z**2)*(1 - erfc(sqrt(z**2)))/z
    assert erf(z).rewrite('erfc') == S.One - erfc(z)
    assert erf(z).rewrite('erfi') == -I*erfi(I*z)
    assert erf(z).rewrite('fresnels') == (1 + I)*(fresnelc(z*(1 - I)/sqrt(pi)) -
        I*fresnels(z*(1 - I)/sqrt(pi)))
    assert erf(z).rewrite('fresnelc') == (1 + I)*(fresnelc(z*(1 - I)/sqrt(pi)) -
        I*fresnels(z*(1 - I)/sqrt(pi)))
    assert erf(z).rewrite('hyper') == 2*z*hyper([S.Half], [3*S.Half], -z**2)/sqrt(pi)
    assert erf(z).rewrite('meijerg') == z*meijerg([S.Half], [], [0], [-S.Half], z**2)/sqrt(pi)
    assert erf(z).rewrite('expint') == sqrt(z**2)/z - z*expint(S.Half, z**2)/sqrt(S.Pi)

    assert limit(exp(x)*exp(x**2)*(erf(x + 1/exp(x)) - erf(x)), x, oo) == \
        2/sqrt(pi)
    assert limit((1 - erf(z))*exp(z**2)*z, z, oo) == 1/sqrt(pi)
    assert limit((1 - erf(x))*exp(x**2)*sqrt(pi)*x, x, oo) == 1
    assert limit(((1 - erf(x))*exp(x**2)*sqrt(pi)*x - 1)*2*x**2, x, oo) == -1

    assert erf(x).as_real_imag() == \
        ((erf(re(x) - I*re(x)*Abs(im(x))/Abs(re(x)))/2 +
         erf(re(x) + I*re(x)*Abs(im(x))/Abs(re(x)))/2,
         I*(erf(re(x) - I*re(x)*Abs(im(x))/Abs(re(x))) -
         erf(re(x) + I*re(x)*Abs(im(x))/Abs(re(x)))) *
         re(x)*Abs(im(x))/(2*im(x)*Abs(re(x)))))

    raises(ArgumentIndexError, lambda: erf(x).fdiff(2))
Esempio n. 14
0
def test_issue_5172():
    n = Symbol('n')
    r = Symbol('r', positive=True)
    c = Symbol('c')
    p = Symbol('p', positive=True)
    m = Symbol('m', negative=True)
    expr = ((2*n*(n - r + 1)/(n + r*(n - r + 1)))**c + \
        (r - 1)*(n*(n - r + 2)/(n + r*(n - r + 1)))**c - n)/(n**c - n)
    expr = expr.subs(c, c + 1)
    raises(NotImplementedError, lambda: limit(expr, n, oo))
    assert limit(expr.subs(c, m), n, oo) == 1
    assert limit(expr.subs(c, p), n, oo).simplify() == \
        (2**(p + 1) + r - 1)/(r + 1)**(p + 1)
Esempio n. 15
0
def test_issue_5183():
    # using list(...) so py.test can recalculate values
    tests = list(cartes([x, -x], [-1, 1], [2, 3, Rational(1, 2), Rational(2, 3)], ["-", "+"]))
    results = (
        oo,
        oo,
        -oo,
        oo,
        -oo * I,
        oo,
        -oo * (-1) ** Rational(1, 3),
        oo,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        oo,
        oo,
        oo,
        -oo,
        oo,
        -oo * I,
        oo,
        -oo * (-1) ** Rational(1, 3),
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
    )
    assert len(tests) == len(results)
    for i, (args, res) in enumerate(zip(tests, results)):
        y, s, e, d = args
        eq = y ** (s * e)
        try:
            assert limit(eq, x, 0, dir=d) == res
        except AssertionError:
            if 0:  # change to 1 if you want to see the failing tests
                print()
                print(i, res, eq, d, limit(eq, x, 0, dir=d))
            else:
                assert None
Esempio n. 16
0
File: ratfun.py Progetto: mph-/lcapy
def as_residue_parts(expr, var):
        
    N, D, delay = as_ratfun_delay(expr, var)

    # Perform polynomial long division so expr = Q + M / D
    Q, M = sym.div(N, D, var)
    expr = M / D
        
    sexpr = Ratfun(expr, var)

    P = sexpr.poles()
    F = []
    R = []
    for p in P:

        # Number of occurrences of the pole.
        N = P[p]

        f = var - p

        if N == 1:
            F.append(f)
            R.append(sexpr.residue(p, P))
            continue

        # Handle repeated poles.
        expr2 = expr * f ** N
        for n in range(1, N + 1):
            m = N - n
            F.append(f ** n)
            dexpr = sym.diff(expr2, var, m)
            R.append(sym.limit(dexpr, var, p) / sym.factorial(m))

    return F, R, Q, delay
Esempio n. 17
0
def test_ci():
    m1 = exp_polar(I*pi)
    m1_ = exp_polar(-I*pi)
    pI = exp_polar(I*pi/2)
    mI = exp_polar(-I*pi/2)

    assert Ci(m1*x) == Ci(x) + I*pi
    assert Ci(m1_*x) == Ci(x) - I*pi
    assert Ci(pI*x) == Chi(x) + I*pi/2
    assert Ci(mI*x) == Chi(x) - I*pi/2
    assert Chi(m1*x) == Chi(x) + I*pi
    assert Chi(m1_*x) == Chi(x) - I*pi
    assert Chi(pI*x) == Ci(x) + I*pi/2
    assert Chi(mI*x) == Ci(x) - I*pi/2
    assert Ci(exp_polar(2*I*pi)*x) == Ci(x) + 2*I*pi
    assert Chi(exp_polar(-2*I*pi)*x) == Chi(x) - 2*I*pi
    assert Chi(exp_polar(2*I*pi)*x) == Chi(x) + 2*I*pi
    assert Ci(exp_polar(-2*I*pi)*x) == Ci(x) - 2*I*pi

    assert mytd(Ci(x), cos(x)/x, x)
    assert mytd(Chi(x), cosh(x)/x, x)

    assert mytn(Ci(x), Ci(x).rewrite(Ei),
                Ei(x*exp_polar(-I*pi/2))/2 + Ei(x*exp_polar(I*pi/2))/2, x)
    assert mytn(Chi(x), Chi(x).rewrite(Ei),
                Ei(x)/2 + Ei(x*exp_polar(I*pi))/2 - I*pi/2, x)

    assert tn_arg(Ci)
    assert tn_arg(Chi)

    from sympy import O, EulerGamma, log, limit
    assert Ci(x).nseries(x, n=4) == EulerGamma + log(x) - x**2/4 + x**4/96 + O(x**5)
    assert Chi(x).nseries(x, n=4) == EulerGamma + log(x) + x**2/4 + x**4/96 + O(x**5)
    assert limit(log(x) - Ci(2*x), x, 0) == -log(2) - EulerGamma
Esempio n. 18
0
def test_issue_6560():
    e = (
        5 * x ** 3 / 4
        - 3 * x / 4
        + (y * (3 * x ** 2 / 2 - S(1) / 2) + 35 * x ** 4 / 8 - 15 * x ** 2 / 4 + S(3) / 8) / (2 * (y + 1))
    )
    assert limit(e, y, oo) == (5 * x ** 3 + 3 * x ** 2 - 3 * x - 1) / 4
Esempio n. 19
0
def test_issue_4546():
    # using list(...) so py.test can recalculate values
    tests = list(cartes([cot, tan], [-pi / 2, 0, pi / 2, pi, 3 * pi / 2], ["-", "+"]))
    results = (0, 0, -oo, oo, 0, 0, -oo, oo, 0, 0, oo, -oo, 0, 0, oo, -oo, 0, 0, oo, -oo)
    assert len(tests) == len(results)
    for i, (args, res) in enumerate(zip(tests, results)):
        f, l, d = args
        eq = f(x)
        try:
            assert limit(eq, x, l, dir=d) == res
        except AssertionError:
            if 0:  # change to 1 if you want to see the failing tests
                print()
                print(i, res, eq, l, d, limit(eq, x, l, dir=d))
            else:
                assert None
Esempio n. 20
0
  def test_single_zero_strategies_tvar(self, filt_func, fsign,
                                             monkeypatch):
    from .. import lazy_filters
    monkeypatch.setattr(lazy_filters, "sin", elementwise("x", 0)(sympy.sin))
    monkeypatch.setattr(lazy_filters, "cos", elementwise("x", 0)(sympy.cos))

    start = 2
    n = 3 # Amount of coefficient samples to get
    freqs = repeat(sympy.pi) / count(start=start)

    filt = filt_func(freqs)
    assert filt.denpoly[0] == 1

    t = sympy.Symbol("t")
    Rs = [sympy.limit(fsign * (sympy.sin(t) - 1) / sympy.cos(t),
                      t, sympy.pi / el)
          for el in xrange(2, 2 + n)]
    Gs = [(R + 1) / 2 for R in Rs]

    pole_sig = filt.denpoly[1]
    assert (fsign * pole_sig).cancel().take(n) == Rs
    assert len(filt.denpoly) == 2

    num_sig0, num_sig1 = filt.numlist
    assert num_sig0.cancel().take(n) == Gs
    assert (fsign * num_sig1).cancel().take(n) == Gs
Esempio n. 21
0
 def _contains(self, expr):
     from sympy import powsimp, limit
     if expr is S.Zero:
         return True
     if expr is S.NaN:
         return False
     if expr.is_Order:
         if self.variables and expr.variables:
             common_symbols = tuple([s for s in self.variables if s in expr.variables])
         elif self.variables:
             common_symbols = self.variables
         else:
             common_symbols = expr.variables
         if not common_symbols:
             if not (self.variables or expr.variables): # O(1),O(1)
                 return True
             return None
         r = None
         for s in common_symbols:
             l = limit(powsimp(self.expr/expr.expr, deep=True,\
             combine='exp'), s, 0) != 0
             if r is None:
                 r = l
             else:
                 if r != l:
                     return
         return r
     obj = Order(expr, *self.variables)
     return self.contains(obj)
Esempio n. 22
0
    def apply(self, expr, x, x0, evaluation, options={}):
        'Limit[expr_, x_->x0_, OptionsPattern[Limit]]'

        expr = expr.to_sympy()
        x = x.to_sympy()
        x0 = x0.to_sympy()

        if expr is None or x is None or x0 is None:
            return

        direction = self.get_option(options, 'Direction', evaluation)
        value = direction.get_int_value()
        if value not in (-1, 1):
            evaluation.message('Limit', 'ldir', direction)
        if value > 0:
            dir_sympy = '-'
        else:
            dir_sympy = '+'

        try:
            result = sympy.limit(expr, x, x0, dir_sympy)
        except sympy.PoleError:
            pass
        except RuntimeError:
            # Bug in Sympy: RuntimeError: maximum recursion depth exceeded
            # while calling a Python object
            pass
        except NotImplementedError:
            pass
        except TypeError:
            # Unknown SymPy0.7.6 bug
            pass
        else:
            return from_sympy(result)
Esempio n. 23
0
def test_basic5():
    class my(Function):
        @classmethod
        def eval(cls, arg):
            if arg is S.Infinity:
                return S.NaN
    assert limit(my(x), x, oo) == Limit(my(x), x, oo)
Esempio n. 24
0
 def contains(self, expr):
     """
     Return True if expr belongs to Order(self.expr, *self.variables).
     Return False if self belongs to expr.
     Return None if the inclusion relation cannot be determined
     (e.g. when self and expr have different symbols).
     """
     from sympy import powsimp, limit
     if expr is S.Zero:
         return True
     if expr is S.NaN:
         return False
     if expr.is_Order:
         if self.variables and expr.variables:
             common_symbols = tuple([s for s in self.variables if s in expr.variables])
         elif self.variables:
             common_symbols = self.variables
         else:
             common_symbols = expr.variables
         if not common_symbols:
             if not (self.variables or expr.variables): # O(1),O(1)
                 return True
             return None
         r = None
         for s in common_symbols:
             l = limit(powsimp(self.expr/expr.expr, deep=True,\
             combine='exp'), s, 0) != 0
             if r is None:
                 r = l
             else:
                 if r != l:
                     return
         return r
     obj = Order(expr, *self.variables)
     return self.contains(obj)
Esempio n. 25
0
File: core.py Progetto: bcbnz/lcapy
    def _as_residue_parts(self):
        """Return residues of expression"""

        var = self.var
        N, D, delay = self._as_ratfun_delay()

        Q, M = N.div(D)

        expr = M / D
        sexpr = sExpr(expr)

        P = sexpr.poles()
        F = []
        R = []
        for p in P:

            # Number of occurrences of the pole.
            N = P[p]

            f = var - p

            if N == 1:
                F.append(f)
                R.append(sexpr.residue(p, P))
                continue

            # Handle repeated poles.
            expr2 = expr * f ** N
            for n in range(1, N + 1):
                m = N - n
                F.append(f ** n)
                dexpr = sym.diff(expr2, var, m)
                R.append(sym.limit(dexpr, var, p) / sym.factorial(m))

        return F, R, Q, delay
Esempio n. 26
0
def test_floor_requires_robust_assumptions():
    assert limit(floor(sin(x)), x, 0, "+") == 0
    assert limit(floor(sin(x)), x, 0, "-") == -1
    assert limit(floor(cos(x)), x, 0, "+") == 0
    assert limit(floor(cos(x)), x, 0, "-") == 0
    assert limit(floor(5 + sin(x)), x, 0, "+") == 5
    assert limit(floor(5 + sin(x)), x, 0, "-") == 4
    assert limit(floor(5 + cos(x)), x, 0, "+") == 5
    assert limit(floor(5 + cos(x)), x, 0, "-") == 5
Esempio n. 27
0
def test_ceiling_requires_robust_assumptions():
    assert limit(ceiling(sin(x)), x, 0, "+") == 1
    assert limit(ceiling(sin(x)), x, 0, "-") == 0
    assert limit(ceiling(cos(x)), x, 0, "+") == 1
    assert limit(ceiling(cos(x)), x, 0, "-") == 1
    assert limit(ceiling(5 + sin(x)), x, 0, "+") == 6
    assert limit(ceiling(5 + sin(x)), x, 0, "-") == 5
    assert limit(ceiling(5 + cos(x)), x, 0, "+") == 6
    assert limit(ceiling(5 + cos(x)), x, 0, "-") == 6
Esempio n. 28
0
def test_basic2():
    assert limit(x**x, x, 0, dir="+") == 1
    assert limit((exp(x) - 1)/x, x, 0) == 1
    assert limit(1 + 1/x, x, oo) == 1
    assert limit(-exp(1/x), x, oo) == -1
    assert limit(x + exp(-x), x, oo) == oo
    assert limit(x + exp(-x**2), x, oo) == oo
    assert limit(x + exp(-exp(x)), x, oo) == oo
    assert limit(13 + 1/x - exp(-x), x, oo) == 13
Esempio n. 29
0
def test_Limits_simple_2():
    assert limit(1000*x/(x**2-1),x,oo)==0  #182
    assert limit((x**2-5*x+1)/(3*x+7),x,oo)==oo  #183
    assert limit((2*x**2-x+3)/(x**3-8*x+5),x,oo)==0  #184
    assert limit((2*x**2-3*x-4)/sqrt(x**4+1),x,oo)==2  #186
    assert limit((2*x+3)/(x+root3(x)),x,oo)==2  #187
    assert limit(x**2/(10+x*sqrt(x)),x,oo)==oo  #188
    assert limit(root3(x**2+1)/(x+1),x,oo)==0  #189
    assert limit(sqrt(x)/sqrt(x+sqrt(x+sqrt(x))),x,oo)==1  #190
Esempio n. 30
0
		def K_limit(self,fx):
				y = ""
				try:
						y = sympy.limit(fx+"/x","x","oo")
				except sympy.PoleError:
						y = "SeuZlebelia gamoTvla"
				print y,"K_limit"
				return y
Esempio n. 31
0
def test_issue_17792():
    assert limit(factorial(n)/sqrt(n)*(exp(1)/n)**n, n, oo) == sqrt(2)*sqrt(pi)
Esempio n. 32
0
def test_issue_14556():
    assert limit(factorial(n + 1)**(1/(n + 1)) - factorial(n)**(1/n), n, oo) == exp(-1)
Esempio n. 33
0
def test_issue_17671():
    assert limit(Ei(-log(x)) - log(log(x))/x, x, 1) == EulerGamma
Esempio n. 34
0
def test_issue_17431():
    assert limit(((n + 1) + 1) / (((n + 1) + 2) * factorial(n + 1)) *
                 (n + 2) * factorial(n) / (n + 1), n, oo) == 0
    assert limit((n + 2)**2*factorial(n)/((n + 1)*(n + 3)*factorial(n + 1))
                 , n, oo) == 0
    assert limit((n + 1) * factorial(n) / (n * factorial(n + 1)), n, oo) == 0
Esempio n. 35
0
def test_issue_18378():
    assert limit(log(exp(3*x) + x)/log(exp(x) + x**100), x, oo) == 3
Esempio n. 36
0
def test_issue_16722():
    z = symbols('z', positive=True)
    assert limit(binomial(n + z, n)*n**-z, n, oo) == 1/gamma(z + 1)
    z = symbols('z', positive=True, integer=True)
    assert limit(binomial(n + z, n)*n**-z, n, oo) == 1/gamma(z + 1)
Esempio n. 37
0
def test_issue_16222():
    assert limit(exp(x), x, 1000000000) == exp(1000000000)
Esempio n. 38
0
def test_issue_16714():
    assert limit(((x**(x + 1) + (x + 1)**x) / x**(x + 1))**x, x, oo) == exp(exp(1))
Esempio n. 39
0
def test_issue_18399():
    assert limit((1 - S(1)/2*x)**(3*x), x, oo) is zoo
    assert limit((-x)**x, x, oo) is zoo
Esempio n. 40
0
def test_issue_14811():
    assert limit(((1 + ((S(2)/3)**(x + 1)))**(2**x))/(2**((S(4)/3)**(x - 1))), x, oo) == oo
Esempio n. 41
0
def test_issue_18306():
    assert limit(sin(sqrt(x))/sqrt(sin(x)), x, 0, '+') == 1
Esempio n. 42
0
def test_issue_17751():
    a, b, c, x = symbols('a b c x', positive=True)
    assert limit((a + 1)*x - sqrt((a + 1)**2*x**2 + b*x + c), x, oo) == -b/(2*a + 2)
Esempio n. 43
0
def test_issue_14393():
    a, b = symbols('a b')
    assert limit((x**b - y**b)/(x**a - y**a), x, y) == b*y**(-a)*y**b/a
Esempio n. 44
0
def test_issue_18442():
    assert limit(tan(x)**(2**(sqrt(pi))), x, oo, dir='-') == Limit(tan(x)**(2**(sqrt(pi))), x, oo, dir='-')