本文整理汇总了Python中sympy.functions.im函数的典型用法代码示例。如果您正苦于以下问题:Python im函数的具体用法?Python im怎么用?Python im使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了im函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: solve_eqn
def solve_eqn(self):
q, betasq, ml, md, m0 = sympy.symbols('q,betasq,ml,md,m0')
nbetasq = self.model_betasq()
eqn1, eqn2, eqn3, eqn4, eqn5 = self.get_eqns()
sols = sympy.solve([eqn1.subs(betasq, nbetasq),
eqn2.subs(betasq, nbetasq),
eqn3.subs(betasq, nbetasq),
eqn4.subs(betasq, nbetasq)],
[q, ml, md, m0])
isAllReal = lambda item: im(item[0])==0 and im(item[1])==0 and im(item[2])==0 and im(item[3])==0
sols = filter(isAllReal, sols)
isValid = lambda item: item[0]>0 and item[1]>=0 and item[2]>=0 and item[3]>0
sols = filter(isValid, sols)
return sols
开发者ID:stephenhky,项目名称:helimagnet,代码行数:14,代码来源:helicalphase_sympy.py
示例2: roots_binomial
def roots_binomial(f):
"""Returns a list of roots of a binomial polynomial."""
n = f.degree()
a, b = f.nth(n), f.nth(0)
alpha = (-cancel(b/a))**Rational(1, n)
if alpha.is_number:
alpha = alpha.expand(complex=True)
roots, I = [], S.ImaginaryUnit
for k in xrange(n):
zeta = exp(2*k*S.Pi*I/n).expand(complex=True)
roots.append((alpha*zeta).expand(power_base=False))
if all([ r.is_number for r in roots ]):
reals, complexes = [], []
for root in roots:
if root.is_real:
reals.append(root)
else:
complexes.append(root)
roots = sorted(reals) + sorted(complexes, key=lambda r: (re(r), -im(r)))
return roots
开发者ID:robotment,项目名称:sympy,代码行数:28,代码来源:polyroots.py
示例3: reduce_poly_inequalities
def reduce_poly_inequalities(exprs, gen, assume=True, relational=True):
"""Reduce a system of polynomial inequalities with rational coefficients. """
exact = True
polys = []
for _exprs in exprs:
_polys = []
for expr in _exprs:
if isinstance(expr, tuple):
expr, rel = expr
else:
if expr.is_Relational:
expr, rel = expr.lhs - expr.rhs, expr.rel_op
else:
expr, rel = expr, '=='
poly = Poly(expr, gen)
if not poly.get_domain().is_Exact:
poly, exact = poly.to_exact(), False
domain = poly.get_domain()
if not (domain.is_ZZ or domain.is_QQ):
raise NotImplementedError("inequality solving is not supported over %s" % domain)
_polys.append((poly, rel))
polys.append(_polys)
solution = solve_poly_inequalities(polys)
if isinstance(solution, Union):
intervals = list(solution.args)
elif isinstance(solution, Interval):
intervals = [solution]
else:
intervals = []
if not exact:
intervals = map(interval_evalf, intervals)
if not relational:
return intervals
real = ask(gen, 'real', assume)
def relationalize(gen):
return Or(*[ i.as_relational(gen) for i in intervals ])
if not real:
result = And(relationalize(re(gen)), Eq(im(gen), 0))
else:
result = relationalize(gen)
return result
开发者ID:addisonc,项目名称:sympy,代码行数:57,代码来源:inequalities.py
示例4: test_even
def test_even():
x, y, z, t = symbols("x,y,z,t")
assert ask(x, Q.even) == None
assert ask(x, Q.even, Assume(x, Q.integer)) == None
assert ask(x, Q.even, Assume(x, Q.integer, False)) == False
assert ask(x, Q.even, Assume(x, Q.rational)) == None
assert ask(x, Q.even, Assume(x, Q.positive)) == None
assert ask(2 * x, Q.even) == None
assert ask(2 * x, Q.even, Assume(x, Q.integer)) == True
assert ask(2 * x, Q.even, Assume(x, Q.even)) == True
assert ask(2 * x, Q.even, Assume(x, Q.irrational)) == False
assert ask(2 * x, Q.even, Assume(x, Q.odd)) == True
assert ask(2 * x, Q.even, Assume(x, Q.integer, False)) == None
assert ask(3 * x, Q.even, Assume(x, Q.integer)) == None
assert ask(3 * x, Q.even, Assume(x, Q.even)) == True
assert ask(3 * x, Q.even, Assume(x, Q.odd)) == False
assert ask(x + 1, Q.even, Assume(x, Q.odd)) == True
assert ask(x + 1, Q.even, Assume(x, Q.even)) == False
assert ask(x + 2, Q.even, Assume(x, Q.odd)) == False
assert ask(x + 2, Q.even, Assume(x, Q.even)) == True
assert ask(7 - x, Q.even, Assume(x, Q.odd)) == True
assert ask(7 + x, Q.even, Assume(x, Q.odd)) == True
assert ask(x + y, Q.even, Assume(x, Q.odd) & Assume(y, Q.odd)) == True
assert ask(x + y, Q.even, Assume(x, Q.odd) & Assume(y, Q.even)) == False
assert ask(x + y, Q.even, Assume(x, Q.even) & Assume(y, Q.even)) == True
assert ask(2 * x + 1, Q.even, Assume(x, Q.integer)) == False
assert ask(2 * x * y, Q.even, Assume(x, Q.rational) & Assume(x, Q.rational)) == None
assert ask(2 * x * y, Q.even, Assume(x, Q.irrational) & Assume(x, Q.irrational)) == None
assert ask(x + y + z, Q.even, Assume(x, Q.odd) & Assume(y, Q.odd) & Assume(z, Q.even)) == True
assert (
ask(x + y + z + t, Q.even, Assume(x, Q.odd) & Assume(y, Q.odd) & Assume(z, Q.even) & Assume(t, Q.integer))
== None
)
assert ask(Abs(x), Q.even, Assume(x, Q.even)) == True
assert ask(Abs(x), Q.even, Assume(x, Q.even, False)) == None
assert ask(re(x), Q.even, Assume(x, Q.even)) == True
assert ask(re(x), Q.even, Assume(x, Q.even, False)) == None
assert ask(im(x), Q.even, Assume(x, Q.even)) == True
assert ask(im(x), Q.even, Assume(x, Q.real)) == True
开发者ID:sympy,项目名称:sympy,代码行数:44,代码来源:test_query.py
示例5: test_Function
def test_Function():
assert mcode(sin(x) ** cos(x)) == "sin(x).^cos(x)"
assert mcode(abs(x)) == "abs(x)"
assert mcode(ceiling(x)) == "ceil(x)"
assert mcode(arg(x)) == "angle(x)"
assert mcode(im(x)) == "imag(x)"
assert mcode(re(x)) == "real(x)"
assert mcode(Max(x, y) + Min(x, y)) == "max(x, y) + min(x, y)"
assert mcode(Max(x, y, z)) == "max(x, max(y, z))"
assert mcode(Min(x, y, z)) == "min(x, min(y, z))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:10,代码来源:test_octave.py
示例6: test_even
def test_even():
x, y, z, t = symbols('x,y,z,t')
assert ask(Q.even(x)) == None
assert ask(Q.even(x), Q.integer(x)) == None
assert ask(Q.even(x), ~Q.integer(x)) == False
assert ask(Q.even(x), Q.rational(x)) == None
assert ask(Q.even(x), Q.positive(x)) == None
assert ask(Q.even(2*x)) == None
assert ask(Q.even(2*x), Q.integer(x)) == True
assert ask(Q.even(2*x), Q.even(x)) == True
assert ask(Q.even(2*x), Q.irrational(x)) == False
assert ask(Q.even(2*x), Q.odd(x)) == True
assert ask(Q.even(2*x), ~Q.integer(x)) == None
assert ask(Q.even(3*x), Q.integer(x)) == None
assert ask(Q.even(3*x), Q.even(x)) == True
assert ask(Q.even(3*x), Q.odd(x)) == False
assert ask(Q.even(x+1), Q.odd(x)) == True
assert ask(Q.even(x+1), Q.even(x)) == False
assert ask(Q.even(x+2), Q.odd(x)) == False
assert ask(Q.even(x+2), Q.even(x)) == True
assert ask(Q.even(7-x), Q.odd(x)) == True
assert ask(Q.even(7+x), Q.odd(x)) == True
assert ask(Q.even(x+y), Q.odd(x) & Q.odd(y)) == True
assert ask(Q.even(x+y), Q.odd(x) & Q.even(y)) == False
assert ask(Q.even(x+y), Q.even(x) & Q.even(y)) == True
assert ask(Q.even(2*x + 1), Q.integer(x)) == False
assert ask(Q.even(2*x*y), Q.rational(x) & Q.rational(x)) == None
assert ask(Q.even(2*x*y), Q.irrational(x) & Q.irrational(x)) == None
assert ask(Q.even(x+y+z), Q.odd(x) & Q.odd(y) & Q.even(z)) == True
assert ask(Q.even(x+y+z+t),
Q.odd(x) & Q.odd(y) & Q.even(z) & Q.integer(t)) == None
assert ask(Q.even(Abs(x)), Q.even(x)) == True
assert ask(Q.even(Abs(x)), ~Q.even(x)) == None
assert ask(Q.even(re(x)), Q.even(x)) == True
assert ask(Q.even(re(x)), ~Q.even(x)) == None
assert ask(Q.even(im(x)), Q.even(x)) == True
assert ask(Q.even(im(x)), Q.real(x)) == True
开发者ID:lazovich,项目名称:sympy,代码行数:42,代码来源:test_query.py
示例7: change_matrix_type
def change_matrix_type(matrix, num_to_sym=1):
"""
Change a matrix or array from numpy to sympy and a sympy matrix
to numpy matrix.
"""
if num_to_sym:
n = len(matrix)
new_matrix = sp.Matrix([[matrix[i,j] for j in range(n)] for i in range(n)])
else:
n = int(sqrt(len(matrix)))
new_matrix = np.matrix([[complex(fun.re(matrix[i,j]), fun.im(matrix[i,j])) for j in range(n)] for i in range(n)])
return new_matrix
开发者ID:maiwol,项目名称:Exact-Simulator,代码行数:12,代码来源:Approx_Errors.py
示例8: reduce_poly_inequalities
def reduce_poly_inequalities(exprs, gen, assume=True, relational=True):
"""Reduce a system of polynomial inequalities with rational coefficients. """
exact = True
polys = []
for _exprs in exprs:
_polys = []
for expr in _exprs:
if isinstance(expr, tuple):
expr, rel = expr
else:
if expr.is_Relational:
expr, rel = expr.lhs - expr.rhs, expr.rel_op
else:
expr, rel = expr, "=="
poly = Poly(expr, gen)
if not poly.get_domain().is_Exact:
poly, exact = poly.to_exact(), False
domain = poly.get_domain()
if not (domain.is_ZZ or domain.is_QQ):
raise NotImplementedError("inequality solving is not supported over %s" % domain)
_polys.append((poly, rel))
polys.append(_polys)
solution = solve_poly_inequalities(polys)
if not exact:
solution = solution.evalf()
if not relational:
return solution
real = ask(Q.real(gen), assumptions=assume)
if not real:
result = And(solution.as_relational(re(gen)), Eq(im(gen), 0))
else:
result = solution.as_relational(gen)
return result
开发者ID:hitej,项目名称:meta-core,代码行数:47,代码来源:inequalities.py
示例9: test_real
def test_real():
x, y = symbols('x y')
assert ask(x, Q.real) == None
assert ask(x, Q.real, Assume(x, Q.real)) == True
assert ask(x, Q.real, Assume(x, Q.nonzero)) == True
assert ask(x, Q.real, Assume(x, Q.positive)) == True
assert ask(x, Q.real, Assume(x, Q.negative)) == True
assert ask(x, Q.real, Assume(x, Q.integer)) == True
assert ask(x, Q.real, Assume(x, Q.even)) == True
assert ask(x, Q.real, Assume(x, Q.prime)) == True
assert ask(x/sqrt(2), Q.real, Assume(x, Q.real)) == True
assert ask(x/sqrt(-2), Q.real, Assume(x, Q.real)) == False
I = S.ImaginaryUnit
assert ask(x+1, Q.real, Assume(x, Q.real)) == True
assert ask(x+I, Q.real, Assume(x, Q.real)) == False
assert ask(x+I, Q.real, Assume(x, Q.complex)) == None
assert ask(2*x, Q.real, Assume(x, Q.real)) == True
assert ask(I*x, Q.real, Assume(x, Q.real)) == False
assert ask(I*x, Q.real, Assume(x, Q.imaginary)) == True
assert ask(I*x, Q.real, Assume(x, Q.complex)) == None
assert ask(x**2, Q.real, Assume(x, Q.real)) == True
assert ask(sqrt(x), Q.real, Assume(x, Q.negative)) == False
assert ask(x**y, Q.real, Assume(x, Q.real) & Assume(y, Q.integer)) == True
assert ask(x**y, Q.real, Assume(x, Q.real) & Assume(y, Q.real)) == None
assert ask(x**y, Q.real, Assume(x, Q.positive) & \
Assume(y, Q.real)) == True
# trigonometric functions
assert ask(sin(x), Q.real) == None
assert ask(cos(x), Q.real) == None
assert ask(sin(x), Q.real, Assume(x, Q.real)) == True
assert ask(cos(x), Q.real, Assume(x, Q.real)) == True
# exponential function
assert ask(exp(x), Q.real) == None
assert ask(exp(x), Q.real, Assume(x, Q.real)) == True
assert ask(x + exp(x), Q.real, Assume(x, Q.real)) == True
# Q.complexes
assert ask(re(x), Q.real) == True
assert ask(im(x), Q.real) == True
开发者ID:Aang,项目名称:sympy,代码行数:45,代码来源:test_query.py
示例10: test_real
def test_real():
x, y = symbols('x,y')
assert ask(Q.real(x)) == None
assert ask(Q.real(x), Q.real(x)) == True
assert ask(Q.real(x), Q.nonzero(x)) == True
assert ask(Q.real(x), Q.positive(x)) == True
assert ask(Q.real(x), Q.negative(x)) == True
assert ask(Q.real(x), Q.integer(x)) == True
assert ask(Q.real(x), Q.even(x)) == True
assert ask(Q.real(x), Q.prime(x)) == True
assert ask(Q.real(x/sqrt(2)), Q.real(x)) == True
assert ask(Q.real(x/sqrt(-2)), Q.real(x)) == False
I = S.ImaginaryUnit
assert ask(Q.real(x+1), Q.real(x)) == True
assert ask(Q.real(x+I), Q.real(x)) == False
assert ask(Q.real(x+I), Q.complex(x)) == None
assert ask(Q.real(2*x), Q.real(x)) == True
assert ask(Q.real(I*x), Q.real(x)) == False
assert ask(Q.real(I*x), Q.imaginary(x)) == True
assert ask(Q.real(I*x), Q.complex(x)) == None
assert ask(Q.real(x**2), Q.real(x)) == True
assert ask(Q.real(sqrt(x)), Q.negative(x)) == False
assert ask(Q.real(x**y), Q.real(x) & Q.integer(y)) == True
assert ask(Q.real(x**y), Q.real(x) & Q.real(y)) == None
assert ask(Q.real(x**y), Q.positive(x) & Q.real(y)) == True
# trigonometric functions
assert ask(Q.real(sin(x))) == None
assert ask(Q.real(cos(x))) == None
assert ask(Q.real(sin(x)), Q.real(x)) == True
assert ask(Q.real(cos(x)), Q.real(x)) == True
# exponential function
assert ask(Q.real(exp(x))) == None
assert ask(Q.real(exp(x)), Q.real(x)) == True
assert ask(Q.real(x + exp(x)), Q.real(x)) == True
# Q.complexes
assert ask(Q.real(re(x))) == True
assert ask(Q.real(im(x))) == True
开发者ID:lazovich,项目名称:sympy,代码行数:44,代码来源:test_query.py
示例11: test_Function_change_name
def test_Function_change_name():
assert mcode(abs(x)) == "abs(x)"
assert mcode(ceiling(x)) == "ceil(x)"
assert mcode(arg(x)) == "angle(x)"
assert mcode(im(x)) == "imag(x)"
assert mcode(re(x)) == "real(x)"
assert mcode(conjugate(x)) == "conj(x)"
assert mcode(chebyshevt(y, x)) == "chebyshevT(y, x)"
assert mcode(chebyshevu(y, x)) == "chebyshevU(y, x)"
assert mcode(laguerre(x, y)) == "laguerreL(x, y)"
assert mcode(Chi(x)) == "coshint(x)"
assert mcode(Shi(x)) == "sinhint(x)"
assert mcode(Ci(x)) == "cosint(x)"
assert mcode(Si(x)) == "sinint(x)"
assert mcode(li(x)) == "logint(x)"
assert mcode(loggamma(x)) == "gammaln(x)"
assert mcode(polygamma(x, y)) == "psi(x, y)"
assert mcode(RisingFactorial(x, y)) == "pochhammer(x, y)"
assert mcode(DiracDelta(x)) == "dirac(x)"
assert mcode(DiracDelta(x, 3)) == "dirac(3, x)"
assert mcode(Heaviside(x)) == "heaviside(x)"
assert mcode(Heaviside(x, y)) == "heaviside(x, y)"
开发者ID:Lenqth,项目名称:sympy,代码行数:22,代码来源:test_octave.py
示例12: roots_quintic
def roots_quintic(f):
"""
Calculate exact roots of a solvable quintic
"""
result = []
coeff_5, coeff_4, p, q, r, s = f.all_coeffs()
# Eqn must be of the form x^5 + px^3 + qx^2 + rx + s
if coeff_4:
return result
if coeff_5 != 1:
l = [p/coeff_5, q/coeff_5, r/coeff_5, s/coeff_5]
if not all(coeff.is_Rational for coeff in l):
return result
f = Poly(f/coeff_5)
quintic = PolyQuintic(f)
# Eqn standardized. Algo for solving starts here
if not f.is_irreducible:
return result
f20 = quintic.f20
# Check if f20 has linear factors over domain Z
if f20.is_irreducible:
return result
# Now, we know that f is solvable
for _factor in f20.factor_list()[1]:
if _factor[0].is_linear:
theta = _factor[0].root(0)
break
d = discriminant(f)
delta = sqrt(d)
# zeta = a fifth root of unity
zeta1, zeta2, zeta3, zeta4 = quintic.zeta
T = quintic.T(theta, d)
tol = S(1e-10)
alpha = T[1] + T[2]*delta
alpha_bar = T[1] - T[2]*delta
beta = T[3] + T[4]*delta
beta_bar = T[3] - T[4]*delta
disc = alpha**2 - 4*beta
disc_bar = alpha_bar**2 - 4*beta_bar
l0 = quintic.l0(theta)
l1 = _quintic_simplify((-alpha + sqrt(disc)) / S(2))
l4 = _quintic_simplify((-alpha - sqrt(disc)) / S(2))
l2 = _quintic_simplify((-alpha_bar + sqrt(disc_bar)) / S(2))
l3 = _quintic_simplify((-alpha_bar - sqrt(disc_bar)) / S(2))
order = quintic.order(theta, d)
test = (order*delta.n()) - ( (l1.n() - l4.n())*(l2.n() - l3.n()) )
# Comparing floats
if not comp(test, 0, tol):
l2, l3 = l3, l2
# Now we have correct order of l's
R1 = l0 + l1*zeta1 + l2*zeta2 + l3*zeta3 + l4*zeta4
R2 = l0 + l3*zeta1 + l1*zeta2 + l4*zeta3 + l2*zeta4
R3 = l0 + l2*zeta1 + l4*zeta2 + l1*zeta3 + l3*zeta4
R4 = l0 + l4*zeta1 + l3*zeta2 + l2*zeta3 + l1*zeta4
Res = [None, [None]*5, [None]*5, [None]*5, [None]*5]
Res_n = [None, [None]*5, [None]*5, [None]*5, [None]*5]
sol = Symbol('sol')
# Simplifying improves performance a lot for exact expressions
R1 = _quintic_simplify(R1)
R2 = _quintic_simplify(R2)
R3 = _quintic_simplify(R3)
R4 = _quintic_simplify(R4)
# Solve imported here. Causing problems if imported as 'solve'
# and hence the changed name
from sympy.solvers.solvers import solve as _solve
a, b = symbols('a b', cls=Dummy)
_sol = _solve( sol**5 - a - I*b, sol)
for i in range(5):
_sol[i] = factor(_sol[i])
R1 = R1.as_real_imag()
R2 = R2.as_real_imag()
R3 = R3.as_real_imag()
R4 = R4.as_real_imag()
for i, currentroot in enumerate(_sol):
Res[1][i] = _quintic_simplify(currentroot.subs({ a: R1[0], b: R1[1] }))
Res[2][i] = _quintic_simplify(currentroot.subs({ a: R2[0], b: R2[1] }))
Res[3][i] = _quintic_simplify(currentroot.subs({ a: R3[0], b: R3[1] }))
Res[4][i] = _quintic_simplify(currentroot.subs({ a: R4[0], b: R4[1] }))
for i in range(1, 5):
for j in range(5):
Res_n[i][j] = Res[i][j].n()
Res[i][j] = _quintic_simplify(Res[i][j])
r1 = Res[1][0]
r1_n = Res_n[1][0]
#.........这里部分代码省略.........
开发者ID:bjodah,项目名称:sympy,代码行数:101,代码来源:polyroots.py
示例13: reduce_rational_inequalities
def reduce_rational_inequalities(exprs, gen, assume=True, relational=True):
"""Reduce a system of rational inequalities with rational coefficients.
Examples
========
>>> from sympy import Poly, Symbol
>>> from sympy.solvers.inequalities import reduce_rational_inequalities
>>> x = Symbol('x', real=True)
>>> reduce_rational_inequalities([[x**2 <= 0]], x)
x == 0
>>> reduce_rational_inequalities([[x + 2 > 0]], x)
And(-2 < x, x < oo)
>>> reduce_rational_inequalities([[(x + 2, ">")]], x)
And(-2 < x, x < oo)
>>> reduce_rational_inequalities([[x + 2]], x)
x == -2
"""
exact = True
eqs = []
for _exprs in exprs:
_eqs = []
for expr in _exprs:
if isinstance(expr, tuple):
expr, rel = expr
else:
if expr.is_Relational:
expr, rel = expr.lhs - expr.rhs, expr.rel_op
else:
expr, rel = expr, '=='
try:
(numer, denom), opt = parallel_poly_from_expr(
expr.together().as_numer_denom(), gen)
except PolynomialError:
raise PolynomialError("only polynomials and "
"rational functions are supported in this context")
if not opt.domain.is_Exact:
numer, denom, exact = numer.to_exact(), denom.to_exact(), False
domain = opt.domain.get_exact()
if not (domain.is_ZZ or domain.is_QQ):
raise NotImplementedError(
"inequality solving is not supported over %s" % opt.domain)
_eqs.append(((numer, denom), rel))
eqs.append(_eqs)
solution = solve_rational_inequalities(eqs)
if not exact:
solution = solution.evalf()
if not relational:
return solution
real = ask(Q.real(gen), assumptions=assume)
if not real:
result = And(solution.as_relational(re(gen)), Eq(im(gen), 0))
else:
result = solution.as_relational(gen)
return result
开发者ID:aiwku1277,项目名称:sympy,代码行数:72,代码来源:inequalities.py
示例14: test_complex
def test_complex():
x, y = symbols('xy')
assert ask(x, Q.complex) == None
assert ask(x, Q.complex, Assume(x, Q.complex)) == True
assert ask(x, Q.complex, Assume(y, Q.complex)) == None
assert ask(x, Q.complex, Assume(x, Q.complex, False)) == False
assert ask(x, Q.complex, Assume(x, Q.real)) == True
assert ask(x, Q.complex, Assume(x, Q.real, False)) == None
assert ask(x, Q.complex, Assume(x, Q.rational)) == True
assert ask(x, Q.complex, Assume(x, Q.irrational)) == True
assert ask(x, Q.complex, Assume(x, Q.positive)) == True
assert ask(x, Q.complex, Assume(x, Q.imaginary)) == True
# a+b
assert ask(x+1, Q.complex, Assume(x, Q.complex)) == True
assert ask(x+1, Q.complex, Assume(x, Q.real)) == True
assert ask(x+1, Q.complex, Assume(x, Q.rational)) == True
assert ask(x+1, Q.complex, Assume(x, Q.irrational)) == True
assert ask(x+1, Q.complex, Assume(x, Q.imaginary)) == True
assert ask(x+1, Q.complex, Assume(x, Q.integer)) == True
assert ask(x+1, Q.complex, Assume(x, Q.even)) == True
assert ask(x+1, Q.complex, Assume(x, Q.odd)) == True
assert ask(x+y, Q.complex, Assume(x, Q.complex) & Assume(y, Q.complex)) == True
assert ask(x+y, Q.complex, Assume(x, Q.real) & Assume(y, Q.imaginary)) == True
# a*x +b
assert ask(2*x+1, Q.complex, Assume(x, Q.complex)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.real)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.positive)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.rational)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.irrational)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.imaginary)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.integer)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.even)) == True
assert ask(2*x+1, Q.complex, Assume(x, Q.odd)) == True
# x**2
assert ask(x**2, Q.complex, Assume(x, Q.complex)) == True
assert ask(x**2, Q.complex, Assume(x, Q.real)) == True
assert ask(x**2, Q.complex, Assume(x, Q.positive)) == True
assert ask(x**2, Q.complex, Assume(x, Q.rational)) == True
assert ask(x**2, Q.complex, Assume(x, Q.irrational)) == True
assert ask(x**2, Q.complex, Assume(x, Q.imaginary)) == True
assert ask(x**2, Q.complex, Assume(x, Q.integer)) == True
assert ask(x**2, Q.complex, Assume(x, Q.even)) == True
assert ask(x**2, Q.complex, Assume(x, Q.odd)) == True
# 2**x
assert ask(2**x, Q.complex, Assume(x, Q.complex)) == True
assert ask(2**x, Q.complex, Assume(x, Q.real)) == True
assert ask(2**x, Q.complex, Assume(x, Q.positive)) == True
assert ask(2**x, Q.complex, Assume(x, Q.rational)) == True
assert ask(2**x, Q.complex, Assume(x, Q.irrational)) == True
assert ask(2**x, Q.complex, Assume(x, Q.imaginary)) == True
assert ask(2**x, Q.complex, Assume(x, Q.integer)) == True
assert ask(2**x, Q.complex, Assume(x, Q.even)) == True
assert ask(2**x, Q.complex, Assume(x, Q.odd)) == True
assert ask(x**y, Q.complex, Assume(x, Q.complex) & \
Assume(y, Q.complex)) == True
# trigonometric expressions
assert ask(sin(x), Q.complex) == True
assert ask(sin(2*x + 1), Q.complex) == True
assert ask(cos(x), Q.complex) == True
assert ask(cos(2*x+1), Q.complex) == True
# exponential
assert ask(exp(x), Q.complex) == True
assert ask(exp(x), Q.complex) == True
# Q.complexes
assert ask(Abs(x), Q.complex) == True
assert ask(re(x), Q.complex) == True
assert ask(im(x), Q.complex) == True
开发者ID:Aang,项目名称:sympy,代码行数:74,代码来源:test_query.py
示例15: test_complex
def test_complex():
x, y = symbols('x,y')
assert ask(Q.complex(x)) == None
assert ask(Q.complex(x), Q.complex(x)) == True
assert ask(Q.complex(x), Q.complex(y)) == None
assert ask(Q.complex(x), ~Q.complex(x)) == False
assert ask(Q.complex(x), Q.real(x)) == True
assert ask(Q.complex(x), ~Q.real(x)) == None
assert ask(Q.complex(x), Q.rational(x)) == True
assert ask(Q.complex(x), Q.irrational(x)) == True
assert ask(Q.complex(x), Q.positive(x)) == True
assert ask(Q.complex(x), Q.imaginary(x)) == True
# a+b
assert ask(Q.complex(x+1), Q.complex(x)) == True
assert ask(Q.complex(x+1), Q.real(x)) == True
assert ask(Q.complex(x+1), Q.rational(x)) == True
assert ask(Q.complex(x+1), Q.irrational(x)) == True
assert ask(Q.complex(x+1), Q.imaginary(x)) == True
assert ask(Q.complex(x+1), Q.integer(x)) == True
assert ask(Q.complex(x+1), Q.even(x)) == True
assert ask(Q.complex(x+1), Q.odd(x)) == True
assert ask(Q.complex(x+y), Q.complex(x) & Q.complex(y)) == True
assert ask(Q.complex(x+y), Q.real(x) & Q.imaginary(y)) == True
# a*x +b
assert ask(Q.complex(2*x+1), Q.complex(x)) == True
assert ask(Q.complex(2*x+1), Q.real(x)) == True
assert ask(Q.complex(2*x+1), Q.positive(x)) == True
assert ask(Q.complex(2*x+1), Q.rational(x)) == True
assert ask(Q.complex(2*x+1), Q.irrational(x)) == True
assert ask(Q.complex(2*x+1), Q.imaginary(x)) == True
assert ask(Q.complex(2*x+1), Q.integer(x)) == True
assert ask(Q.complex(2*x+1), Q.even(x)) == True
assert ask(Q.complex(2*x+1), Q.odd(x)) == True
# x**2
assert ask(Q.complex(x**2), Q.complex(x)) == True
assert ask(Q.complex(x**2), Q.real(x)) == True
assert ask(Q.complex(x**2), Q.positive(x)) == True
assert ask(Q.complex(x**2), Q.rational(x)) == True
assert ask(Q.complex(x**2), Q.irrational(x)) == True
assert ask(Q.complex(x**2), Q.imaginary(x)) == True
assert ask(Q.complex(x**2), Q.integer(x)) == True
assert ask(Q.complex(x**2), Q.even(x)) == True
assert ask(Q.complex(x**2), Q.odd(x)) == True
# 2**x
assert ask(Q.complex(2**x), Q.complex(x)) == True
assert ask(Q.complex(2**x), Q.real(x)) == True
assert ask(Q.complex(2**x), Q.positive(x)) == True
assert ask(Q.complex(2**x), Q.rational(x)) == True
assert ask(Q.complex(2**x), Q.irrational(x)) == True
assert ask(Q.complex(2**x), Q.imaginary(x)) == True
assert ask(Q.complex(2**x), Q.integer(x)) == True
assert ask(Q.complex(2**x), Q.even(x)) == True
assert ask(Q.complex(2**x), Q.odd(x)) == True
assert ask(Q.complex(x**y), Q.complex(x) & Q.complex(y)) == True
# trigonometric expressions
assert ask(Q.complex(sin(x))) == True
assert ask(Q.complex(sin(2*x + 1))) == True
assert ask(Q.complex(cos(x))) == True
assert ask(Q.complex(cos(2*x+1))) == True
# exponential
assert ask(Q.complex(exp(x))) == True
assert ask(Q.complex(exp(x))) == True
# Q.complexes
assert ask(Q.complex(Abs(x))) == True
assert ask(Q.complex(re(x))) == True
assert ask(Q.complex(im(x))) == True
开发者ID:lazovich,项目名称:sympy,代码行数:73,代码来源:test_query.py
注:本文中的sympy.functions.im函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论