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


Python mpmath.sqrt方法代码示例

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


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

示例1: test_ladder_operator_coefficient

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_ladder_operator_coefficient():
    # for ell in range(sf.ell_max + 1):
    #     for m in range(-ell, ell + 1):
    #         a = math.sqrt(ell * (ell + 1) - m * (m + 1))
    #         b = sf.ladder_operator_coefficient(ell, m)
    #         if (m == ell):
    #             assert b == 0.0
    #         else:
    #             assert abs(a - b) / (abs(a) + abs(b)) < 3e-16
    for twoell in range(2*sf.ell_max + 1):
        for twom in range(-twoell, twoell + 1, 2):
            a = math.sqrt(twoell * (twoell + 2) - twom * (twom + 2))/2
            b = sf._ladder_operator_coefficient(twoell, twom)
            c = sf.ladder_operator_coefficient(twoell/2, twom/2)
            if (twom == twoell):
                assert b == 0.0 and c == 0.0
            else:
                assert abs(a - b) / (abs(a) + abs(b)) < 3e-16 and abs(a - c) / (abs(a) + abs(c)) < 3e-16 
开发者ID:moble,项目名称:spherical_functions,代码行数:20,代码来源:test_spherical_functions.py

示例2: compute_a

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def compute_a(n):
    """a_k from DLMF 5.11.6"""
    a = [mp.sqrt(2)/2]
    for k in range(1, n):
        ak = a[-1]/k
        for j in range(1, len(a)):
            ak -= a[j]*a[-j]/(j + 1)
        ak /= a[0]*(1 + mp.mpf(1)/(k + 1))
        a.append(ak)
    return a 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,代码来源:gammainc_asy.py

示例3: compute_g

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def compute_g(n):
    """g_k from DLMF 5.11.3/5.11.5"""
    a = compute_a(2*n)
    g = []
    for k in range(n):
        g.append(mp.sqrt(2)*mp.rf(0.5, k)*a[2*k])
    return g 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:9,代码来源:gammainc_asy.py

示例4: eta

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def eta(lam):
    """Function from DLMF 8.12.1 shifted to be centered at 0."""
    if lam > 0:
        return mp.sqrt(2*(lam - mp.log(lam + 1)))
    elif lam < 0:
        return -mp.sqrt(2*(lam - mp.log(lam + 1)))
    else:
        return 0 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:10,代码来源:gammainc_asy.py

示例5: _student_t_cdf

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def _student_t_cdf(df, t, dps=None):
    if dps is None:
        dps = mpmath.mp.dps
    with mpmath.workdps(dps):
        df, t = mpmath.mpf(df), mpmath.mpf(t)
        fac = mpmath.hyp2f1(0.5, 0.5*(df + 1), 1.5, -t**2/df)
        fac *= t*mpmath.gamma(0.5*(df + 1))
        fac /= mpmath.sqrt(mpmath.pi*df)*mpmath.gamma(0.5*df)
        return 0.5 + fac 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:11,代码来源:test_cdflib.py

示例6: _noncentral_chi_pdf

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def _noncentral_chi_pdf(t, df, nc):
    res = mpmath.besseli(df/2 - 1, mpmath.sqrt(nc*t))
    res *= mpmath.exp(-(t + nc)/2)*(t/nc)**(df/4 - 1/2)/2
    return res 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:6,代码来源:test_cdflib.py

示例7: test_log_ndtr_complex

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_log_ndtr_complex(self):
        assert_mpmath_equal(sc.log_ndtr,
                            exception_to_nan(lambda z: mpmath.log(mpmath.erfc(-z/np.sqrt(2.))/2.)),
                            [ComplexArg(a=complex(-10000, -100),
                                        b=complex(10000, 100))], n=200, dps=300) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:7,代码来源:test_mpmath.py

示例8: test_j0

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_j0(self):
        # The Bessel function at large arguments is j0(x) ~ cos(x + phi)/sqrt(x)
        # and at large arguments the phase of the cosine loses precision.
        #
        # This is numerically expected behavior, so we compare only up to
        # 1e8 = 1e15 * 1e-7
        assert_mpmath_equal(sc.j0,
                            mpmath.j0,
                            [Arg(-1e3, 1e3)])
        assert_mpmath_equal(sc.j0,
                            mpmath.j0,
                            [Arg(-1e8, 1e8)],
                            rtol=1e-5) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:15,代码来源:test_mpmath.py

