当前位置: 首页>>代码示例>>Python>>正文


Python symbol.Wild类代码示例

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


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

示例1: _eval_nseries

    def _eval_nseries(self, x, n, logx):
        # NOTE Please see the comment at the beginning of this file, labelled
        #      IMPORTANT.
        from sympy import cancel
        if not logx:
            logx = log(x)
        if self.args[0] == x:
            return logx
        arg = self.args[0]
        k, l = Wild("k"), Wild("l")
        r = arg.match(k*x**l)
        if r is not None:
            #k = r.get(r, S.One)
            #l = r.get(l, S.Zero)
            k, l = r[k], r[l]
            if l != 0 and not l.has(x) and not k.has(x):
                r = log(k) + l*logx  # XXX true regardless of assumptions?
                return r

        # TODO new and probably slow
        s = self.args[0].nseries(x, n=n, logx=logx)
        while s.is_Order:
            n += 1
            s = self.args[0].nseries(x, n=n, logx=logx)
        a, b = s.leadterm(x)
        p = cancel(s/(a*x**b) - 1)
        g = None
        l = []
        for i in xrange(n + 2):
            g = log.taylor_term(i, p, g)
            g = g.nseries(x, n=n, logx=logx)
            l.append(g)
        return log(a) + b*logx + Add(*l) + C.Order(p**n, x)
开发者ID:AALEKH,项目名称:sympy,代码行数:33,代码来源:exponential.py

示例2: _eval_nseries

 def _eval_nseries(self, x, n):
     from sympy import powsimp
     arg = self.args[0]
     k, l = Wild("k"), Wild("l")
     r = arg.match(k*x**l)
     if r is not None:
         #k = r.get(r, S.One)
         #l = r.get(l, S.Zero)
         k, l = r[k], r[l]
         if l != 0 and not l.has(x) and not k.has(x):
             r = log(k) + l*log(x) # XXX true regardless of assumptions?
             return r
     order = C.Order(x**n, x)
     arg = self.args[0]
     use_lt = not C.Order(1, x).contains(arg)
     if not use_lt:
         arg0 = arg.limit(x, 0)
         use_lt = (arg0 is S.Zero)
     if use_lt: # singularity, #example: self = log(sin(x))
         # arg = (arg / lt) * lt
         lt = arg.as_leading_term(x) # arg = sin(x); lt = x
         a = powsimp((arg/lt).expand(), deep=True, combine='exp') # a = sin(x)/x
         # the idea is to recursively call log(a).series(), but one needs to
         # make sure that log(sin(x)/x) doesn't get "simplified" to
         # -log(x)+log(sin(x)) and an infinite recursion occurs, see also the
         # issue 252.
         obj = log(lt) + log(a).nseries(x, n=n)
     else:
         # arg -> arg0 + (arg - arg0) -> arg0 * (1 + (arg/arg0 - 1))
         z = (arg/arg0 - 1)
         o = C.Order(z, x)
         if o is S.Zero:
             return log(1 + z) + log(arg0)
         if o.expr.is_number:
             e = log(order.expr*x)/log(x)
         else:
             e = log(order.expr)/log(o.expr)
         n = e.limit(x, 0) + 1
         if n.is_unbounded:
             # requested accuracy gives infinite series,
             # order is probably nonpolynomial e.g. O(exp(-1/x), x).
             return log(1 + z) + log(arg0)
         # XXX was int or floor intended? int used to behave like floor
         try:
             n = int(n)
         except TypeError:
             #well, the n is something more complicated (like 1+log(2))
             n = int(n.evalf()) + 1 # XXX why is 1 being added?
         assert n>=0, `n`
         l = []
         g = None
         for i in xrange(n + 2):
             g = log.taylor_term(i, z, g)
             g = g.nseries(x, n=n)
             l.append(g)
         obj = Add(*l) + log(arg0)
     obj2 = expand_log(powsimp(obj, deep=True, combine='exp'))
     if obj2 != obj:
         r = obj2.nseries(x, n=n)
     else:
         r = obj
     if r == self:
         return self
     return r + order
开发者ID:rainly,项目名称:sympy,代码行数:64,代码来源:exponential.py


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