本文整理汇总了Python中sympy.solvers.solvers.checksol函数的典型用法代码示例。如果您正苦于以下问题:Python checksol函数的具体用法?Python checksol怎么用?Python checksol使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checksol函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_is_constant
def test_is_constant():
from sympy.solvers.solvers import checksol
Sum(x, (x, 1, 10)).is_constant() == True
Sum(x, (x, 1, n)).is_constant() == False
Sum(x, (x, 1, n)).is_constant(y) == True
Sum(x, (x, 1, n)).is_constant(n) == False
Sum(x, (x, 1, n)).is_constant(x) == True
eq = a * cos(x) ** 2 + a * sin(x) ** 2 - a
eq.is_constant() == True
assert eq.subs({x: pi, a: 2}) == eq.subs({x: pi, a: 3}) == 0
assert x.is_constant() is False
assert x.is_constant(y) is True
assert checksol(x, x, Sum(x, (x, 1, n))) == False
assert checksol(x, x, Sum(x, (x, 1, n))) == False
f = Function("f")
assert checksol(x, x, f(x)) == False
p = symbols("p", positive=True)
assert Pow(x, S(0), evaluate=False).is_constant() == True # == 1
assert Pow(S(0), x, evaluate=False).is_constant() == False # == 0 or 1
assert Pow(S(0), p, evaluate=False).is_constant() == True # == 1
assert (2 ** x).is_constant() == False
assert Pow(S(2), S(3), evaluate=False).is_constant() == True
z1, z2 = symbols("z1 z2", zero=True)
assert (z1 + 2 * z2).is_constant() is True
assert meter.is_constant() is True
assert (3 * meter).is_constant() is True
assert (x * meter).is_constant() is False
开发者ID:Botouls,项目名称:sympy,代码行数:32,代码来源:test_expr.py
示例2: __eval_cond
def __eval_cond(cls, cond):
"""Return the truth value of the condition."""
from sympy.solvers.solvers import checksol
if cond is True:
return True
if isinstance(cond, Equality):
if checksol(cond, {}, minimal=True):
# the equality is trivially solved
return True
return None
开发者ID:Maihj,项目名称:sympy,代码行数:11,代码来源:piecewise.py
示例3: __eval_cond
def __eval_cond(cls, cond):
"""Return the truth value of the condition."""
from sympy.solvers.solvers import checksol
if cond == True:
return True
if isinstance(cond, Equality):
if checksol(cond, {}, minimal=True):
# the equality is trivially solved
return True
diff = cond.lhs - cond.rhs
if diff.is_commutative:
return diff.is_zero
return None
开发者ID:B-Rich,项目名称:sympy,代码行数:13,代码来源:piecewise.py
示例4: _solve_radical
def _solve_radical(f, symbol, solveset_solver):
""" Helper function to solve equations with radicals """
eq, cov = unrad(f)
if not cov:
result = solveset_solver(eq, symbol) - Union(*[solveset_solver(g, symbol) for g in denoms(f, [symbol])])
else:
y, yeq = cov
if not solveset_solver(y - I, y):
yreal = Dummy("yreal", real=True)
yeq = yeq.xreplace({y: yreal})
eq = eq.xreplace({y: yreal})
y = yreal
g_y_s = solveset_solver(yeq, symbol)
f_y_sols = solveset_solver(eq, y)
result = Union(*[imageset(Lambda(y, g_y), f_y_sols) for g_y in g_y_s])
return FiniteSet(*[s for s in result if checksol(f, symbol, s) is True])
开发者ID:Carreau,项目名称:sympy,代码行数:17,代码来源:solveset.py
示例5: _solve_radical
def _solve_radical(f, symbol, solveset_solver):
""" Helper function to solve equations with radicals """
from sympy.solvers.solvers import unrad
try:
eq, cov, dens = unrad(f)
if cov == []:
result = solveset_solver(eq, symbol) - \
Union(*[solveset_solver(g, symbol) for g in dens])
else:
if len(cov) > 1:
raise NotImplementedError("Multivariate solver is "
"not implemented.")
else:
y = cov[0][0]
g_y_s = solveset_solver(cov[0][1], symbol)
f_y_sols = solveset_solver(eq, y)
result = Union(*[imageset(Lambda(y, g_y), f_y_sols)
for g_y in g_y_s])
return FiniteSet(*[s for s in result if checksol(f, symbol, s) is True])
except ValueError:
raise NotImplementedError
开发者ID:AdrianPotter,项目名称:sympy,代码行数:22,代码来源:solveset.py
示例6: test_issue_2574
def test_issue_2574():
eq = -x + exp(exp(LambertW(log(x)))*LambertW(log(x)))
assert checksol(eq, x, 2) is True
assert checksol(eq, x, 2, numerical=False) is None
开发者ID:Maihj,项目名称:sympy,代码行数:4,代码来源:test_solvers.py
注:本文中的sympy.solvers.solvers.checksol函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论