本文整理汇总了Python中sympy.Integral.doit方法的典型用法代码示例。如果您正苦于以下问题:Python Integral.doit方法的具体用法?Python Integral.doit怎么用?Python Integral.doit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Integral
的用法示例。
在下文中一共展示了Integral.doit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_issue1566
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_issue1566():
# Allow only upper or lower limit evaluation
e = Integral(x**2, (x, None, 1))
f = Integral(x**2, (x, 1, None))
assert e.doit() == Rational(1, 3)
assert f.doit() == Rational(-1, 3)
assert Integral(x*y, (x, None, y)).subs(y, t) == Integral(x*t, (x, None, t))
assert Integral(x*y, (x, y, None)).subs(y, t) == Integral(x*t, (x, t, None))
示例2: test_doit
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_doit():
e = Integral(Integral(2*x), (x, 0, 1))
assert e.doit() == Rational(1, 3)
assert e.doit(deep=False) == Rational(1, 3)
f = Function('f')
# doesn't matter if the integral can't be performed
assert Integral(f(x), (x, 1, 1)).doit() == 0
# doesn't matter if the limits can't be evaluated
assert Integral(0, (x, 1, Integral(f(x), x))).doit() == 0
示例3: test_doit
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_doit():
a = Integral(x**2, x)
assert isinstance(a.doit(), Integral) == False
assert isinstance(a.doit(integrals=True), Integral) == False
assert isinstance(a.doit(integrals=False), Integral) == True
assert (2*Integral(x, x)).doit() == x**2
示例4: test_issue1566
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_issue1566():
# Allow only upper or lower limit evaluation
e = Integral(x**2, (x, None, 1))
f = Integral(x**2, (x, 1, None))
assert e.doit() == Rational(1, 3)
assert f.doit() == Rational(-1, 3)
assert Integral(x*y, (x, None, y)).subs(y, t) == Integral(x*t, (x, None, t))
assert Integral(x*y, (x, y, None)).subs(y, t) == Integral(x*t, (x, t, None))
#FIXME-py3k: This fails somewhere down the line with:
#FIXME-py3k: TypeError: type Float doesn't define __round__ method
assert integrate(x**2, (x, None, 1)) == Rational(1, 3)
assert integrate(x**2, (x, 1, None)) == Rational(-1, 3)
assert integrate("x**2", ("x", "1", None)) == Rational(-1, 3)
示例5: test_doit_integrals
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_doit_integrals():
e = Integral(Integral(2*x), (x, 0, 1))
assert e.doit() == Rational(1, 3)
assert e.doit(deep=False) == Rational(1, 3)
f = Function('f')
# doesn't matter if the integral can't be performed
assert Integral(f(x), (x, 1, 1)).doit() == 0
# doesn't matter if the limits can't be evaluated
assert Integral(0, (x, 1, Integral(f(x), x))).doit() == 0
assert Integral(x, (a, 0)).doit() == 0
limits = ((a, 1, exp(x)), (x, 0))
assert Integral(a, *limits).doit() == S(1)/4
assert Integral(a, *list(reversed(limits))).doit() == 0
示例6: test_conjugate_transpose
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_conjugate_transpose():
A, B = symbols("A B", commutative=False)
x = Symbol("x", complex=True)
p = Integral(A*B, (x,))
assert p.adjoint().doit() == p.doit().adjoint()
assert p.conjugate().doit() == p.doit().conjugate()
assert p.transpose().doit() == p.doit().transpose()
x = Symbol("x", real=True)
p = Integral(A*B, (x,))
assert p.adjoint().doit() == p.doit().adjoint()
assert p.conjugate().doit() == p.doit().conjugate()
assert p.transpose().doit() == p.doit().transpose()
示例7: main
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def main():
print "Hydrogen radial wavefunctions:"
a, r = symbols("a r")
print "R_{21}:"
pprint(R_nl(2, 1, a, r))
print "R_{60}:"
pprint(R_nl(6, 0, a, r))
print "Normalization:"
i = Integral(R_nl(1, 0, 1, r)**2 * r**2, (r, 0, oo))
pprint(Eq(i, i.doit()))
i = Integral(R_nl(2, 0, 1, r)**2 * r**2, (r, 0, oo))
pprint(Eq(i, i.doit()))
i = Integral(R_nl(2, 1, 1, r)**2 * r**2, (r, 0, oo))
pprint(Eq(i, i.doit()))
示例8: main
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def main():
print "Hydrogen radial wavefunctions:"
var("r a")
print "R_{21}:"
pprint(R_nl(2, 1, a, r))
print "R_{60}:"
pprint(R_nl(6, 0, a, r))
print "Normalization:"
i = Integral(R_nl(1, 0, 1, r)**2 * r**2, (r, 0, oo))
print pretty(i), " = ", i.doit()
i = Integral(R_nl(2, 0, 1, r)**2 * r**2, (r, 0, oo))
print pretty(i), " = ", i.doit()
i = Integral(R_nl(2, 1, 1, r)**2 * r**2, (r, 0, oo))
print pretty(i), " = ", i.doit()
示例9: test_transform
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_transform():
a = Integral(x**2 + 1, (x, -1, 2))
fx = x
fy = 3*y + 1
assert a.doit() == a.transform(fx, fy).doit()
assert a.transform(fx, fy).transform(fy, fx) == a
fx = 3*x + 1
fy = y
assert a.transform(fx, fy).transform(fy, fx) == a
a = Integral(sin(1/x), (x, 0, 1))
assert a.transform(x, 1/y) == Integral(sin(y)/y**2, (y, 1, oo))
assert a.transform(x, 1/y).transform(y, 1/x) == a
a = Integral(exp(-x**2), (x, -oo, oo))
assert a.transform(x, 2*y) == Integral(2*exp(-4*y**2), (y, -oo, oo))
# < 3 arg limit handled properly
assert Integral(x, x).transform(x, a*y).doit() == \
Integral(y*a**2, y).doit()
_3 = S(3)
assert Integral(x, (x, 0, -_3)).transform(x, 1/y).doit() == \
Integral(-1/x**3, (x, -oo, -1/_3)).doit()
assert Integral(x, (x, 0, _3)).transform(x, 1/y) == \
Integral(y**(-3), (y, 1/_3, oo))
# issue 8400
i = Integral(x + y, (x, 1, 2), (y, 1, 2))
assert i.transform(x, (x + 2*y, x)).doit() == \
i.transform(x, (x + 2*z, x)).doit() == 3
示例10: test_is_zero
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_is_zero():
from sympy.abc import x, m, n
assert Integral(0, (x, 1, x)).is_zero
assert Integral(1, (x, 1, 1)).is_zero
assert Integral(1, (x, 1, 2)).is_zero is False
assert Integral(sin(m*x)*cos(n*x), (x, 0, 2*pi)).is_zero is None
assert Integral(x, (m, 0)).is_zero
assert Integral(x + 1/m, (m, 0)).is_zero is None
i = Integral(m, (m, 1, exp(x)), (x, 0))
assert i.is_zero is None and i.doit() == S(1)/4
assert Integral(m, (x, 0), (m, 1, exp(x))).is_zero is True
示例11: test_transform
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_transform():
a = Integral(x**2+1, (x, -1, 2))
assert a.doit() == a.transform(x, 3*x+1).doit()
assert a.transform(x, 3*x+1).transform(x, 3*x+1, inverse=True) == a
assert a.transform(x, 3*x+1, inverse=True).transform(x, 3*x+1) == a
a = Integral(sin(1/x), (x, 0, 1))
assert a.transform(x, 1/x) == Integral(sin(x)/x**2, (x, 1, oo))
assert a.transform(x, 1/x).transform(x, 1/x) == a
a = Integral(exp(-x**2), (x, -oo, oo))
assert a.transform(x, 2*x) == Integral(2*exp(-4*x**2), (x, -oo, oo))
raises(ValueError, "a.transform(x, 1/x)")
raises(ValueError, "a.transform(x, 1/x)")
示例12: test_transform
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_transform():
a = Integral(x ** 2 + 1, (x, -1, 2))
assert a.doit() == a.transform(x, 3 * x + 1).doit()
assert a.transform(x, 3 * x + 1).transform(x, 3 * x + 1, inverse=True) == a
assert a.transform(x, 3 * x + 1, inverse=True).transform(x, 3 * x + 1) == a
a = Integral(sin(1 / x), (x, 0, 1))
assert a.transform(x, 1 / x) == Integral(sin(x) / x ** 2, (x, 1, oo))
assert a.transform(x, 1 / x).transform(x, 1 / x) == a
a = Integral(exp(-x ** 2), (x, -oo, oo))
assert a.transform(x, 2 * x) == Integral(2 * exp(-4 * x ** 2), (x, -oo, oo))
# < 3 arg limit handled properly
assert Integral(x, x).transform(x, a * x) == Integral(x * a ** 2, x)
raises(ValueError, "a.transform(x, 1/x)")
raises(ValueError, "a.transform(x, 1/x)")
_3 = S(3)
assert Integral(x, (x, 0, -_3)).transform(x, 1 / x) == Integral(-1 / x ** 3, (x, -oo, -1 / _3))
assert Integral(x, (x, 0, _3)).transform(x, 1 / x) == Integral(x ** (-3), (x, 1 / _3, oo))
示例13: test_doit2
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_doit2():
e = Integral(Integral(2*x), (x, 0, 1))
# risch currently chokes on the contained integral.
assert e.doit(deep = False) == e
示例14: test_nested_doit
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
def test_nested_doit():
e = Integral(Integral(x, x), x)
f = Integral(x, x, x)
assert e.doit() == f.doit()
示例15: var
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import doit [as 别名]
#!/usr/bin/env python
"""
This example shows how to work with the Hydrogen radial wavefunctions.
"""
from sympy import var, pprint, Integral, oo, Eq
from sympy.physics.hydrogen import R_nl
print "Hydrogen radial wavefunctions:"
var("r a")
print "R_{21}:"
pprint(R_nl(2, 1, a, r))
print "R_{60}:"
pprint(R_nl(6, 0, a, r))
print "Normalization:"
i = Integral(R_nl(1, 0, 1, r)**2 * r**2, (r, 0, oo))
pprint(Eq(i, i.doit()))
i = Integral(R_nl(2, 0, 1, r)**2 * r**2, (r, 0, oo))
pprint(Eq(i, i.doit()))
i = Integral(R_nl(2, 1, 1, r)**2 * r**2, (r, 0, oo))
pprint(Eq(i, i.doit()))