• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python sympy.loggamma函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_FunctionWrapper

def test_FunctionWrapper():
    import sympy
    n, m, theta, phi = sympy.symbols("n, m, theta, phi")
    r = sympy.Ynm(n, m, theta, phi)
    s = Integer(2)*r
    assert isinstance(s, Mul)
    assert isinstance(s.args[1]._sympy_(), sympy.Ynm)

    x = symbols("x")
    e = x + sympy.loggamma(x)
    assert str(e) == "x + loggamma(x)"
    assert isinstance(e, Add)
    assert e + sympy.loggamma(x) == x + 2*sympy.loggamma(x)

    f = e.subs({x : 10})
    assert f == 10 + log(362880)

    f = e.subs({x : 2})
    assert f == 2

    f = e.subs({x : 100});
    v = f.n(53, real=True);
    assert abs(float(v) - 459.13420537) < 1e-7

    f = e.diff(x)
    assert f == 1 + sympy.polygamma(0, x)
开发者ID:kunal-iitkgp,项目名称:symengine.py,代码行数:26,代码来源:test_functions.py


示例2: test_intractable

def test_intractable():
    assert gruntz(1/gamma(x), x, oo) == 0
    assert gruntz(1/loggamma(x), x, oo) == 0
    assert gruntz(gamma(x)/loggamma(x), x, oo) == oo
    assert gruntz(exp(gamma(x))/gamma(x), x, oo) == oo
    assert gruntz(gamma(x), x, 3) == 2
    assert gruntz(gamma(S(1)/7 + 1/x), x, oo) == gamma(S(1)/7)
    assert gruntz(log(x**x)/log(gamma(x)), x, oo) == 1
    assert gruntz(log(gamma(gamma(x)))/exp(x), x, oo) == oo
开发者ID:agamdua,项目名称:sympy,代码行数:9,代码来源:test_gruntz.py


示例3: test_loggamma

def test_loggamma():
    raises(TypeError, lambda: loggamma(2, 3))
    raises(ArgumentIndexError, lambda: loggamma(x).fdiff(2))
    assert loggamma(x).diff(x) == polygamma(0, x)
    s1 = loggamma(1/(x + sin(x)) + cos(x)).nseries(x, n=4)
    s2 = (-log(2*x) - 1)/(2*x) - log(x/pi)/2 + (4 - log(2*x))*x/24 + O(x**2) + \
        log(x)*x**2/2
    assert (s1 - s2).expand(force=True).removeO() == 0
    s1 = loggamma(1/x).series(x)
    s2 = (1/x - S(1)/2)*log(1/x) - 1/x + log(2*pi)/2 + \
        x/12 - x**3/360 + x**5/1260 + O(x**7)
    assert ((s1 - s2).expand(force=True)).removeO() == 0

    assert loggamma(x).rewrite('intractable') == log(gamma(x))

    assert loggamma(x).is_real is None
    y, z = Symbol('y', real=True), Symbol('z', imaginary=True)
    assert loggamma(y).is_real
    assert loggamma(z).is_real is False

    def tN(N, M):
        assert loggamma(1/x)._eval_nseries(x, n=N, logx=None).getn() == M
    tN(0, 0)
    tN(1, 1)
    tN(2, 3)
    tN(3, 3)
    tN(4, 5)
    tN(5, 5)
开发者ID:QuaBoo,项目名称:sympy,代码行数:28,代码来源:test_gamma_functions.py


示例4: test_gruntz_eval_special

def test_gruntz_eval_special():
    # Gruntz, p. 126
    assert gruntz(exp(x) * (sin(1 / x + exp(-x)) - sin(1 / x + exp(-x ** 2))), x, oo) == 1
    assert gruntz((erf(x - exp(-exp(x))) - erf(x)) * exp(exp(x)) * exp(x ** 2), x, oo) == -2 / sqrt(pi)
    assert gruntz(exp(exp(x)) * (exp(sin(1 / x + exp(-exp(x)))) - exp(sin(1 / x))), x, oo) == 1
    assert gruntz(exp(x) * (gamma(x + exp(-x)) - gamma(x)), x, oo) == oo
    assert gruntz(exp(exp(digamma(digamma(x)))) / x, x, oo) == exp(-S(1) / 2)
    assert gruntz(exp(exp(digamma(log(x)))) / x, x, oo) == exp(-S(1) / 2)
    assert gruntz(digamma(digamma(digamma(x))), x, oo) == oo
    assert gruntz(loggamma(loggamma(x)), x, oo) == oo
    assert gruntz(((gamma(x + 1 / gamma(x)) - gamma(x)) / log(x) - cos(1 / x)) * x * log(x), x, oo) == -S(1) / 2
    assert gruntz(x * (gamma(x - 1 / gamma(x)) - gamma(x) + log(x)), x, oo) == S(1) / 2
    assert gruntz((gamma(x + 1 / gamma(x)) - gamma(x)) / log(x), x, oo) == 1
