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


Python hyperexpand.hyperexpand函数代码示例

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


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

示例1: test_polynomial

def test_polynomial():
    from sympy import oo
    assert hyperexpand(hyper([], [-1], z)) == oo
    assert hyperexpand(hyper([-2], [-1], z)) == oo
    assert hyperexpand(hyper([0, 0], [-1], z)) == 1
    assert can_do([-5, -2, randcplx(), randcplx()], [-10, randcplx()])
    assert hyperexpand(hyper((-1, 1), (-2,), z)) == 1 + z/2
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:7,代码来源:test_hyperexpand.py

示例2: test_branch_bug

def test_branch_bug():
    assert hyperexpand(hyper((-S(1)/3, S(1)/2), (S(2)/3, S(3)/2), -z)) == \
        -z**S('1/3')*lowergamma(exp_polar(I*pi)/3, z)/5 \
        + sqrt(pi)*erf(sqrt(z))/(5*sqrt(z))
    assert hyperexpand(meijerg([S(7)/6, 1], [], [S(2)/3], [S(1)/6, 0], z)) == \
        2*z**S('2/3')*(2*sqrt(pi)*erf(sqrt(z))/sqrt(z) - 2*lowergamma(
                       S(2)/3, z)/z**S('2/3'))*gamma(S(2)/3)/gamma(S(5)/3)
开发者ID:vprusso,项目名称:sympy,代码行数:7,代码来源:test_hyperexpand.py

示例3: test_partial_simp

def test_partial_simp():
    # First test that hypergeometric function formulae work.
    a, b, c, d, e = map(lambda _: randcplx(), range(5))
    for func in [Hyper_Function([a, b, c], [d, e]),
            Hyper_Function([], [a, b, c, d, e])]:
        f = build_hypergeometric_formula(func)
        z = f.z
        assert f.closed_form == func(z)
        deriv1 = f.B.diff(z)*z
        deriv2 = f.M*f.B
        for func1, func2 in zip(deriv1, deriv2):
            assert tn(func1, func2, z)

    # Now test that formulae are partially simplified.
    from sympy.abc import a, b, z
    assert hyperexpand(hyper([3, a], [1, b], z)) == \
        (-a*b/2 + a*z/2 + 2*a)*hyper([a + 1], [b], z) \
        + (a*b/2 - 2*a + 1)*hyper([a], [b], z)
    assert tn(
        hyperexpand(hyper([3, d], [1, e], z)), hyper([3, d], [1, e], z), z)
    assert hyperexpand(hyper([3], [1, a, b], z)) == \
        hyper((), (a, b), z) \
        + z*hyper((), (a + 1, b), z)/(2*a) \
        - z*(b - 4)*hyper((), (a + 1, b + 1), z)/(2*a*b)
    assert tn(
        hyperexpand(hyper([3], [1, d, e], z)), hyper([3], [1, d, e], z), z)
开发者ID:vprusso,项目名称:sympy,代码行数:26,代码来源:test_hyperexpand.py

示例4: test_meijerg_expand

