本文整理汇总了Python中sympy.solve_linear函数的典型用法代码示例。如果您正苦于以下问题:Python solve_linear函数的具体用法?Python solve_linear怎么用?Python solve_linear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了solve_linear函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_solve_linear
def test_solve_linear():
x, y = symbols('x y')
w = Wild('w')
assert solve_linear(x, x) == (0, 1)
assert solve_linear(x, y - 2*x) in [(x, y/3), (y, 3*x)]
assert solve_linear(x, y - 2*x, exclude=[x]) ==(y, 3*x)
assert solve_linear(3*x - y, 0) in [(x, y/3), (y, 3*x)]
assert solve_linear(3*x - y, 0, [x]) == (x, y/3)
assert solve_linear(3*x - y, 0, [y]) == (y, 3*x)
assert solve_linear(x**2/y, 1) == (y, x**2)
assert solve_linear(w, x) in [(w, x), (x, w)]
assert solve_linear(cos(x)**2 + sin(x)**2 + 2 + y) == \
(y, -2 - cos(x)**2 - sin(x)**2)
assert solve_linear(cos(x)**2 + sin(x)**2 + 2 + y, x=[x]) == (0, 1)
开发者ID:fxkr,项目名称:sympy,代码行数:14,代码来源:test_solvers.py
示例2: test_issue_2802
def test_issue_2802():
f, g, h = map(Function, "fgh")
a = Symbol("a")
D = Derivative(f(x), x)
G = Derivative(g(a), a)
assert solve(f(x) + f(x).diff(x), f(x)) == [-D]
assert solve(f(x) - 3, f(x)) == [3]
assert solve(f(x) - 3 * f(x).diff(x), f(x)) == [3 * D]
assert solve([f(x) - 3 * f(x).diff(x)], f(x)) == {f(x): 3 * D}
assert solve([f(x) - 3 * f(x).diff(x), f(x) ** 2 - y + 4], f(x), y) == [{f(x): 3 * D, y: 9 * D ** 2 + 4}]
assert solve(-f(a) ** 2 * g(a) ** 2 + f(a) ** 2 * h(a) ** 2 + g(a).diff(a), h(a), g(a)) == [
{g(a): -sqrt(h(a) ** 2 + G / f(a) ** 2)},
{g(a): sqrt(h(a) ** 2 + G / f(a) ** 2)},
]
args = [f(x).diff(x, 2) * (f(x) + g(x)) - g(x) ** 2 + 2, f(x), g(x)]
assert solve(*args) == [(-sqrt(2), sqrt(2)), (sqrt(2), -sqrt(2))]
eqs = [f(x) ** 2 + g(x) - 2 * f(x).diff(x), g(x) ** 2 - 4]
assert solve(eqs, f(x), g(x)) == [
{g(x): 2, f(x): -sqrt(2 * D - 2)},
{g(x): 2, f(x): sqrt(2 * D - 2)},
{g(x): -2, f(x): -sqrt(2 * D + 2)},
{g(x): -2, f(x): sqrt(2 * D + 2)},
]
# the underlying problem was in solve_linear that was not masking off
# anything but a Mul or Add; it now raises an error if it gets anything
# but a symbol and solve handles the substitutions necessary so solve_linear
# won't make this error
raises(ValueError, "solve_linear(f(x) + f(x).diff(x), symbols=[f(x)])")
assert solve_linear(f(x) + f(x).diff(x), symbols=[x]) == (f(x) + Derivative(f(x), x), 1)
assert solve_linear(f(x) + Integral(x, (x, y)), symbols=[x]) == (f(x) + Integral(x, (x, y)), 1)
assert solve_linear(f(x) + Integral(x, (x, y)) + x, symbols=[x]) == (x + f(x) + Integral(x, (x, y)), 1)
assert solve_linear(f(y) + Integral(x, (x, y)) + x, symbols=[x]) == (x, -f(y) - Integral(x, (x, y)))
assert solve_linear(x - f(x) / a + (f(x) - 1) / a, symbols=[x]) == (x, 1 / a)
assert solve_linear(x + Derivative(2 * x, x)) == (x, -2)
assert solve_linear(x + Integral(x, y), symbols=[x]) == (x, 0)
assert solve_linear(x + Integral(x, y) - 2, symbols=[x]) == (x, 2 / (y + 1))
assert solve(x + exp(x) ** 2, exp(x)) == [-sqrt(-x), sqrt(-x)]
assert solve(x + exp(x), x, implicit=True) == [-exp(x)]
assert solve(cos(x) - sin(x), x, implicit=True) == []
assert solve(x - sin(x), x, implicit=True) == [sin(x)]
assert solve(x ** 2 + x - 3, x, implicit=True) == [-x ** 2 + 3]
assert solve(x ** 2 + x - 3, x ** 2, implicit=True) == [-x + 3]
开发者ID:vipulnsward,项目名称:sympy,代码行数:44,代码来源:test_solvers.py
示例3: test_solve_linear
def test_solve_linear():
w = Wild('w')
assert solve_linear(x, x) == (0, 1)
assert solve_linear(x, y - 2*x) in [(x, y/3), (y, 3*x)]
assert solve_linear(x, y - 2*x, exclude=[x]) == (y, 3*x)
assert solve_linear(3*x - y, 0) in [(x, y/3), (y, 3*x)]
assert solve_linear(3*x - y, 0, [x]) == (x, y/3)
assert solve_linear(3*x - y, 0, [y]) == (y, 3*x)
assert solve_linear(x**2/y, 1) == (y, x**2)
assert solve_linear(w, x) in [(w, x), (x, w)]
assert solve_linear(cos(x)**2 + sin(x)**2 + 2 + y) == \
(y, -2 - cos(x)**2 - sin(x)**2)
assert solve_linear(cos(x)**2 + sin(x)**2 + 2 + y, symbols=[x]) == (0, 1)
assert solve_linear(Eq(x, 3)) == (x, 3)
assert solve_linear(1/(1/x - 2)) == (0, 0)
assert solve_linear((x + 1)*exp(-x), symbols=[x]) == (x + 1, exp(x))
assert solve_linear((x + 1)*exp(x), symbols=[x]) == ((x + 1)*exp(x), 1)
assert solve_linear(x*exp(-x**2), symbols=[x]) == (0, 0)
raises(ValueError, lambda: solve_linear(Eq(x, 3), 3))
开发者ID:Maihj,项目名称:sympy,代码行数:19,代码来源:test_solvers.py
示例4: test_solve_linear
def test_solve_linear():
x, y = symbols('x y')
w = Wild('w')
assert solve_linear(x, x) == (0, 1)
assert solve_linear(x, y - 2*x) in [(x, y/3), (y, 3*x)]
assert solve_linear(x, y - 2*x, exclude=[x]) ==(y, 3*x)
assert solve_linear(3*x - y, 0) in [(x, y/3), (y, 3*x)]
assert solve_linear(3*x - y, 0, [x]) == (x, y/3)
assert solve_linear(3*x - y, 0, [y]) == (y, 3*x)
assert solve_linear(x**2/y, 1) == (y, x**2)
assert solve_linear(w, x) in [(w, x), (x, w)]
assert solve_linear(cos(x)**2 + sin(x)**2 + 2 + y) == \
(y, -2 - cos(x)**2 - sin(x)**2)
assert solve_linear(cos(x)**2 + sin(x)**2 + 2 + y, symbols=[x]) == (0, 1)
assert solve_linear(Eq(x, 3)) == (x, 3)
assert solve_linear(1/(1/x - 2)) == (0, 0)
raises(ValueError, 'solve_linear(Eq(x, 3), 3)')
开发者ID:itsrg,项目名称:sympy,代码行数:17,代码来源:test_solvers.py
注:本文中的sympy.solve_linear函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论