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


Python Integral.n方法代码示例

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


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

示例1: test_is_number

# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import n [as 别名]
def test_is_number():
    from sympy.abc import x, y, z
    from sympy import cos, sin
    assert Integral(x).is_number is False
    assert Integral(1, x).is_number is False
    assert Integral(1, (x, 1)).is_number is True
    assert Integral(1, (x, 1, 2)).is_number is True
    assert Integral(1, (x, 1, y)).is_number is False
    assert Integral(1, (x, y)).is_number is False
    assert Integral(x, y).is_number is False
    assert Integral(x, (y, 1, x)).is_number is False
    assert Integral(x, (y, 1, 2)).is_number is False
    assert Integral(x, (x, 1, 2)).is_number is True
    # `foo.is_number` should always be eqivalent to `not foo.free_symbols`
    # in each of these cases, there are pseudo-free symbols
    i = Integral(x, (y, 1, 1))
    assert i.is_number is False and i.n() == 0
    i = Integral(x, (y, z, z))
    assert i.is_number is False and i.n() == 0
    i = Integral(1, (y, z, z + 2))
    assert i.is_number is False and i.n() == 2

    assert Integral(x*y, (x, 1, 2), (y, 1, 3)).is_number is True
    assert Integral(x*y, (x, 1, 2), (y, 1, z)).is_number is False
    assert Integral(x, (x, 1)).is_number is True
    assert Integral(x, (x, 1, Integral(y, (y, 1, 2)))).is_number is True
    assert Integral(Sum(z, (z, 1, 2)), (x, 1, 2)).is_number is True
    # it is possible to get a false negative if the integrand is
    # actually an unsimplified zero, but this is true of is_number in general.
    assert Integral(sin(x)**2 + cos(x)**2 - 1, x).is_number is False
    assert Integral(f(x), (x, 0, 1)).is_number is True
开发者ID:baoqchau,项目名称:sympy,代码行数:33,代码来源:test_integrals.py

示例2: test_is_number

# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import n [as 别名]
def test_is_number():
    from sympy.abc import x, y, z
    from sympy import cos, sin
    assert Integral(x).is_number is False
    assert Integral(1, x).is_number is False
    assert Integral(1, (x, 1)).is_number is True
    assert Integral(1, (x, 1, 2)).is_number is True
    assert Integral(1, (x, 1, y)).is_number is False
    assert Integral(1, (x, y)).is_number is False
    assert Integral(x, y).is_number is False
    assert Integral(x, (y, 1, x)).is_number is False
    assert Integral(x, (y, 1, 2)).is_number is False
    assert Integral(x, (x, 1, 2)).is_number is True
    i = Integral(x, (y, 1, 1))
    assert i.is_number is True and i.n() == 0
    i = Integral(x, (y, z, z))
    assert i.is_number is True and i.n() == 0
    i = Integral(1, (y, z, z + 2))
    assert i.is_number is True and i.n() == 2
    assert Integral(x*y, (x, 1, 2), (y, 1, 3)).is_number is True
    assert Integral(x*y, (x, 1, 2), (y, 1, z)).is_number is False
    assert Integral(x, (x, 1)).is_number is True
    assert Integral(x, (x, 1, Integral(y, (y, 1, 2)))).is_number is True
    assert Integral(Sum(z, (z, 1, 2)), (x, 1, 2)).is_number is True
    # it is possible to get a false negative if the integrand is
    # actually an unsimplified zero, but this is true of is_number in general.
    assert Integral(sin(x)**2 + cos(x)**2 - 1, x).is_number is False
    assert Integral(f(x), (x, 0, 1)).is_number is True
开发者ID:KsenijaM,项目名称:sympy,代码行数:30,代码来源:test_integrals.py

示例3: test_literal_evalf_is_number_is_zero_is_comparable

# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import n [as 别名]
def test_literal_evalf_is_number_is_zero_is_comparable():
    from sympy.integrals.integrals import Integral
    from sympy.core.symbol import symbols
    from sympy.core.function import Function
    from sympy.functions.elementary.trigonometric import cos, sin
    x = symbols('x')
    f = Function('f')

    # issue 5033
    assert f.is_number is False
    # issue 6646
    assert f(1).is_number is False
    i = Integral(0, (x, x, x))
    # expressions that are symbolically 0 can be difficult to prove
    # so in case there is some easy way to know if something is 0
    # it should appear in the is_zero property for that object;
    # if is_zero is true evalf should always be able to compute that
    # zero
    assert i.n() == 0
    assert i.is_zero
    assert i.is_number is False
    assert i.evalf(2, strict=False) == 0

    # issue 10268
    n = sin(1)**2 + cos(1)**2 - 1
    assert n.is_comparable is False
    assert n.n(2).is_comparable is False
    assert n.n(2).n(2).is_comparable
开发者ID:gamechanger98,项目名称:sympy,代码行数:30,代码来源:test_basic.py

示例4: test_as_sum_midpoint1

# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import n [as 别名]
def test_as_sum_midpoint1():
    e = Integral(sqrt(x ** 3 + 1), (x, 2, 10))
    assert e.as_sum(1, method="midpoint") == 8 * sqrt(217)
    assert e.as_sum(2, method="midpoint") == 4 * sqrt(65) + 12 * sqrt(57)
    assert e.as_sum(3, method="midpoint") == 8 * sqrt(217) / 3 + 8 * sqrt(3081) / 27 + 8 * sqrt(52809) / 27
    assert e.as_sum(4, method="midpoint") == 2 * sqrt(730) + 4 * sqrt(7) + 4 * sqrt(86) + 6 * sqrt(14)
    assert abs(e.as_sum(4, method="midpoint").n() - e.n()) < 0.5

    e = Integral(sqrt(x ** 3 + y ** 3), (x, 2, 10), (y, 0, 10))
    raises(NotImplementedError, "e.as_sum(4)")
开发者ID:arunenigma,项目名称:sympy,代码行数:12,代码来源:test_integrals.py

示例5: test_as_sum_midpoint1

# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import n [as 别名]
def test_as_sum_midpoint1():
    e = Integral(sqrt(x**3+1), (x, 2, 10))
    assert e.as_sum(1, method="midpoint") == 8*217**(S(1)/2)
    assert e.as_sum(2, method="midpoint") == 4*65**(S(1)/2) + 12*57**(S(1)/2)
    assert e.as_sum(3, method="midpoint") == 8*217**(S(1)/2)/3 + \
            8*3081**(S(1)/2)/27 + 8*52809**(S(1)/2)/27
    assert e.as_sum(4, method="midpoint") == 2*730**(S(1)/2) + \
            4*7**(S(1)/2) + 4*86**(S(1)/2) + 6*14**(S(1)/2)
    assert abs(e.as_sum(4, method="midpoint").n() - e.n()) < 0.5

    e = Integral(sqrt(x**3+y**3), (x, 2, 10), (y, 0, 10))
    raises(NotImplementedError, "e.as_sum(4)")
开发者ID:wxgeo,项目名称:sympy,代码行数:14,代码来源:test_integrals.py


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