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


Python C.floor方法代码示例

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


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

示例1: real_root

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import floor [as 别名]
def real_root(arg, n=None):
    """Return the real nth-root of arg if possible. If n is omitted then
    all instances of (-n)**(1/odd) will be changed to -n**(1/odd); this
    will only create a real root of a principle root -- the presence of
    other factors may cause the result to not be real.

    Examples
    ========

    >>> from sympy import root, real_root, Rational
    >>> from sympy.abc import x, n

    >>> real_root(-8, 3)
    -2
    >>> root(-8, 3)
    2*(-1)**(1/3)
    >>> real_root(_)
    -2

    If one creates a non-principle root and applies real_root, the
    result will not be real (so use with caution):

    >>> root(-8, 3, 2)
    -2*(-1)**(2/3)
    >>> real_root(_)
    -2*(-1)**(2/3)


    See Also
    ========

    sympy.polys.rootoftools.RootOf
    sympy.core.power.integer_nthroot
    root, sqrt
    """
    if n is not None:
        try:
            n = as_int(n)
            arg = sympify(arg)
            if arg.is_positive or arg.is_negative:
                rv = root(arg, n)
            else:
                raise ValueError
        except ValueError:
            return root(arg, n)*C.Piecewise(
                (S.One, ~C.Equality(C.im(arg), 0)),
                (C.Pow(S.NegativeOne, S.One/n)**(2*C.floor(n/2)), C.And(
                    C.Equality(n % 2, 1),
                    arg < 0)),
                (S.One, True))
    else:
        rv = sympify(arg)
    n1pow = Transform(lambda x: -(-x.base)**x.exp,
                      lambda x:
                      x.is_Pow and
                      x.base.is_negative and
                      x.exp.is_Rational and
                      x.exp.p == 1 and x.exp.q % 2)
    return rv.xreplace(n1pow)
开发者ID:artcompiler,项目名称:artcompiler.github.com,代码行数:61,代码来源:miscellaneous.py

示例2: taylor_term

# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import floor [as 别名]
 def taylor_term(n, x, *previous_terms):
     if n < 0 or n % 2 == 0:
         return S.Zero
     else:
         x = sympify(x)
         k = C.floor((n - 1)/S(2))
         if len(previous_terms) > 2:
             return -previous_terms[-2] * x**2 * (n - 2)/(n*k)
         else:
             return 2*(-1)**k * x**n/(n*C.factorial(k)*sqrt(S.Pi))
开发者ID:Maihj,项目名称:sympy,代码行数:12,代码来源:error_functions.py


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