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


Python C.exp方法代码示例

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


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

示例1: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def eval(cls, arg):
     from sympy.simplify.simplify import signsimp
     if hasattr(arg, '_eval_Abs'):
         obj = arg._eval_Abs()
         if obj is not None:
             return obj
     # handle what we can
     arg = signsimp(arg, evaluate=False)
     if arg.is_Mul:
         known = []
         unk = []
         for t in arg.args:
             tnew = cls(t)
             if tnew.func is cls:
                 unk.append(tnew.args[0])
             else:
                 known.append(tnew)
         known = Mul(*known)
         unk = cls(Mul(*unk), evaluate=False) if unk else S.One
         return known*unk
     if arg is S.NaN:
         return S.NaN
     if arg.is_Pow:
         base, exponent = arg.as_base_exp()
         if base.is_real:
             if exponent.is_integer:
                 if exponent.is_even:
                     return arg
                 if base is S.NegativeOne:
                     return S.One
                 if base.func is cls and exponent is S.NegativeOne:
                     return arg
                 return Abs(base)**exponent
             if base.is_positive == True:
                 return base**re(exponent)
             return (-base)**re(exponent)*C.exp(-S.Pi*im(exponent))
     if isinstance(arg, C.exp):
         return C.exp(re(arg.args[0]))
     if arg.is_zero:  # it may be an Expr that is zero
         return S.Zero
     if arg.is_nonnegative:
         return arg
     if arg.is_nonpositive:
         return -arg
     if arg.is_imaginary:
         arg2 = -S.ImaginaryUnit * arg
         if arg2.is_nonnegative:
             return arg2
     if arg.is_Add:
         if arg.has(S.Infinity, S.NegativeInfinity):
             if any(a.is_infinite for a in arg.as_real_imag()):
                 return S.Infinity
         if arg.is_real is None and arg.is_imaginary is None:
             if all(a.is_real or a.is_imaginary or (S.ImaginaryUnit*a).is_real for a in arg.args):
                 from sympy import expand_mul
                 return sqrt(expand_mul(arg*arg.conjugate()))
     if arg.is_real is False and arg.is_imaginary is False:
         from sympy import expand_mul
         return sqrt(expand_mul(arg*arg.conjugate()))
开发者ID:fetrocinol,项目名称:sympy,代码行数:61,代码来源:complexes.py

示例2: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
    def eval(cls, a, x):
        if a.is_Number:
            if a is S.One:
                return S.One - C.exp(-x)
            elif a.is_Integer:
                b = a - 1

                if b.is_positive:
                    return b*cls(b, x) - x**b * C.exp(-x)
开发者ID:KevinGoodsell,项目名称:sympy,代码行数:11,代码来源:gamma_functions.py

示例3: separate

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
def separate(expr, deep=False):
    """Rewrite or separate a power of product to a product of powers
       but without any expanding, ie. rewriting products to summations.

       >>> from sympy import *
       >>> x, y, z = symbols('x', 'y', 'z')

       >>> separate((x*y)**2)
       x**2*y**2

       >>> separate((x*(y*z)**3)**2)
       x**2*y**6*z**6

       >>> separate((x*sin(x))**y + (x*cos(x))**y)
       x**y*cos(x)**y + x**y*sin(x)**y

       #this does not work because of exp combining
       #>>> separate((exp(x)*exp(y))**x)
       #exp(x*y)*exp(x**2)

       >>> separate((sin(x)*cos(x))**y)
       cos(x)**y*sin(x)**y

       Notice that summations are left un touched. If this is not the
       requested behaviour, apply 'expand' to input expression before:

       >>> separate(((x+y)*z)**2)
       z**2*(x + y)**2

       >>> separate((x*y)**(1+z))
       x**(1 + z)*y**(1 + z)

    """
    expr = sympify(expr)

    if expr.is_Pow:
        terms, expo = [], separate(expr.exp, deep)

        if expr.base.is_Mul:
            t = [ separate(C.Pow(t,expo), deep) for t in expr.base.args ]
            return C.Mul(*t)
        elif expr.base.func is C.exp:
            if deep == True:
                return C.exp(separate(expr.base[0], deep)*expo)
            else:
                return C.exp(expr.base[0]*expo)
        else:
            return C.Pow(separate(expr.base, deep), expo)
    elif expr.is_Add or expr.is_Mul:
        return type(expr)(*[ separate(t, deep) for t in expr.args ])
    elif expr.is_Function and deep:
        return expr.func(*[ separate(t) for t in expr.args])
    else:
        return expr
开发者ID:gnulinooks,项目名称:sympy,代码行数:56,代码来源:simplify.py

示例4: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
    def eval(cls, a, x):
        if a.is_Number:
            # TODO this should be non-recursive
            if a is S.One:
                return S.One - C.exp(-x)
            elif a is S.Half:
                return sqrt(pi) * erf(sqrt(x))
            elif a.is_Integer or (2 * a).is_Integer:
                b = a - 1
                if b.is_positive:
                    return b * cls(b, x) - x ** b * C.exp(-x)

                if not a.is_Integer:
                    return (cls(a + 1, x) + x ** a * C.exp(-x)) / a
