本文整理汇总了Python中sympy.Integral.subs方法的典型用法代码示例。如果您正苦于以下问题:Python Integral.subs方法的具体用法?Python Integral.subs怎么用?Python Integral.subs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Integral
的用法示例。
在下文中一共展示了Integral.subs方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subs2
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import subs [as 别名]
def test_subs2():
e = Integral(exp(x - y), x, t)
assert e.subs(y, 3) == Integral(exp(x - 3), x, t)
e = Integral(exp(x - y), (x, 0, 1), (t, 0, 1))
assert e.subs(y, 3) == Integral(exp(x - 3), (x, 0, 1), (t, 0, 1))
f = Lambda(x, exp(-x**2))
conv = Integral(f(x - y)*f(y), (y, -oo, oo), (t, 0, 1))
assert conv.subs({x: 0}) == Integral(exp(-2*y**2), (y, -oo, oo), (t, 0, 1))
示例2: test_subs7
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import subs [as 别名]
def test_subs7():
e = Integral(x, (x, 1, y), (y, 1, 2))
assert e.subs({x: 1, y: 2}) == e
e = Integral(sin(x) + sin(y), (x, sin(x), sin(y)),
(y, 1, 2))
assert e.subs(sin(y), 1) == e
assert e.subs(sin(x), 1) == Integral(sin(x) + sin(y), (x, 1, sin(y)),
(y, 1, 2))
示例3: test_subs6
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import subs [as 别名]
def test_subs6():
a, b = symbols('a b')
e = Integral(x*y, (x, f(x), f(y)))
assert e.subs(x, 1) == Integral(x*y, (x, f(1), f(y)))
assert e.subs(y, 1) == Integral(x, (x, f(x), f(1)))
e = Integral(x*y, (x, f(x), f(y)), (y, f(x), f(y)))
assert e.subs(x, 1) == Integral(x*y, (x, f(1), f(y)), (y, f(1), f(y)))
assert e.subs(y, 1) == Integral(x*y, (x, f(x), f(y)), (y, f(x), f(1)))
e = Integral(x*y, (x, f(x), f(a)), (y, f(x), f(a)))
assert e.subs(a, 1) == Integral(x*y, (x, f(x), f(1)), (y, f(x), f(1)))
示例4: test_subs5
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import subs [as 别名]
def test_subs5():
e = Integral(exp(-x**2), x)
assert e.subs(x, 5) == Integral(exp(-x**2), (x, 5))
e = Integral(exp(-x**2), (x, -oo, oo))
assert e.subs(x, 5) == e
e = Integral(exp(-x**2+y), x)
assert e.subs(x, 5) == Integral(exp(y - x**2), (x, 5))
assert e.subs(y, 5) == Integral(exp(-x**2+5), x)
e = Integral(exp(-x**2+y), (y, -oo, oo), (x, -oo, oo))
assert e.subs(x, 5) == e
assert e.subs(y, 5) == e
示例5: test_get_motion_methods
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import subs [as 别名]
def test_get_motion_methods():
# Initialization
t = dynamicsymbols._t
s1, s2, s3 = symbols("s1 s2 s3")
S1, S2, S3 = symbols("S1 S2 S3")
S4, S5, S6 = symbols("S4 S5 S6")
t1, t2 = symbols("t1 t2")
a, b, c = dynamicsymbols("a b c")
ad, bd, cd = dynamicsymbols("a b c", 1)
a2d, b2d, c2d = dynamicsymbols("a b c", 2)
v0 = S1 * N.x + S2 * N.y + S3 * N.z
v01 = S4 * N.x + S5 * N.y + S6 * N.z
v1 = s1 * N.x + s2 * N.y + s3 * N.z
v2 = a * N.x + b * N.y + c * N.z
v2d = ad * N.x + bd * N.y + cd * N.z
v2dd = a2d * N.x + b2d * N.y + c2d * N.z
# Test position parameter
assert get_motion_params(frame=N) == (0, 0, 0)
assert get_motion_params(N, position=v1) == (0, 0, v1)
assert get_motion_params(N, position=v2) == (v2dd, v2d, v2)
# Test velocity parameter
assert get_motion_params(N, velocity=v1) == (0, v1, v1 * t)
assert get_motion_params(N, velocity=v1, position=v0, timevalue1=t1) == (0, v1, v0 + v1 * (t - t1))
assert get_motion_params(N, velocity=v1, position=v2, timevalue1=t1) == (0, v1, v1 * t - v1 * t1 + v2.subs(t, t1))
integral_vector = Integral(a, t) * N.x + Integral(b, t) * N.y + Integral(c, t) * N.z
assert get_motion_params(N, velocity=v2, position=v0, timevalue1=t1) == (
v2d,
v2,
v0 + integral_vector - integral_vector.subs(t, t1),
)
# Test acceleration parameter
assert get_motion_params(N, acceleration=v1) == (v1, v1 * t, v1 * t ** 2 / 2)
assert get_motion_params(N, acceleration=v1, velocity=v0, position=v2, timevalue1=t1, timevalue2=t2) == (
v1,
(v0 + v1 * t - v1 * t2),
-v0 * t1 + v1 * t ** 2 / 2 + v1 * t2 * t1 - v1 * t1 ** 2 / 2 + t * (v0 - v1 * t2) + v2.subs(t, t1),
)
assert get_motion_params(N, acceleration=v1, velocity=v0, position=v01, timevalue1=t1, timevalue2=t2) == (
v1,
v0 + v1 * t - v1 * t2,
-v0 * t1 + v01 + v1 * t ** 2 / 2 + v1 * t2 * t1 - v1 * t1 ** 2 / 2 + t * (v0 - v1 * t2),
)
i = Integral(a, t)
i_sub = i.subs(t, t2)
assert get_motion_params(
N, acceleration=a * N.x, velocity=S1 * N.x, position=S2 * N.x, timevalue1=t1, timevalue2=t2
) == (
a * N.x,
(S1 + i - i_sub) * N.x,
(S2 + Integral(S1 - t * (a.subs(t, t2)) + i, t) - Integral(S1 - t1 * (a.subs(t, t2)) + i.subs(t, t1), t)) * N.x,
)
示例6: test_subs5
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import subs [as 别名]
def test_subs5():
e = Integral(exp(-x**2), (x, -oo, oo))
assert e.subs(x, 5) == e
e = Integral(exp(-x**2 + y), x)
assert e.subs(y, 5) == Integral(exp(-x**2 + 5), x)
e = Integral(exp(-x**2 + y), (x, x))
assert e.subs(x, 5) == Integral(exp(y - x**2), (x, 5))
assert e.subs(y, 5) == Integral(exp(-x**2 + 5), x)
e = Integral(exp(-x**2 + y), (y, -oo, oo), (x, -oo, oo))
assert e.subs(x, 5) == e
assert e.subs(y, 5) == e
# Test evaluation of antiderivatives
e = Integral(exp(-x**2), (x, x))
assert e.subs(x, 5) == Integral(exp(-x**2), (x, 5))
e = Integral(exp(x), x)
assert (e.subs(x,1)-e.subs(x,0) - Integral(exp(x),(x,0,1))).doit().is_zero
示例7: test_subs4
# 需要导入模块: from sympy import Integral [as 别名]
# 或者: from sympy.Integral import subs [as 别名]
def test_subs4():
e = Integral(exp(x), (x, 0, y), (t, y, 1))
assert e.subs(y, 3) == Integral(exp(x), (x, 0, 3), (t, 3, 1))
f = Lambda(x, exp(-x**2))
conv = Integral(f(y)*f(y), (y, -oo, oo), (t, x, 1))
assert conv.subs({x: 0}) == Integral(exp(-2*y**2), (y, -oo, oo), (t, 0, 1))