示例9: test_spherical_jn

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_spherical_jn(self):
        def mp_spherical_jn(n, z):
            arg = mpmath.mpmathify(z)
            out = (mpmath.besselj(n + mpmath.mpf(1)/2, arg) /
                   mpmath.sqrt(2*arg/mpmath.pi))
            if arg.imag == 0:
                return out.real
            else:
                return out

        assert_mpmath_equal(lambda n, z: sc.spherical_jn(int(n), z),
                            exception_to_nan(mp_spherical_jn),
                            [IntArg(0, 200), Arg(-1e8, 1e8)],
                            dps=300) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:16,代码来源:test_mpmath.py

示例10: test_spherical_jn_complex

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_spherical_jn_complex(self):
        def mp_spherical_jn(n, z):
            arg = mpmath.mpmathify(z)
            out = (mpmath.besselj(n + mpmath.mpf(1)/2, arg) /
                   mpmath.sqrt(2*arg/mpmath.pi))
            if arg.imag == 0:
                return out.real
            else:
                return out

        assert_mpmath_equal(lambda n, z: sc.spherical_jn(int(n.real), z),
                            exception_to_nan(mp_spherical_jn),
                            [IntArg(0, 200), ComplexArg()]) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:15,代码来源:test_mpmath.py

示例11: test_spherical_yn

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_spherical_yn(self):
        def mp_spherical_yn(n, z):
            arg = mpmath.mpmathify(z)
            out = (mpmath.bessely(n + mpmath.mpf(1)/2, arg) /
                   mpmath.sqrt(2*arg/mpmath.pi))
            if arg.imag == 0:
                return out.real
            else:
                return out

        assert_mpmath_equal(lambda n, z: sc.spherical_yn(int(n), z),
                            exception_to_nan(mp_spherical_yn),
                            [IntArg(0, 200), Arg(-1e10, 1e10)],
                            dps=100) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:16,代码来源:test_mpmath.py

示例12: test_spherical_in

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_spherical_in(self):
        def mp_spherical_in(n, z):
            arg = mpmath.mpmathify(z)
            out = (mpmath.besseli(n + mpmath.mpf(1)/2, arg) /
                   mpmath.sqrt(2*arg/mpmath.pi))
            if arg.imag == 0:
                return out.real
            else:
                return out

        assert_mpmath_equal(lambda n, z: sc.spherical_in(int(n), z),
                            exception_to_nan(mp_spherical_in),
                            [IntArg(0, 200), Arg()],
                            dps=200, atol=10**(-278)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:16,代码来源:test_mpmath.py

示例13: test_spherical_in_complex

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_spherical_in_complex(self):
        def mp_spherical_in(n, z):
            arg = mpmath.mpmathify(z)
            out = (mpmath.besseli(n + mpmath.mpf(1)/2, arg) /
                   mpmath.sqrt(2*arg/mpmath.pi))
            if arg.imag == 0:
                return out.real
            else:
                return out

        assert_mpmath_equal(lambda n, z: sc.spherical_in(int(n.real), z),
                            exception_to_nan(mp_spherical_in),
                            [IntArg(0, 200), ComplexArg()]) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:15,代码来源:test_mpmath.py

示例14: test_spherical_kn

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_spherical_kn(self):
        def mp_spherical_kn(n, z):
            out = (mpmath.besselk(n + mpmath.mpf(1)/2, z) *
                   mpmath.sqrt(mpmath.pi/(2*mpmath.mpmathify(z))))
            if mpmath.mpmathify(z).imag == 0:
                return out.real
            else:
                return out

        assert_mpmath_equal(lambda n, z: sc.spherical_kn(int(n), z),
                            exception_to_nan(mp_spherical_kn),
                            [IntArg(0, 150), Arg()],
                            dps=100) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:15,代码来源:test_mpmath.py

示例15: test_spherical_kn_complex

# 需要导入模块: import mpmath [as 别名]
# 或者: from mpmath import sqrt [as 别名]
def test_spherical_kn_complex(self):
        def mp_spherical_kn(n, z):
            arg = mpmath.mpmathify(z)
            out = (mpmath.besselk(n + mpmath.mpf(1)/2, arg) /
                   mpmath.sqrt(2*arg/mpmath.pi))
            if arg.imag == 0:
                return out.real
            else:
                return out

        assert_mpmath_equal(lambda n, z: sc.spherical_kn(int(n.real), z),
                            exception_to_nan(mp_spherical_kn),
                            [IntArg(0, 200), ComplexArg()],
                            dps=200) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:16,代码来源:test_mpmath.py


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