开发者ID:Carreau,项目名称:sympy,代码行数:13,代码来源:test_gruntz.py


示例5: test_function__eval_nseries

def test_function__eval_nseries():
    n = Symbol("n")

    assert sin(x)._eval_nseries(x, 2, None) == x + O(x ** 2)
    assert sin(x + 1)._eval_nseries(x, 2, None) == x * cos(1) + sin(1) + O(x ** 2)
    assert sin(pi * (1 - x))._eval_nseries(x, 2, None) == pi * x + O(x ** 2)
    assert acos(1 - x ** 2)._eval_nseries(x, 2, None) == sqrt(2) * x + O(x ** 2)
    assert polygamma(n, x + 1)._eval_nseries(x, 2, None) == polygamma(n, 1) + polygamma(n + 1, 1) * x + O(x ** 2)
    raises(PoleError, "sin(1/x)._eval_nseries(x,2,None)")
    raises(PoleError, "acos(1-x)._eval_nseries(x,2,None)")
    raises(PoleError, "acos(1+x)._eval_nseries(x,2,None)")
    assert loggamma(1 / x)._eval_nseries(x, 0, None) == log(x) / 2 - log(x) / x - 1 / x + O(1, x)
    assert loggamma(log(1 / x)).nseries(x, n=1, logx=y) == loggamma(-y)
开发者ID:ness01,项目名称:sympy,代码行数:13,代码来源:test_functions.py


示例6: test_loggamma

def test_loggamma():
    s1 = loggamma(1/(x+sin(x))+cos(x)).nseries(x,n=4)
    s2 = (-log(2*x)-1)/(2*x) - log(x/pi)/2 + (4-log(2*x))*x/24 + O(x**2)
    assert cancel(s1 - s2).removeO() == 0
    s1 = loggamma(1/x).series(x)
    s2 = (1/x-S(1)/2)*log(1/x) - 1/x  + log(2*pi)/2 + \
         x/12 - x**3/360 + x**5/1260 +  O(x**7)
    assert cancel(s1 - s2).removeO() == 0

    def tN(N, M):
        assert loggamma(1/x)._eval_nseries(x,n=N,logx=None).getn() == M
    tN(0, 0)
    tN(1, 1)
    tN(2, 3)
    tN(3, 3)
    tN(4, 5)
    tN(5, 5)
开发者ID:addisonc,项目名称:sympy,代码行数:17,代码来源:test_gamma_functions.py


示例7: test_function__eval_nseries

def test_function__eval_nseries():
    n = Symbol("n")

    assert sin(x)._eval_nseries(x, 2, None) == x + O(x ** 2)
    assert sin(x + 1)._eval_nseries(x, 2, None) == x * cos(1) + sin(1) + O(x ** 2)
    assert sin(pi * (1 - x))._eval_nseries(x, 2, None) == pi * x + O(x ** 2)
    assert acos(1 - x ** 2)._eval_nseries(x, 2, None) == sqrt(2) * x + O(x ** 2)
    assert polygamma(n, x + 1)._eval_nseries(x, 2, None) == polygamma(n, 1) + polygamma(n + 1, 1) * x + O(x ** 2)
    raises(PoleError, lambda: sin(1 / x)._eval_nseries(x, 2, None))
    raises(PoleError, lambda: acos(1 - x)._eval_nseries(x, 2, None))
    raises(PoleError, lambda: acos(1 + x)._eval_nseries(x, 2, None))
    assert loggamma(1 / x)._eval_nseries(x, 0, None) == log(x) / 2 - log(x) / x - 1 / x + O(1, x)
    assert loggamma(log(1 / x)).nseries(x, n=1, logx=y) == loggamma(-y)

    # issue 6725:
    assert expint(S(3) / 2, -x)._eval_nseries(x, 5, None) == 2 - 2 * sqrt(pi) * sqrt(
        -x
    ) - 2 * x - x ** 2 / 3 - x ** 3 / 15 - x ** 4 / 84 + O(x ** 5)
    assert sin(sqrt(x))._eval_nseries(x, 3, None) == sqrt(x) - x ** (S(3) / 2) / 6 + x ** (S(5) / 2) / 120 + O(x ** 3)
开发者ID:scopatz,项目名称:sympy,代码行数:19,代码来源:test_function.py


示例8: tN

 def tN(N, M):
     assert loggamma(1/x)._eval_nseries(x,n=N,logx=None).getn() == M
开发者ID:addisonc,项目名称:sympy,代码行数:2,代码来源:test_gamma_functions.py


示例9: test_loggamma