开发者ID:nvlrules,项目名称:sympy,代码行数:16,代码来源:gamma_functions.py

示例5: fdiff

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def fdiff(self, argindex=1):
     from sympy import unpolarify
     arg = unpolarify(self.args[0])
     if argindex == 1:
         return C.exp(arg)/arg
     else:
         raise ArgumentIndexError(self, argindex)
开发者ID:Maihj,项目名称:sympy,代码行数:9,代码来源:error_functions.py

示例6: eval

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
    def eval(cls, a, x):
        # For lack of a better place, we use this one to extract branching
        # information. The following can be
        # found in the literature (c/f references given above), albeit scattered:
        # 1) For fixed x != 0, lowergamma(s, x) is an entire function of s
        # 2) For fixed positive integers s, lowergamma(s, x) is an entire
        #    function of x.
        # 3) For fixed non-positive integers s,
        #    lowergamma(s, exp(I*2*pi*n)*x) =
        #              2*pi*I*n*(-1)**(-s)/factorial(-s) + lowergamma(s, x)
        #    (this follows from lowergamma(s, x).diff(x) = x**(s-1)*exp(-x)).
        # 4) For fixed non-integral s,
        #    lowergamma(s, x) = x**s*gamma(s)*lowergamma_unbranched(s, x),
        #    where lowergamma_unbranched(s, x) is an entire function (in fact
        #    of both s and x), i.e.
        #    lowergamma(s, exp(2*I*pi*n)*x) = exp(2*pi*I*n*a)*lowergamma(a, x)
        from sympy import unpolarify, I, factorial, exp

        nx, n = x.extract_branch_factor()
        if a.is_integer and a.is_positive:
            nx = unpolarify(x)
            if nx != x:
                return lowergamma(a, nx)
        elif a.is_integer and a.is_nonpositive:
            if n != 0:
                return 2 * pi * I * n * (-1) ** (-a) / factorial(-a) + lowergamma(a, nx)
        elif n != 0:
            return exp(2 * pi * I * n * a) * lowergamma(a, nx)

        # Special values.
        if a.is_Number:
            # TODO this should be non-recursive
            if a is S.One:
                return S.One - C.exp(-x)
            elif a is S.Half:
                return sqrt(pi) * erf(sqrt(x))
            elif a.is_Integer or (2 * a).is_Integer:
                b = a - 1
                if b.is_positive:
                    return b * cls(b, x) - x ** b * C.exp(-x)

                if not a.is_Integer:
                    return (cls(a + 1, x) + x ** a * C.exp(-x)) / a
开发者ID:Krastanov,项目名称:sympy,代码行数:45,代码来源:gamma_functions.py

示例7: fdiff

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def fdiff(self, argindex=2):
     from sympy import meijerg
     if argindex == 2:
         a, z = self.args
         return -C.exp(-z)*z**(a-1)
     elif argindex == 1:
         a, z = self.args
         return uppergamma(a, z)*log(z) + meijerg([], [1, 1], [0, 0, a], [], z)
     else:
         raise ArgumentIndexError(self, argindex)
开发者ID:Kimay,项目名称:sympy,代码行数:12,代码来源:gamma_functions.py

示例8: fdiff

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
    def fdiff(self, argindex=2):
        from sympy import meijerg, unpolarify

        if argindex == 2:
            a, z = self.args
            return C.exp(-unpolarify(z)) * z ** (a - 1)
        elif argindex == 1:
            a, z = self.args
            return gamma(a) * digamma(a) - log(z) * uppergamma(a, z) - meijerg([], [1, 1], [0, 0, a], [], z)

        else:
            raise ArgumentIndexError(self, argindex)
开发者ID:Krastanov,项目名称:sympy,代码行数:14,代码来源:gamma_functions.py

示例9: parse_term

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
    def parse_term(expr):
        """Parses expression expr and outputs tuple (sexpr, rat_expo, sym_expo, deriv)
        where:
         - sexpr is the base expression
         - rat_expo is the rational exponent that sexpr is raised to
         - sym_expo is the symbolic exponent that sexpr is raised to
         - deriv contains the derivatives the the expression

         for example, the output of x would be (x, 1, None, None)
         the output of 2**x would be (2, 1, x, None)
        """
        rat_expo, sym_expo = S.One, None
        sexpr, deriv = expr, None

        if expr.is_Pow:
            if isinstance(expr.base, Derivative):
                sexpr, deriv = parse_derivative(expr.base)
            else:
                sexpr = expr.base

            if expr.exp.is_Rational:
                rat_expo = expr.exp
            elif expr.exp.is_Mul:
                coeff, tail = expr.exp.as_coeff_terms()

                if coeff.is_Rational:
                    rat_expo, sym_expo = coeff, C.Mul(*tail)
                else:
                    sym_expo = expr.exp
            else:
                sym_expo = expr.exp
        elif expr.func is C.exp:
            if expr.args[0].is_Rational:
                sexpr, rat_expo = S.Exp1, expr.args[0]
            elif expr.args[0].is_Mul:
                coeff, tail = expr.args[0].as_coeff_terms()

                if coeff.is_Rational:
                    sexpr, rat_expo = C.exp(C.Mul(*tail)), coeff
        elif isinstance(expr, Derivative):
            sexpr, deriv = parse_derivative(expr)

        return sexpr, rat_expo, sym_expo, deriv
开发者ID:gnulinooks,项目名称:sympy,代码行数:45,代码来源:simplify.py

示例10: _together

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
    def _together(expr):

        from sympy.core.function import Function

        if expr.is_Add:
            items, coeffs, basis = [], [], {}

            for elem in expr.args:
                numer, q = fraction(_together(elem))

                denom = {}

                for term in make_list(q.expand(), Mul):
                    expo = S.One
                    coeff = S.One

                    if term.is_Pow:
                        if term.exp.is_Rational:
                            term, expo = term.base, term.exp
                        elif term.exp.is_Mul:
                            coeff, tail = term.exp.as_coeff_terms()
                            if coeff.is_Rational:
                                tail = C.Mul(*tail)
                                term, expo = Pow(term.base, tail), coeff
                        coeff = S.One
                    elif term.func is C.exp:
                        if term.args[0].is_Rational:
                            term, expo = S.Exp1, term.args[0]
                        elif term.args[0].is_Mul:
                            coeff, tail = term.args[0].as_coeff_terms()
                            if coeff.is_Rational:
                                tail = C.Mul(*tail)
                                term, expo = C.exp(tail), coeff
                        coeff = S.One
                    elif term.is_Rational:
                        coeff = Integer(term.q)
                        term = Integer(term.p)

                    if term in denom:
                        denom[term] += expo
                    else:
                        denom[term] = expo

                    if term in basis:
                        total, maxi = basis[term]

                        n_total = total + expo
                        n_maxi = max(maxi, expo)

                        basis[term] = (n_total, n_maxi)
                    else:
                        basis[term] = (expo, expo)

                    coeffs.append(coeff)
                items.append((numer, denom))

            numerator, denominator = [], []

            for (term, (total, maxi)) in basis.iteritems():
                basis[term] = (total, total-maxi)

                if term.func is C.exp:
                    denominator.append(C.exp(maxi*term.args[0]))
                else:
                    if maxi is S.One:
                        denominator.append(term)
                    else:
                        denominator.append(Pow(term, maxi))

            if all([ c.is_integer for c in coeffs ]):
                gcds = lambda x, y: igcd(int(x), int(y))
                common = Rational(reduce(gcds, coeffs))
            else:
                common = S.One

            product = reduce(lambda x, y: x*y, coeffs) / common

            for ((numer, denom), coeff) in zip(items, coeffs):

                expr, coeff = [], product / (coeff*common)

                for term in basis.iterkeys():
                    total, sub = basis[term]

                    if term in denom:
                        expo = total-denom[term]-sub
                    else:
                        expo = total-sub

                    if term.func is C.exp:
                        expr.append(C.exp(expo*term.args[0]))
                    else:
                        if expo is S.One:
                            expr.append(term)
                        else:
                            expr.append(Pow(term, expo))

                numerator.append(coeff*Mul(*([numer] + expr)))

            return Add(*numerator)/(product*Mul(*denominator))
#.........这里部分代码省略.........
开发者ID:gnulinooks,项目名称:sympy,代码行数:103,代码来源:simplify.py

示例11: _eval_rewrite_as_intractable

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def _eval_rewrite_as_intractable(self, z):
     return (S.One - erf(z))*C.exp(z**2)
开发者ID:Maihj,项目名称:sympy,代码行数:4,代码来源:error_functions.py

示例12: _eval_rewrite_as_tractable

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def _eval_rewrite_as_tractable(self, arg):
     return (C.exp(arg) + C.exp(-arg)) / 2
开发者ID:Bercio,项目名称:sympy,代码行数:4,代码来源:hyperbolic.py

示例13: _eval_rewrite_as_exp

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def _eval_rewrite_as_exp(self, arg):
     return (C.exp(arg) - C.exp(-arg)) / 2
开发者ID:Aang,项目名称:sympy,代码行数:4,代码来源:hyperbolic.py

示例14: _eval_rewrite_as_tractable

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def _eval_rewrite_as_tractable(self, z):
     return C.exp(loggamma(z))
开发者ID:Krastanov,项目名称:sympy,代码行数:4,代码来源:gamma_functions.py

示例15: _eval_rewrite_as_tractable

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import exp [as 别名]
 def _eval_rewrite_as_tractable(self, z):
     return S.One - _erfs(z)*C.exp(-z**2)
开发者ID:Maihj,项目名称:sympy,代码行数:4,代码来源:error_functions.py


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