本文整理汇总了Python中sympy.abc.x.subs函数的典型用法代码示例。如果您正苦于以下问题:Python subs函数的具体用法?Python subs怎么用?Python subs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subs函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_issue_6976
def test_issue_6976():
x, y = symbols('x y')
assert (sqrt(x)**3 + sqrt(x) + x + x**2).subs(sqrt(x), y) == \
y**4 + y**3 + y**2 + y
assert (x**4 + x**3 + x**2 + x + sqrt(x)).subs(x**2, y) == \
sqrt(x) + x**3 + x + y**2 + y
assert x.subs(x**3, y) == x
assert x.subs(x**(S(1)/3), y) == y**3
# More substitutions are possible with nonnegative symbols
x, y = symbols('x y', nonnegative=True)
assert (x**4 + x**3 + x**2 + x + sqrt(x)).subs(x**2, y) == \
y**(S(1)/4) + y**(S(3)/2) + sqrt(y) + y**2 + y
assert x.subs(x**3, y) == y**(S(1)/3)
开发者ID:asmeurer,项目名称:sympy,代码行数:14,代码来源:test_subs.py
示例2: test_issue_8886
def test_issue_8886():
from sympy.physics.mechanics import ReferenceFrame as R
# if something can't be sympified we assume that it
# doesn't play well with SymPy and disallow the
# substitution
v = R('A').x
assert x.subs(x, v) == x
assert v.subs(v, x) == v
assert v.__eq__(x) is False
开发者ID:Lenqth,项目名称:sympy,代码行数:9,代码来源:test_subs.py
示例3: test_dict_set
def test_dict_set():
a, b, c = map(Wild, 'abc')
f = 3*cos(4*x)
r = f.match(a*cos(b*x))
assert r == {a: 3, b: 4}
e = a/b*sin(b*x)
assert e.subs(r) == r[a]/r[b]*sin(r[b]*x)
assert e.subs(r) == 3*sin(4*x) / 4
s = set(r.items())
assert e.subs(s) == r[a]/r[b]*sin(r[b]*x)
assert e.subs(s) == 3*sin(4*x) / 4
assert e.subs(r) == r[a]/r[b]*sin(r[b]*x)
assert e.subs(r) == 3*sin(4*x) / 4
assert x.subs(Dict((x, 1))) == 1
开发者ID:KsenijaM,项目名称:sympy,代码行数:16,代码来源:test_subs.py
示例4: test_subs_iter
def test_subs_iter():
assert x.subs(reversed([[x, y]])) == y
it = iter([[x, y]])
assert x.subs(it) == y
assert x.subs(Tuple((x, y))) == y
开发者ID:KsenijaM,项目名称:sympy,代码行数:5,代码来源:test_subs.py
注:本文中的sympy.abc.x.subs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论