def test_loggamma():
    raises(TypeError, lambda: loggamma(2, 3))
    raises(ArgumentIndexError, lambda: loggamma(x).fdiff(2))

    assert loggamma(-1) == oo
    assert loggamma(-2) == oo
    assert loggamma(0) == oo
    assert loggamma(1) == 0
    assert loggamma(2) == 0
    assert loggamma(3) == log(2)
    assert loggamma(4) == log(6)

    n = Symbol("n", integer=True, positive=True)
    assert loggamma(n) == log(gamma(n))
    assert loggamma(-n) == oo
    assert loggamma(n/2) == log(2**(-n + 1)*sqrt(pi)*gamma(n)/gamma(n/2 + S.Half))

    from sympy import I

    assert loggamma(oo) == oo
    assert loggamma(-oo) == zoo
    assert loggamma(I*oo) == zoo
    assert loggamma(-I*oo) == zoo
    assert loggamma(zoo) == zoo
    assert loggamma(nan) == nan

    L = loggamma(S(16)/3)
    E = -5*log(3) + loggamma(S(1)/3) + log(4) + log(7) + log(10) + log(13)
    assert expand_func(L).doit() == E
    assert L.n() == E.n()

    L = loggamma(19/S(4))
    E = -4*log(4) + loggamma(S(3)/4) + log(3) + log(7) + log(11) + log(15)
    assert expand_func(L).doit() == E
    assert L.n() == E.n()

    L = loggamma(S(23)/7)
    E = -3*log(7) + log(2) + loggamma(S(2)/7) + log(9) + log(16)
    assert expand_func(L).doit() == E
    assert L.n() == E.n()

    L = loggamma(19/S(4)-7)
    E = -log(9) - log(5) + loggamma(S(3)/4) + 3*log(4) - 3*I*pi
    assert expand_func(L).doit() == E
    assert L.n() == E.n()

    L = loggamma(23/S(7)-6)
    E = -log(19) - log(12) - log(5) + loggamma(S(2)/7) + 3*log(7) - 3*I*pi
    assert expand_func(L).doit() == E
    assert L.n() == E.n()

    assert loggamma(x).diff(x) == polygamma(0, x)
    s1 = loggamma(1/(x + sin(x)) + cos(x)).nseries(x, n=4)
    s2 = (-log(2*x) - 1)/(2*x) - log(x/pi)/2 + (4 - log(2*x))*x/24 + O(x**2) + \
        log(x)*x**2/2
    assert (s1 - s2).expand(force=True).removeO() == 0
    s1 = loggamma(1/x).series(x)
    s2 = (1/x - S(1)/2)*log(1/x) - 1/x + log(2*pi)/2 + \
        x/12 - x**3/360 + x**5/1260 + O(x**7)
    assert ((s1 - s2).expand(force=True)).removeO() == 0

    assert loggamma(x).rewrite('intractable') == log(gamma(x))

    s1 = loggamma(x).series(x)
    assert s1 == -log(x) - EulerGamma*x + pi**2*x**2/12 + x**3*polygamma(2, 1)/6 + \
        pi**4*x**4/360 + x**5*polygamma(4, 1)/120 + O(x**6)
    assert s1 == loggamma(x).rewrite('intractable').series(x)

    assert conjugate(loggamma(x)) == loggamma(conjugate(x))
    assert conjugate(loggamma(0)) == conjugate(loggamma(0))
    assert conjugate(loggamma(1)) == loggamma(conjugate(1))
    assert conjugate(loggamma(-oo)) == conjugate(loggamma(-oo))
    assert loggamma(x).is_real is None
    y, z = Symbol('y', real=True), Symbol('z', imaginary=True)
    assert loggamma(y).is_real
    assert loggamma(z).is_real is False

    def tN(N, M):
        assert loggamma(1/x)._eval_nseries(x, n=N).getn() == M
    tN(0, 0)
    tN(1, 1)
    tN(2, 3)
    tN(3, 3)
    tN(4, 5)
    tN(5, 5)
开发者ID:A-turing-machine,项目名称:sympy,代码行数:85,代码来源:test_gamma_functions.py


示例10: test_polygamma