def test_meijerg_expand():
    from sympy import combsimp, simplify
    # from mpmath docs
    assert hyperexpand(meijerg([[], []], [[0], []], -z)) == exp(z)

    assert hyperexpand(meijerg([[1, 1], []], [[1], [0]], z)) == \
        log(z + 1)
    assert hyperexpand(meijerg([[1, 1], []], [[1], [1]], z)) == \
        z/(z + 1)
    assert hyperexpand(meijerg([[], []], [[S(1)/2], [0]], (z/2)**2)) \
           == sin(z)/sqrt(pi)
    assert hyperexpand(meijerg([[], []], [[0], [S(1)/2]], (z/2)**2)) \
           == cos(z)/sqrt(pi)
    assert can_do_meijer([], [a], [a - 1, a - S.Half], [])
    assert can_do_meijer([], [], [a/2], [-a/2], False)  # branches...
    assert can_do_meijer([a], [b], [a], [b, a - 1])

    # wikipedia
    assert hyperexpand(meijerg([1], [], [], [0], z)) == \
       Piecewise((0, abs(z) < 1), (1, abs(1/z) < 1),
                 (meijerg([1], [], [], [0], z), True))
    assert hyperexpand(meijerg([], [1], [0], [], z)) == \
       Piecewise((1, abs(z) < 1), (0, abs(1/z) < 1),
                 (meijerg([], [1], [0], [], z), True))

    # The Special Functions and their Approximations
    assert can_do_meijer([], [], [a + b/2], [a, a - b/2, a + S.Half])
    assert can_do_meijer(
        [], [], [a], [b], False)  # branches only agree for small z
    assert can_do_meijer([], [S.Half], [a], [-a])
    assert can_do_meijer([], [], [a, b], [])
    assert can_do_meijer([], [], [a, b], [])
    assert can_do_meijer([], [], [a, a + S.Half], [b, b + S.Half])
    assert can_do_meijer([], [], [a, -a], [0, S.Half], False)  # dito
    assert can_do_meijer([], [], [a, a + S.Half, b, b + S.Half], [])
    assert can_do_meijer([S.Half], [], [0], [a, -a])
    assert can_do_meijer([S.Half], [], [a], [0, -a], False)  # dito
    assert can_do_meijer([], [a - S.Half], [a, b], [a - S.Half], False)
    assert can_do_meijer([], [a + S.Half], [a + b, a - b, a], [], False)
    assert can_do_meijer([a + S.Half], [], [b, 2*a - b, a], [], False)

    # This for example is actually zero.
    assert can_do_meijer([], [], [], [a, b])

    # Testing a bug:
    assert hyperexpand(meijerg([0, 2], [], [], [-1, 1], z)) == \
        Piecewise((0, abs(z) < 1),
                  (z*(1 - 1/z**2)/2, abs(1/z) < 1),
                  (meijerg([0, 2], [], [], [-1, 1], z), True))

    # Test that the simplest possible answer is returned:
    assert combsimp(
        simplify(hyperexpand(meijerg([1], [1 - a], [-a/2, -a/2 + S(1)/2],
                                                 [], 1/z)))) == \
           -2*sqrt(pi)*(sqrt(z + 1) + 1)**a/a

    # Test that hyper is returned
    assert hyperexpand(meijerg([1], [], [a], [0, 0], z)) == \
           z**a*gamma(a)*hyper(
               (a,), (a + 1, a + 1), z*exp_polar(I*pi))/gamma(a + 1)**2
开发者ID:jenshnielsen,项目名称:sympy,代码行数:60,代码来源:test_hyperexpand.py

示例5: test_hyperexpand_parametric

def test_hyperexpand_parametric():
    assert (
        hyperexpand(hyper([a, S(1) / 2 + a], [S(1) / 2], z))
        == (1 + sqrt(z)) ** (-2 * a) / 2 + (1 - sqrt(z)) ** (-2 * a) / 2
    )
    assert hyperexpand(hyper([a, -S(1) / 2 + a], [2 * a], z)) == 2 ** (2 * a - 1) * ((-z + 1) ** (S(1) / 2) + 1) ** (
        -2 * a + 1
    )
开发者ID:mattpap,项目名称:sympy,代码行数:8,代码来源:test_hyperexpand.py

示例6: test_meijerg_lookup

def test_meijerg_lookup():
    from sympy import uppergamma

    assert hyperexpand(meijerg([a], [], [b, a], [], z)) == z ** b * exp(z) * gamma(-a + b + 1) * uppergamma(a - b, z)
    assert hyperexpand(meijerg([0], [], [0, 0], [], z)) == exp(z) * uppergamma(0, z)
    assert can_do_meijer([a], [], [b, a + 1], [])
    assert can_do_meijer([a], [], [b + 2, a], [])
    assert can_do_meijer([a], [], [b - 2, a], [])
开发者ID:kristenmills,项目名称:sympy,代码行数:8,代码来源:test_hyperexpand.py

示例7: test_hyperexpand

def test_hyperexpand():
    # Luke, Y. L. (1969), The Special Functions and Their Approximations,
    # Volume 1, section 6.2

    assert hyperexpand(hyper([], [], z)) == exp(z)
    assert hyperexpand(hyper([1, 1], [2], -z) * z) == log(1 + z)
    assert hyperexpand(hyper([], [S.Half], -z ** 2 / 4)) == cos(z)
    assert hyperexpand(z * hyper([], [S("3/2")], -z ** 2 / 4)) == sin(z)
    assert hyperexpand(hyper([S("1/2"), S("1/2")], [S("3/2")], z ** 2) * z) == asin(z)
开发者ID:mattpap,项目名称:sympy,代码行数:9,代码来源:test_hyperexpand.py

示例8: test_hyperexpand_special

def test_hyperexpand_special():
    assert hyperexpand(hyper([a, b], [c], 1)) == \
           gamma(c)*gamma(c - a - b)/gamma(c - a)/gamma(c - b)
    assert hyperexpand(hyper([a, b], [1 + a - b], -1)) == \
           gamma(1 + a/2)*gamma(1 + a - b)/gamma(1 + a)/gamma(1 + a/2 - b)
    assert hyperexpand(hyper([a, b], [1 + b - a], -1)) == \
           gamma(1 + b/2)*gamma(1 + b - a)/gamma(1 + b)/gamma(1 + b/2 - a)
    assert hyperexpand(meijerg([1 - z - a/2], [1 - z + a/2], [b/2], [-b/2], 1)) == \
           gamma(1 - 2*z)*gamma(z + a/2 + b/2)/gamma(1 - z + a/2 - b/2) \
           /gamma(1 - z - a/2 + b/2)/gamma(1 - z + a/2 + b/2)
开发者ID:ALGHeArT,项目名称:sympy,代码行数:10,代码来源:test_hyperexpand.py

示例9: test_hyperexpand

def test_hyperexpand():
    # Luke, Y. L. (1969), The Special Functions and Their Approximations,
    # Volume 1, section 6.2

    assert hyperexpand(hyper([], [], z)) == exp(z)
    assert hyperexpand(hyper([1, 1], [2], -z)*z) == log(1 + z)
    assert hyperexpand(hyper([], [S.Half], -z**2/4)) == cos(z)
    assert hyperexpand(z*hyper([], [S('3/2')], -z**2/4)) == sin(z)
    assert hyperexpand(hyper([S('1/2'), S('1/2')], [S('3/2')], z**2)*z) \
        == asin(z)
    assert isinstance(Sum(binomial(2, z)*z**2, (z, 0, a)).doit(), Expr)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:11,代码来源:test_hyperexpand.py

示例10: test_hyperexpand_bases

def test_hyperexpand_bases():
    assert (
        hyperexpand(hyper([2], [a], z))
        == a + z ** (-a + 1) * (-a ** 2 + 3 * a + z * (a - 1) - 2) * exp(z) * lowergamma(a - 1, z) - 1
    )
    # TODO [a+1, a-S.Half], [2*a]
    assert hyperexpand(hyper([1, 2], [3], z)) == -2 / z - 2 * log(exp_polar(-I * pi) * z + 1) / z ** 2
    assert hyperexpand(hyper([S.Half, 2], [S(3) / 2], z)) == -1 / (2 * z - 2) + log((sqrt(z) + 1) / (-sqrt(z) + 1)) / (
        4 * sqrt(z)
    )
    assert hyperexpand(hyper([S(1) / 2, S(1) / 2], [S(5) / 2], z)) == (-3 * z + 3) / 4 / (z * sqrt(-z + 1)) + (
        6 * z - 3
    ) * asin(sqrt(z)) / (4 * z ** (S(3) / 2))
    assert hyperexpand(hyper([1, 2], [S(3) / 2], z)) == -1 / (2 * z - 2) - asin(sqrt(z)) / (
        sqrt(z) * (2 * z - 2) * sqrt(-z + 1)
    )
    assert hyperexpand(hyper([-S.Half - 1, 1, 2], [S.Half, 3], z)) == sqrt(z) * (6 * z / 7 - S(6) / 5) * atanh(
        sqrt(z)
    ) + (-30 * z ** 2 + 32 * z - 6) / 35 / z - 6 * log(-z + 1) / (35 * z ** 2)
    assert hyperexpand(hyper([1 + S.Half, 1, 1], [2, 2], z)) == -4 * log(sqrt(-z + 1) / 2 + S(1) / 2) / z
    # TODO hyperexpand(hyper([a], [2*a + 1], z))
    # TODO [S.Half, a], [S(3)/2, a+1]
    assert hyperexpand(hyper([2], [b, 1], z)) == z ** (-b / 2 + S(1) / 2) * besseli(b - 1, 2 * sqrt(z)) * gamma(
        b
    ) + z ** (-b / 2 + 1) * besseli(b, 2 * sqrt(z)) * gamma(b)
开发者ID:kendhia,项目名称:sympy,代码行数:25,代码来源:test_hyperexpand.py

