Esempio n. 1
0
def test_issue_10681():
    from sympy import RR
    from sympy.abc import R, r
    f = integrate(r**2*(R**2-r**2)**0.5, r, meijerg=True)
    g = (1.0/3)*R**1.0*r**3*hyper((-0.5, S(3)/2), (S(5)/2,),
                                  r**2*exp_polar(2*I*pi)/R**2)
    assert RR.almosteq((f/g).n(), 1.0, 1e-12)
Esempio n. 2
0
def test_extended_domain_in_expr_to_holonomic():
    x = symbols('x')
    p = expr_to_holonomic(1.2*cos(3.1*x))
    assert p.to_expr() == 1.2*cos(3.1*x)
    assert sstr(p.integrate(x).to_expr()) == '0.387096774193548*sin(3.1*x)'
    _, Dx = DifferentialOperators(RR.old_poly_ring(x), 'Dx')
    p = expr_to_holonomic(1.1329138213*x)
    q = HolonomicFunction((-1.1329138213) + (1.1329138213*x)*Dx, x, 0, {1: [1.1329138213]})
    assert p == q
    assert p.to_expr() == 1.1329138213*x
    assert sstr(p.integrate((x, 1, 2))) == sstr((1.1329138213*x).integrate((x, 1, 2)))
    y, z = symbols('y, z')
    p = expr_to_holonomic(sin(x*y*z), x=x)
    assert p.to_expr() == sin(x*y*z)
    assert p.integrate(x).to_expr() == (-cos(x*y*z) + 1)/(y*z)
    p = expr_to_holonomic(sin(x*y + z), x=x).integrate(x).to_expr()
    q = (cos(z) - cos(x*y + z))/y
    assert p == q
    a = symbols('a')
    p = expr_to_holonomic(a*x, x)
    assert p.to_expr() == a*x
    assert p.integrate(x).to_expr() == a*x**2/2
    D_2, C_1 = symbols("D_2, C_1")
    p = expr_to_holonomic(x) + expr_to_holonomic(1.2*cos(x))
    p = p.to_expr().subs(D_2, 0)
    assert p - x - 1.2*cos(1.0*x) == 0
    p = expr_to_holonomic(x) * expr_to_holonomic(1.2*cos(x))
    p = p.to_expr().subs(C_1, 0)
    assert p - 1.2*x*cos(1.0*x) == 0
Esempio n. 3
0
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)
Esempio n. 4
0
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)
Esempio n. 5
0
def test_issue_10681():
    from sympy import RR
    from sympy.abc import R, r
    f = integrate(r**2 * (R**2 - r**2)**0.5, r, meijerg=True)
    g = (1.0 / 3) * R**1.0 * r**3 * hyper(
        (-0.5, Rational(3, 2)),
        (Rational(5, 2), ), r**2 * exp_polar(2 * I * pi) / R**2)
    assert RR.almosteq((f / g).n(), 1.0, 1e-12)
Esempio n. 6
0
def test_meijerg_with_Floats():
    # see issue #10681
    from sympy import RR

    f = meijerg(((3.0, 1), ()), ((Rational(3, 2), ), (0, )), z)
    a = -2.3632718012073
    g = (a * z**Rational(3, 2) * hyper(
        (-0.5, Rational(3, 2)), (Rational(5, 2), ), z * exp_polar(I * pi)))
    assert RR.almosteq((hyperexpand(f) / g).n(), 1.0, 1e-12)
Esempio n. 7
0
def test_extended_domain_in_expr_to_holonomic():
    x = symbols('x')
    p = expr_to_holonomic(1.2*cos(3.1*x), domain=RR)
    assert p.to_expr() == 1.2*cos(3.1*x)
    assert sstr(p.integrate(x).to_expr()) == '0.387096774193548*sin(3.1*x)'
    _, Dx = DifferentialOperators(RR.old_poly_ring(x), 'Dx')
    p = expr_to_holonomic(1.1329138213*x, domain=RR, lenics=2)
    q = HolonomicFunction((-1.1329138213) + (1.1329138213*x)*Dx, x, 0, [0, 1.1329138213])
    assert p == q
    assert p.to_expr() == 1.1329138213*x
    assert sstr(p.integrate((x, 1, 2))) == sstr((1.1329138213*x).integrate((x, 1, 2)))
    y, z = symbols('y, z')
    p = expr_to_holonomic(sin(x*y*z), x=x, domain=ZZ[y, z])
    assert p.to_expr() == sin(x*y*z)
    assert p.integrate(x).to_expr() == (-cos(x*y*z) + 1)/(y*z)
    p = expr_to_holonomic(sin(x*y + z), x=x, domain=ZZ[y, z]).integrate(x).to_expr()
    q = (cos(z) - cos(x*y + z))/y
    assert p == q
Esempio n. 8
0
def test_extended_domain_in_expr_to_holonomic():
    x = symbols('x')
    p = expr_to_holonomic(1.2 * cos(3.1 * x), domain=RR)
    assert p.to_expr() == 1.2 * cos(3.1 * x)
    assert sstr(p.integrate(x).to_expr()) == '0.387096774193548*sin(3.1*x)'
    _, Dx = DifferentialOperators(RR.old_poly_ring(x), 'Dx')
    p = expr_to_holonomic(1.1329138213 * x, domain=RR, lenics=2)
    q = HolonomicFunction((-1.1329138213) + (1.1329138213 * x) * Dx, x, 0,
                          [0, 1.1329138213])
    assert p == q
    assert p.to_expr() == 1.1329138213 * x
    assert sstr(p.integrate((x, 1, 2))) == sstr((1.1329138213 * x).integrate(
        (x, 1, 2)))
    y, z = symbols('y, z')
    p = expr_to_holonomic(sin(x * y * z), x=x, domain=ZZ[y, z])
    assert p.to_expr() == sin(x * y * z)
    assert p.integrate(x).to_expr() == (-cos(x * y * z) + 1) / (y * z)
    p = expr_to_holonomic(sin(x * y + z), x=x,
                          domain=ZZ[y, z]).integrate(x).to_expr()
    q = (cos(z) - cos(x * y + z)) / y
    assert p == q