def test_polygamma():
    from sympy import I

    assert polygamma(n, nan) == nan

    assert polygamma(0, oo) == oo
    assert polygamma(0, -oo) == oo
    assert polygamma(0, I*oo) == oo
    assert polygamma(0, -I*oo) == oo
    assert polygamma(1, oo) == 0
    assert polygamma(5, oo) == 0

    assert polygamma(0, -9) == zoo

    assert polygamma(0, -9) == zoo
    assert polygamma(0, -1) == zoo

    assert polygamma(0, 0) == zoo

    assert polygamma(0, 1) == -EulerGamma
    assert polygamma(0, 7) == Rational(49, 20) - EulerGamma

    assert polygamma(1, 1) == pi**2/6
    assert polygamma(1, 2) == pi**2/6 - 1
    assert polygamma(1, 3) == pi**2/6 - Rational(5, 4)
    assert polygamma(3, 1) == pi**4 / 15
    assert polygamma(3, 5) == 6*(Rational(-22369, 20736) + pi**4/90)
    assert polygamma(5, 1) == 8 * pi**6 / 63

    def t(m, n):
        x = S(m)/n
        r = polygamma(0, x)
        if r.has(polygamma):
            return False
        return abs(polygamma(0, x.n()).n() - r.n()).n() < 1e-10
    assert t(1, 2)
    assert t(3, 2)
    assert t(-1, 2)
    assert t(1, 4)
    assert t(-3, 4)
    assert t(1, 3)
    assert t(4, 3)
    assert t(3, 4)
    assert t(2, 3)

    assert polygamma(0, x).rewrite(zeta) == polygamma(0, x)
    assert polygamma(1, x).rewrite(zeta) == zeta(2, x)
    assert polygamma(2, x).rewrite(zeta) == -2*zeta(3, x)

    assert polygamma(3, 7*x).diff(x) == 7*polygamma(4, 7*x)

    assert polygamma(0, x).rewrite(harmonic) == harmonic(x - 1) - EulerGamma
    assert polygamma(2, x).rewrite(harmonic) == 2*harmonic(x - 1, 3) - 2*zeta(3)
    ni = Symbol("n", integer=True)
    assert polygamma(ni, x).rewrite(harmonic) == (-1)**(ni + 1)*(-harmonic(x - 1, ni + 1)
                                                                 + zeta(ni + 1))*factorial(ni)

    # Polygamma of non-negative integer order is unbranched:
    from sympy import exp_polar
    k = Symbol('n', integer=True, nonnegative=True)
    assert polygamma(k, exp_polar(2*I*pi)*x) == polygamma(k, x)

    # but negative integers are branched!
    k = Symbol('n', integer=True)
    assert polygamma(k, exp_polar(2*I*pi)*x).args == (k, exp_polar(2*I*pi)*x)

    # Polygamma of order -1 is loggamma:
    assert polygamma(-1, x) == loggamma(x)

    # But smaller orders are iterated integrals and don't have a special name
    assert polygamma(-2, x).func is polygamma

    # Test a bug
    assert polygamma(0, -x).expand(func=True) == polygamma(0, -x)
开发者ID:A-turing-machine,项目名称:sympy,代码行数:74,代码来源:test_gamma_functions.py


示例11: test_loggamma

def test_loggamma():
    raises(TypeError, lambda: loggamma(2, 3))
    raises(ArgumentIndexError, lambda: loggamma(x).fdiff(2))
    assert loggamma(x).diff(x) == polygamma(0, x)
    s1 = loggamma(1 / (x + sin(x)) + cos(x)).nseries(x, n=4)
    s2 = (-log(2 * x) - 1) / (2 * x) - log(x / pi) / 2 + (4 - log(2 * x)) * x / 24 + O(x ** 2) + log(x) * x ** 2 / 2
    assert (s1 - s2).expand(force=True).removeO() == 0
    s1 = loggamma(1 / x).series(x)
    s2 = (1 / x - S(1) / 2) * log(1 / x) - 1 / x + log(2 * pi) / 2 + x / 12 - x ** 3 / 360 + x ** 5 / 1260 + O(x ** 7)
    assert ((s1 - s2).expand(force=True)).removeO() == 0

    assert loggamma(x).rewrite("intractable") == log(gamma(x))

    s1 = loggamma(x).series(x)
    assert s1 == -log(x) - EulerGamma * x + pi ** 2 * x ** 2 / 12 + x ** 3 * polygamma(
        2, 1
    ) / 6 + pi ** 4 * x ** 4 / 360 + x ** 5 * polygamma(4, 1) / 120 + O(x ** 6)
    assert s1 == loggamma(x).rewrite("intractable").series(x)

    assert conjugate(loggamma(x)) == loggamma(conjugate(x))
    assert conjugate(loggamma(0)) == conjugate(loggamma(0))
    assert conjugate(loggamma(1)) == loggamma(conjugate(1))
    assert conjugate(loggamma(-oo)) == conjugate(loggamma(-oo))
    assert loggamma(x).is_real is None
    y, z = Symbol("y", real=True), Symbol("z", imaginary=True)
    assert loggamma(y).is_real
    assert loggamma(z).is_real is False

    def tN(N, M):
        assert loggamma(1 / x)._eval_nseries(x, n=N).getn() == M

    tN(0, 0)
    tN(1, 1)
    tN(2, 3)
    tN(3, 3)
    tN(4, 5)
    tN(5, 5)
开发者ID:melsophos,项目名称:sympy,代码行数:37,代码来源:test_gamma_functions.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python sympy.lowergamma函数代码示例发布时间:2022-05-27
下一篇:
Python sympy.logcombine函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap