本文整理汇总了Python中sympy.solvers.solve_undetermined_coeffs函数的典型用法代码示例。如果您正苦于以下问题:Python solve_undetermined_coeffs函数的具体用法?Python solve_undetermined_coeffs怎么用?Python solve_undetermined_coeffs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了solve_undetermined_coeffs函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_solve_undetermined_coeffs
def test_solve_undetermined_coeffs():
assert solve_undetermined_coeffs(a*x**2 + b*x**2 + b*x + 2*c*x + c + 1, [a, b, c], x) == \
{a: -2, b: 2, c: -1}
# Test that rational functions work
assert solve_undetermined_coeffs(a/x + b/(x + 1) - (2*x + 1)/(x**2 + x), [a, b], x) == \
{a: 1, b: 1}
# Test cancellation in rational functions
assert solve_undetermined_coeffs(((c + 1)*a*x**2 + (c + 1)*b*x**2 +
(c + 1)*b*x + (c + 1)*2*c*x + (c + 1)**2)/(c + 1), [a, b, c], x) == \
{a: -2, b: 2, c: -1}
开发者ID:Maihj,项目名称:sympy,代码行数:10,代码来源:test_solvers.py
示例2: synthesize
def synthesize(polynomial, filter_implementation, filter_type, parameters):
""" Implements the filter given by polynomial,
with the filter_implementation and filter_type given.
Assumptions:
- Low-pass and high-pass filters set the resistor
and find the capacitor.
- Sallen-key LP filter sets R1 = R2 = Rr and C1 and C2 can vary.
- Sallen-key HP filter sets C1 = C2 = Cc and R1 and R2 can vary.
- MFB LP filter sets C1 = C2 = Cc and R1, R2, R3 can vary.
- MFB HP filter sets R1 = R2 = R3 = Rr and C1, C2 can vary.
"""
s = sym.var('s')
if filter_implementation == '1' and filter_type == 'lp':
C = sym.var('C')
targets = [C]
R = parameters['R']
tf = rc_lowpass(s, R, C)
if filter_implementation == '1' and filter_type == 'hp':
C = sym.var('C')
targets = [C]
R = parameters['R']
tf = rc_highpass(s, R, C)
if filter_implementation == 'sk' and filter_type == 'lp':
C1, C2, s = sym.var('C1 C2 s')
targets = [C1, C2] # The values we want to find
Rr = parameters['Rr']
tf = sk_lowpass(s, Rr, Rr, C1, C2)
if filter_implementation == 'sk' and filter_type == 'hp':
R1, R2, s = sym.var('R1 R2 s')
targets = [R1, R2] # The values we want to find
Cc = parameters['Cc']
tf = sk_highpass(s, R1, R2, Cc, Cc)
print(tf)
print("I need to solve ", tf-polynomial)
print("My variables are ", targets)
result = solvers.solve_undetermined_coeffs(tf - polynomial, targets, 's')
return result
开发者ID:Python-Devs-Brasil,项目名称:pyfilter,代码行数:42,代码来源:synthesis.py
示例3: rsolve_poly
#.........这里部分代码省略.........
if nni_roots:
N = [max(nni_roots)]
else:
N = []
if homogeneous:
N += [-b-1]
else:
N += [f.as_poly(n).degree() - b, -b-1]
N = int(max(N))
if N < 0:
if homogeneous:
if hints.get('symbols', False):
return (S.Zero, [])
else:
return S.Zero
else:
return None
if N <= r:
C = []
y = E = S.Zero
for i in xrange(0, N+1):
C.append(Symbol('C'+str(i)))
y += C[i] * n**i
for i in xrange(0, r+1):
E += coeffs[i].as_basic()*y.subs(n, n+i)
solutions = solve_undetermined_coeffs(E-f, C, n)
if solutions is not None:
C = [ c for c in C if (c not in solutions) ]
result = y.subs(solutions)
else:
return None # TBD
else:
A = r
U = N+A+b+1
nni_roots = roots(polys[r], filter='Z',
predicate=lambda r: r >= 0).keys()
if nni_roots != []:
a = max(nni_roots) + 1
else:
a = S.Zero
def zero_vector(k):
return [S.Zero] * k
def one_vector(k):
return [S.One] * k
def delta(p, k):
B = S.One
D = p.subs(n, a+k)
for i in xrange(1, k+1):
B *= -Rational(k-i+1, i)
D += B * p.subs(n, a+k-i)
开发者ID:Sumith1896,项目名称:sympy-polys,代码行数:66,代码来源:recurr.py
注:本文中的sympy.solvers.solve_undetermined_coeffs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论