示例11: test_shifted_sum

def test_shifted_sum():
    from sympy import simplify

    assert (
        simplify(hyperexpand(z ** 4 * hyper([2], [3, S("3/2")], -z ** 2)))
        == z * sin(2 * z) + (-z ** 2 + S.Half) * cos(2 * z) - S.Half
    )
开发者ID:mattpap,项目名称:sympy,代码行数:7,代码来源:test_hyperexpand.py

示例12: can_do_meijer

def can_do_meijer(a1, a2, b1, b2, numeric=True):
    """
    This helper function tries to hyperexpand() the meijer g-function
    corresponding to the parameters a1, a2, b1, b2.
    It returns False if this expansion still contains g-functions.
    If numeric is True, it also tests the so-obtained formula numerically
    (at random values) and returns False if the test fails.
    Else it returns True.
    """
    from sympy import unpolarify, expand
    r = hyperexpand(meijerg(a1, a2, b1, b2, z))
    if r.has(meijerg):
        return False
    # NOTE hyperexpand() returns a truly branched function, whereas numerical
    #      evaluation only works on the main branch. Since we are evaluating on
    #      the main branch, this should not be a problem, but expressions like
    #      exp_polar(I*pi/2*x)**a are evaluated incorrectly. We thus have to get
    #      rid of them. The expand heuristically does this...
    r = unpolarify(expand(r, force=True, power_base=True, power_exp=False,
                          mul=False, log=False, multinomial=False, basic=False))

    if not numeric:
        return True

    repl = {}
    for n, a in enumerate(meijerg(a1, a2, b1, b2, z).free_symbols - set([z])):
        repl[a] = randcplx(n)
    return tn(meijerg(a1, a2, b1, b2, z).subs(repl), r.subs(repl), z)
开发者ID:vprusso,项目名称:sympy,代码行数:28,代码来源:test_hyperexpand.py

示例13: test_meijerg_with_Floats

def test_meijerg_with_Floats():
    # see issue #10681
    from sympy import RR
    f = meijerg(((3.0, 1), ()), ((S(3)/2,), (0,)), z)
    a = -2.3632718012073
    g = a*z**(S(3)/2)*hyper((-0.5, S(3)/2), (S(5)/2,), z*exp_polar(I*pi))
    assert RR.almosteq((hyperexpand(f)/g).n(), 1.0, 1e-12)
开发者ID:chaffra,项目名称:sympy,代码行数:7,代码来源:test_hyperexpand.py

示例14: test_meijerg_lookup

def test_meijerg_lookup():
    from sympy import uppergamma, Si, Ci
    assert hyperexpand(meijerg([a], [], [b, a], [], z)) == \
        z**b*exp(z)*gamma(-a + b + 1)*uppergamma(a - b, z)
    assert hyperexpand(meijerg([0], [], [0, 0], [], z)) == \
        exp(z)*uppergamma(0, z)
    assert can_do_meijer([a], [], [b, a + 1], [])
    assert can_do_meijer([a], [], [b + 2, a], [])
    assert can_do_meijer([a], [], [b - 2, a], [])

    assert hyperexpand(meijerg([a], [], [a, a, a - S(1)/2], [], z)) == \
        -sqrt(pi)*z**(a - S(1)/2)*(2*cos(2*sqrt(z))*(Si(2*sqrt(z)) - pi/2)
                                   - 2*sin(2*sqrt(z))*Ci(2*sqrt(z))) == \
        hyperexpand(meijerg([a], [], [a, a - S(1)/2, a], [], z)) == \
        hyperexpand(meijerg([a], [], [a - S(1)/2, a, a], [], z))
    assert can_do_meijer([a - 1], [], [a + 2, a - S(3)/2, a + 1], [])
开发者ID:vprusso,项目名称:sympy,代码行数:16,代码来源:test_hyperexpand.py

示例15: can_do

def can_do(ap, bq, numerical=True):
    r = hyperexpand(hyper(ap, bq, z))
    if r.has(hyper):
        return False

    if not numerical:
        return True

    repl = {}
    for n, a in enumerate(r.free_symbols - set([z])):
        repl[a] = randcplx(n)
    return tn(hyper(ap, bq, z).subs(repl), r.subs(repl), z)
开发者ID:TeddyBoomer,项目名称:wxgeometrie,代码行数:12,代码来源:test_hyperexpand.py


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