• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python limits.limit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sympy.series.limits.limit函数的典型用法代码示例。如果您正苦于以下问题:Python limit函数的具体用法?Python limit怎么用?Python limit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了limit函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _dirichlet_test

 def _dirichlet_test(g_n):
     try:
         ing_val = limit(Sum(g_n, (sym, interval.inf, m)).doit(), m, S.Infinity)
         if ing_val.is_finite:
             return S.true
     except NotImplementedError:
         pass
开发者ID:carstimon,项目名称:sympy,代码行数:7,代码来源:summations.py


示例2: test_limit2

def test_limit2():
    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
开发者ID:certik,项目名称:sympy-oldcore,代码行数:9,代码来源:test_limit.py


示例3: test_limits

def test_limits():
    k, x = symbols('k, x')
    assert hyper((1,), (S(4)/3, S(5)/3), k**2).series(k) == \
           hyper((1,), (S(4)/3, S(5)/3), 0) + \
           9*k**2*hyper((2,), (S(7)/3, S(8)/3), 0)/20 + \
           81*k**4*hyper((3,), (S(10)/3, S(11)/3), 0)/1120 + \
           O(k**6) # issue 6350
    assert limit(meijerg((), (), (1,), (0,), -x), x, 0) == \
            meijerg(((), ()), ((1,), (0,)), 0) # issue 6052
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:9,代码来源:test_hyper.py


示例4: _bounded_convergent_test

 def _bounded_convergent_test(g1_n, g2_n):
     try:
         lim_val = limit(g1_n, sym, upper_limit)
         if lim_val.is_finite or (isinstance(lim_val, AccumulationBounds)
                                  and (lim_val.max - lim_val.min).is_finite):
             if Sum(g2_n, (sym, lower_limit, upper_limit)).is_absolutely_convergent():
                 return S.true
     except NotImplementedError:
         pass
开发者ID:tschijnmo,项目名称:sympy,代码行数:9,代码来源:summations.py


示例5: is_convergent

    def is_convergent(self):
        r"""Checks for the convergence of a Sum.

        We divide the study of convergence of infinite sums and products in
        two parts.

        First Part:
        One part is the question whether all the terms are well defined, i.e.,
        they are finite in a sum and also non-zero in a product. Zero
        is the analogy of (minus) infinity in products as
        :math:`e^{-\infty} = 0`.

        Second Part:
        The second part is the question of convergence after infinities,
        and zeros in products, have been omitted assuming that their number
        is finite. This means that we only consider the tail of the sum or
        product, starting from some point after which all terms are well
        defined.

        For example, in a sum of the form:

        .. math::

            \sum_{1 \leq i < \infty} \frac{1}{n^2 + an + b}

        where a and b are numbers. The routine will return true, even if there
        are infinities in the term sequence (at most two). An analogous
        product would be:

        .. math::

            \prod_{1 \leq i < \infty} e^{\frac{1}{n^2 + an + b}}

        This is how convergence is interpreted. It is concerned with what
        happens at the limit. Finding the bad terms is another independent
        matter.

        Note: It is responsibility of user to see that the sum or product
        is well defined.

        There are various tests employed to check the convergence like
        divergence test, root test, integral test, alternating series test,
        comparison tests, Dirichlet tests. It returns true if Sum is convergent
        and false if divergent and NotImplementedError if it can not be checked.

        References
        ==========

        .. [1] https://en.wikipedia.org/wiki/Convergence_tests

        Examples
        ========

        >>> from sympy import factorial, S, Sum, Symbol, oo
        >>> n = Symbol('n', integer=True)
        >>> Sum(n/(n - 1), (n, 4, 7)).is_convergent()
        True
        >>> Sum(n/(2*n + 1), (n, 1, oo)).is_convergent()
        False
        >>> Sum(factorial(n)/5**n, (n, 1, oo)).is_convergent()
        False
        >>> Sum(1/n**(S(6)/5), (n, 1, oo)).is_convergent()
        True

        See Also
        ========

        Sum.is_absolutely_convergent()

        Product.is_convergent()
        """
        from sympy import Interval, Integral, Limit, log, symbols, Ge, Gt, simplify
        p, q = symbols('p q', cls=Wild)

        sym = self.limits[0][0]
        lower_limit = self.limits[0][1]
        upper_limit = self.limits[0][2]
        sequence_term = self.function

        if len(sequence_term.free_symbols) > 1:
            raise NotImplementedError("convergence checking for more than one symbol "
                                      "containing series is not handled")

        if lower_limit.is_finite and upper_limit.is_finite:
            return S.true

        # transform sym -> -sym and swap the upper_limit = S.Infinity
        # and lower_limit = - upper_limit
        if lower_limit is S.NegativeInfinity:
            if upper_limit is S.Infinity:
                return Sum(sequence_term, (sym, 0, S.Infinity)).is_convergent() and \
                        Sum(sequence_term, (sym, S.NegativeInfinity, 0)).is_convergent()
            sequence_term = simplify(sequence_term.xreplace({sym: -sym}))
            lower_limit = -upper_limit
            upper_limit = S.Infinity

        sym_ = Dummy(sym.name, integer=True, positive=True)
        sequence_term = sequence_term.xreplace({sym: sym_})
        sym = sym_

#.........这里部分代码省略.........
开发者ID:carstimon,项目名称:sympy,代码行数:101,代码来源:summations.py


示例6: limit

 def limit(self, x, xlim, dir='+'):
     """ Compute limit x->xlim.
     """
     from sympy.series.limits import limit
     return TupleArg(*[limit(f, x, xlim, dir) for f in self.args])
开发者ID:moorepants,项目名称:sympy,代码行数:5,代码来源:hyper.py


示例7: test_limit4

def test_limit4():
    #issue 364
    assert limit((3**x+5**x)**(1/x), x, oo) == 5
    #issue 364
    assert limit((3**(1/x)+5**(1/x))**x, x, 0) == 5
开发者ID:certik,项目名称:sympy-oldcore,代码行数:5,代码来源:test_limit.py


示例8: test_limit3

def test_limit3():
    a = Symbol('a')
    assert limit(x-log(1+exp(x)), x, oo) == 0
    assert limit(x-log(a+exp(x)), x, oo) == 0
    assert limit(exp(x)/(1+exp(x)), x, oo) == 1
    assert limit(exp(x)/(a+exp(x)), x, oo) == 1
开发者ID:certik,项目名称:sympy-oldcore,代码行数:6,代码来源:test_limit.py


示例9: test_limit1

def test_limit1():
    assert limit(x, x, oo) == oo
    assert limit(x, x, -oo) == -oo
    assert limit(-x, x, oo) == -oo
    assert limit(x**2, x, -oo) == oo
    assert limit(-x**2, x, oo) == -oo
    assert limit(x*log(x), x, 0, dir="+") == 0
    assert limit(1/x,x,oo) == 0
    assert limit(exp(x),x,oo) == oo
    assert limit(-exp(x),x,oo) == -oo
    assert limit(exp(x)/x,x,oo) == oo
    assert limit(1/x-exp(-x),x,oo) == 0
    assert limit(x+1/x,x,oo) == oo
开发者ID:certik,项目名称:sympy-oldcore,代码行数:13,代码来源:test_limit.py


示例10: _limit_inf

def _limit_inf(expr, n):
    try:
        return limit(expr, n, S.Infinity)
    except (NotImplementedError, PoleError):
        return None
开发者ID:leonsooi,项目名称:sympy,代码行数:5,代码来源:limitseq.py


示例11: is_convergent

    def is_convergent(self):
        """
        Convergence tests are used for checking the convergence of
        a series. There are various tests employed to check the convergence,
        returns true if convergent and false if divergent and NotImplementedError
        if can not be checked. Like divergence test, root test, integral test,
        alternating series test, comparison tests, Dirichlet tests.

        References
        ==========

        .. [1] https://en.wikipedia.org/wiki/Convergence_tests

        Examples
        ========

        >>> from sympy import Interval, factorial, S, Sum, Symbol, oo
        >>> n = Symbol('n', integer=True)
        >>> Sum(n/(n - 1), (n, 4, 7)).is_convergent()
        True
        >>> Sum(n/(2*n + 1), (n, 1, oo)).is_convergent()
        False
        >>> Sum(factorial(n)/5**n, (n, 1, oo)).is_convergent()
        False
        >>> Sum(1/n**(S(6)/5), (n, 1, oo)).is_convergent()
        True

        See Also
        ========

        Sum.is_absolute_convergent()
        """
        from sympy import Interval, Integral, Limit, log, symbols, Ge, Gt, simplify
        p, q = symbols('p q', cls=Wild)

        sym = self.limits[0][0]
        lower_limit = self.limits[0][1]
        upper_limit = self.limits[0][2]
        sequence_term = self.function

        if len(sequence_term.free_symbols) > 1:
            raise NotImplementedError("convergence checking for more that one symbol \
                                        containing series is not handled")

        if lower_limit.is_finite and upper_limit.is_finite:
            return S.true

        # transform sym -> -sym and swap the upper_limit = S.Infinity and lower_limit = - upper_limit
        if lower_limit is S.NegativeInfinity:
            if upper_limit is S.Infinity:
                return Sum(sequence_term, (sym, 0, S.Infinity)).is_convergent() and \
                        Sum(sequence_term, (sym, S.NegativeInfinity, 0)).is_convergent()
            sequence_term = simplify(sequence_term.xreplace({sym: -sym}))
            lower_limit = -upper_limit
            upper_limit = S.Infinity

        interval = Interval(lower_limit, upper_limit)

        # Piecewise function handle
        if sequence_term.is_Piecewise:
            for func_cond in sequence_term.args:
                if func_cond[1].func is Ge or func_cond[1].func is Gt or func_cond[1] == True:
                    return Sum(func_cond[0], (sym, lower_limit, upper_limit)).is_convergent()
            return S.true

        ###  -------- Divergence test ----------- ###
        try:
            lim_val = limit(abs(sequence_term), sym, upper_limit)
            if lim_val.is_number and lim_val != S.Zero:
                return S.false
        except NotImplementedError:
            pass

        order = O(sequence_term, (sym, S.Infinity))

        ### --------- p-series test (1/n**p) ---------- ###
        p1_series_test = order.expr.match(sym**p)
        if p1_series_test is not None:
            if p1_series_test[p] < -1:
                return S.true
            if p1_series_test[p] > -1:
                return S.false

        p2_series_test = order.expr.match((1/sym)**p)
        if p2_series_test is not None:
            if p2_series_test[p] > 1:
                return S.true
            if p2_series_test[p] < 1:
                return S.false

        ### ----------- root test ---------------- ###
        lim = Limit(abs(sequence_term)**(1/sym), sym, S.Infinity)
        lim_evaluated = lim.doit()
        if lim_evaluated.is_number:
            if lim_evaluated < 1:
                return S.true
            if lim_evaluated > 1:
                return S.false

        ### ------------- alternating series test ----------- ###
#.........这里部分代码省略.........
开发者ID:MechCoder,项目名称:sympy,代码行数:101,代码来源:summations.py



注:本文中的sympy.series.limits.limit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sets.imageset函数代码示例发布时间:2022-05-27
下一篇:
Python gruntz.mrv_leadterm函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap