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


Python C.re方法代码示例

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


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

示例1: _eval_expand_trig

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import re [as 别名]
    def _eval_expand_trig(self, **hints):
        arg = self.args[0]
        x = None
        if arg.is_Add:
            from sympy import symmetric_poly
            n = len(arg.args)
            TX = []
            for x in arg.args:
                tx = tan(x, evaluate=False)._eval_expand_trig()
                TX.append(tx)

            Yg = numbered_symbols('Y')
            Y = [ Yg.next() for i in xrange(n) ]

            p = [0,0]
            for i in xrange(n+1):
                p[1-i%2] += symmetric_poly(i,Y)*(-1)**((i%4)//2)
            return (p[0]/p[1]).subs(zip(Y,TX))

        else:
            coeff, terms = arg.as_coeff_Mul(rational=True)
            if coeff.is_Integer and coeff > 1:
                I = S.ImaginaryUnit
                z = C.Symbol('dummy',real=True)
                P = ((1+I*z)**coeff).expand()
                return (C.im(P)/C.re(P)).subs([(z,tan(terms))])
        return tan(arg)
开发者ID:bhlegm,项目名称:sympy,代码行数:29,代码来源:trigonometric.py

示例2: _eval_expand_trig

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import re [as 别名]
    def _eval_expand_trig(self, **hints):
        arg = self.args[0]
        x = None
        if arg.is_Add:
            from sympy import symmetric_poly

            n = len(arg.args)
            CX = []
            for x in arg.args:
                cx = cot(x, evaluate=False)._eval_expand_trig()
                CX.append(cx)

            Yg = numbered_symbols("Y")
            Y = [Yg.next() for i in xrange(n)]

            p = [0, 0]
            for i in xrange(n, -1, -1):
                p[(n - i) % 2] += symmetric_poly(i, Y) * (-1) ** (((n - i) % 4) // 2)
            return (p[0] / p[1]).subs(zip(Y, CX))
        else:
            coeff, terms = arg.as_coeff_Mul(rational=True)
            if coeff.is_Integer and coeff > 1:
                I = S.ImaginaryUnit
                z = C.Symbol("dummy", real=True)
                P = ((z + I) ** coeff).expand()
                return (C.re(P) / C.im(P)).subs([(z, cot(terms))])
        return cot(arg)
开发者ID:amitjamadagni,项目名称:sympy,代码行数:29,代码来源:trigonometric.py

示例3: as_real_imag

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import re [as 别名]
 def as_real_imag(self, deep=True, **hints):
     other = []
     coeff = S(1)
     for a in self.args:
         if a.is_real:
             coeff *= a
         else:
             other.append(a)
     m = Mul(*other)
     if hints.get('ignore') == m:
         return None
     else:
         return (coeff*C.re(m), coeff*C.im(m))
开发者ID:FireJade,项目名称:sympy,代码行数:15,代码来源:mul.py

示例4: eval

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import re [as 别名]
    def eval(cls, n, a, x):
        # For negative n the polynomials vanish
        # See http://functions.wolfram.com/Polynomials/GegenbauerC3/03/01/03/0012/
        if n.is_negative:
            return S.Zero

        # Some special values for fixed a
        if a == S.Half:
            return legendre(n, x)
        elif a == S.One:
            return chebyshevu(n, x)
        elif a == S.NegativeOne:
            return S.Zero

        if not n.is_Number:
            # Handle this before the general sign extraction rule
            if x == S.NegativeOne:
                if (C.re(a) > S.Half) == True:
                    return S.ComplexInfinity
                else:
                    # No sec function available yet
                    # return (C.cos(S.Pi*(a+n)) * C.sec(S.Pi*a) * C.gamma(2*a+n) /
                    #            (C.gamma(2*a) * C.gamma(n+1)))
                    return None

            # Symbolic result C^a_n(x)
            # C^a_n(-x)  --->  (-1)**n * C^a_n(x)
            if x.could_extract_minus_sign():
                return S.NegativeOne ** n * gegenbauer(n, a, -x)
            # We can evaluate for some special values of x
            if x == S.Zero:
                return (
                    2 ** n * sqrt(S.Pi) * C.gamma(a + S.Half * n) / (C.gamma((1 - n) / 2) * C.gamma(n + 1) * C.gamma(a))
                )
            if x == S.One:
                return C.gamma(2 * a + n) / (C.gamma(2 * a) * C.gamma(n + 1))
            elif x == S.Infinity:
                if n.is_positive:
                    return C.RisingFactorial(a, n) * S.Infinity
        else:
            # n is a given fixed integer, evaluate into polynomial
            return gegenbauer_poly(n, a, x)
开发者ID:B-Rich,项目名称:sympy,代码行数:44,代码来源:polynomials.py

示例5: as_real_imag

# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import re [as 别名]
 def as_real_imag(self, deep=True, **hints):
     other = []
     coeff = S(1)
     for a in self.args:
         if a.is_real:
             coeff *= a
         elif a.is_commutative:
             # search for complex conjugate pairs:
             for i, x in enumerate(other):
                 if x == a.conjugate():
                     coeff *= C.Abs(x)**2
                     del other[i]
                     break
             else:
                 other.append(a)
         else:
             other.append(a)
     m = Mul(*other)
     if hints.get('ignore') == m:
         return None
     else:
         return (coeff*C.re(m), coeff*C.im(m))
开发者ID:Abhityagi16,项目名称:sympy,代码行数:24,代码来源:mul.py


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