本文整理汇总了Python中sympy.solvers.solveset.solveset_complex函数的典型用法代码示例。如果您正苦于以下问题:Python solveset_complex函数的具体用法?Python solveset_complex怎么用?Python solveset_complex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了solveset_complex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_solveset_complex_exp
def test_solveset_complex_exp():
from sympy.abc import x, n
assert solveset_complex(exp(x) - 1, x) == imageset(Lambda(n, I * 2 * n * pi), S.Integers)
assert solveset_complex(exp(x) - I, x) == imageset(Lambda(n, I * (2 * n * pi + pi / 2)), S.Integers)
assert solveset_complex(1 / exp(x), x) == S.EmptySet
assert solveset_complex(sinh(x).rewrite(exp), x) == imageset(Lambda(n, n * pi * I), S.Integers)
开发者ID:pabloferz,项目名称:sympy,代码行数:7,代码来源:test_solveset.py
示例2: test_garbage_input
def test_garbage_input():
raises(ValueError, lambda: solveset_real([x], x))
raises(ValueError, lambda: solveset_real(x, pi))
raises(ValueError, lambda: solveset_real(x, x ** 2))
raises(ValueError, lambda: solveset_complex([x], x))
raises(ValueError, lambda: solveset_complex(x, pi))
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:7,代码来源:test_solveset.py
示例3: test_solve_complex_sqrt
def test_solve_complex_sqrt():
assert solveset_complex(sqrt(5*x + 6) - 2 - x, x) == \
FiniteSet(-S(1), S(2))
assert solveset_complex(sqrt(5*x + 6) - (2 + 2*I) - x, x) == \
FiniteSet(-S(2), 3 - 4*I)
assert solveset_complex(4*x*(1 - a * sqrt(x)), x) == \
FiniteSet(S(0), 1 / a ** 2)
开发者ID:nickle8424,项目名称:sympy,代码行数:7,代码来源:test_solveset.py
示例4: test_solveset_complex_rational
def test_solveset_complex_rational():
assert solveset_complex((x - 1)*(x - I)/(x - 3), x) == \
FiniteSet(1, I)
assert solveset_complex((x - y**3)/((y**2)*sqrt(1 - y**2)), x) == \
FiniteSet(y**3)
assert solveset_complex(-x**2 - I, x) == \
FiniteSet(-sqrt(2)/2 + sqrt(2)*I/2, sqrt(2)/2 - sqrt(2)*I/2)
开发者ID:nickle8424,项目名称:sympy,代码行数:8,代码来源:test_solveset.py
示例5: test_solve_polynomial_symbolic_param
def test_solve_polynomial_symbolic_param():
assert solveset_complex((x**2 - 1)**2 - a, x) == \
FiniteSet(sqrt(1 + sqrt(a)), -sqrt(1 + sqrt(a)),
sqrt(1 - sqrt(a)), -sqrt(1 - sqrt(a)))
# issue 4507
assert solveset_complex(y - b/(1 + a*x), x) == \
FiniteSet((b/y - 1)/a) - FiniteSet(-1/a)
# issue 4508
assert solveset_complex(y - b*x/(a + x), x) == \
FiniteSet(-a*y/(y - b)) - FiniteSet(-a)
开发者ID:Kogorushi,项目名称:sympy,代码行数:12,代码来源:test_solveset.py
示例6: test_solve_quintics
def test_solve_quintics():
skip("This test is too slow")
f = x**5 - 110*x**3 - 55*x**2 + 2310*x + 979
s = solveset_complex(f, x)
for root in s:
res = f.subs(x, root.n()).n()
assert tn(res, 0)
f = x**5 + 15*x + 12
s = solveset_complex(f, x)
for root in s:
res = f.subs(x, root.n()).n()
assert tn(res, 0)
开发者ID:nickle8424,项目名称:sympy,代码行数:13,代码来源:test_solveset.py
示例7: test_solveset_complex_polynomial
def test_solveset_complex_polynomial():
from sympy.abc import x, a, b, c
assert solveset_complex(a*x**2 + b*x + c, x) == \
FiniteSet(-b/(2*a) - sqrt(-4*a*c + b**2)/(2*a),
-b/(2*a) + sqrt(-4*a*c + b**2)/(2*a))
assert solveset_complex(x - y**3, y) == FiniteSet(
(-x**Rational(1, 3))/2 + I*sqrt(3)*x**Rational(1, 3)/2,
x**Rational(1, 3),
(-x**Rational(1, 3))/2 - I*sqrt(3)*x**Rational(1, 3)/2)
assert solveset_complex(x + 1/x - 1, x) == \
FiniteSet(Rational(1, 2) + I*sqrt(3)/2, Rational(1, 2) - I*sqrt(3)/2)
开发者ID:nickle8424,项目名称:sympy,代码行数:13,代码来源:test_solveset.py
示例8: test_solve_sqrt_3
def test_solve_sqrt_3():
R = Symbol("R")
eq = sqrt(2) * R * sqrt(1 / (R + 1)) + (R + 1) * (sqrt(2) * sqrt(1 / (R + 1)) - 1)
sol = solveset_complex(eq, R)
assert sol == FiniteSet(
*[
S(5) / 3 + 4 * sqrt(10) * cos(atan(3 * sqrt(111) / 251) / 3) / 3,
-sqrt(10) * cos(atan(3 * sqrt(111) / 251) / 3) / 3
+ 40 * re(1 / ((-S(1) / 2 - sqrt(3) * I / 2) * (S(251) / 27 + sqrt(111) * I / 9) ** (S(1) / 3))) / 9
+ sqrt(30) * sin(atan(3 * sqrt(111) / 251) / 3) / 3
+ S(5) / 3
+ I
* (
-sqrt(30) * cos(atan(3 * sqrt(111) / 251) / 3) / 3
- sqrt(10) * sin(atan(3 * sqrt(111) / 251) / 3) / 3
+ 40 * im(1 / ((-S(1) / 2 - sqrt(3) * I / 2) * (S(251) / 27 + sqrt(111) * I / 9) ** (S(1) / 3))) / 9
),
]
)
# the number of real roots will depend on the value of m: for m=1 there are 4
# and for m=-1 there are none.
eq = -sqrt((m - q) ** 2 + (-m / (2 * q) + S(1) / 2) ** 2) + sqrt(
(-m ** 2 / 2 - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) / 4 - S(1) / 4) ** 2
+ (m ** 2 / 2 - m - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) / 4 - S(1) / 4) ** 2
)
raises(NotImplementedError, lambda: solveset_real(eq, q))
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:28,代码来源:test_solveset.py
示例9: test_solve_trig
def test_solve_trig():
from sympy.abc import n
assert solveset_real(sin(x), x) == Union(
imageset(Lambda(n, 2 * pi * n), S.Integers), imageset(Lambda(n, 2 * pi * n + pi), S.Integers)
)
assert solveset_real(sin(x) - 1, x) == imageset(Lambda(n, 2 * pi * n + pi / 2), S.Integers)
assert solveset_real(cos(x), x) == Union(
imageset(Lambda(n, 2 * pi * n - pi / 2), S.Integers), imageset(Lambda(n, 2 * pi * n + pi / 2), S.Integers)
)
assert solveset_real(sin(x) + cos(x), x) == Union(
imageset(Lambda(n, 2 * n * pi - pi / 4), S.Integers), imageset(Lambda(n, 2 * n * pi + 3 * pi / 4), S.Integers)
)
assert solveset_real(sin(x) ** 2 + cos(x) ** 2, x) == S.EmptySet
assert solveset_complex(cos(x) - S.Half, x) == Union(
imageset(Lambda(n, 2 * n * pi + pi / 3), S.Integers), imageset(Lambda(n, 2 * n * pi - pi / 3), S.Integers)
)
y, a = symbols("y,a")
assert solveset(sin(y + a) - sin(y), a, domain=S.Reals) == Union(
imageset(Lambda(n, 2 * n * pi), S.Integers),
imageset(Lambda(n, -I * (I * (2 * n * pi + arg(-exp(-2 * I * y))) + 2 * im(y))), S.Integers),
)
开发者ID:pabloferz,项目名称:sympy,代码行数:28,代码来源:test_solveset.py
示例10: test_solve_sqrt_3
def test_solve_sqrt_3():
R = Symbol("R")
eq = sqrt(2) * R * sqrt(1 / (R + 1)) + (R + 1) * (sqrt(2) * sqrt(1 / (R + 1)) - 1)
sol = solveset_complex(eq, R)
assert sol == FiniteSet(
*[
S(5) / 3 + 4 * sqrt(10) * cos(atan(3 * sqrt(111) / 251) / 3) / 3,
-sqrt(10) * cos(atan(3 * sqrt(111) / 251) / 3) / 3
+ 40 * re(1 / ((-S(1) / 2 - sqrt(3) * I / 2) * (S(251) / 27 + sqrt(111) * I / 9) ** (S(1) / 3))) / 9
+ sqrt(30) * sin(atan(3 * sqrt(111) / 251) / 3) / 3
+ S(5) / 3
+ I
* (
-sqrt(30) * cos(atan(3 * sqrt(111) / 251) / 3) / 3
- sqrt(10) * sin(atan(3 * sqrt(111) / 251) / 3) / 3
+ 40 * im(1 / ((-S(1) / 2 - sqrt(3) * I / 2) * (S(251) / 27 + sqrt(111) * I / 9) ** (S(1) / 3))) / 9
),
]
)
# the number of real roots will depend on the value of m: for m=1 there are 4
# and for m=-1 there are none.
eq = -sqrt((m - q) ** 2 + (-m / (2 * q) + S(1) / 2) ** 2) + sqrt(
(-m ** 2 / 2 - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) / 4 - S(1) / 4) ** 2
+ (m ** 2 / 2 - m - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) / 4 - S(1) / 4) ** 2
)
unsolved_object = ConditionSet(
q,
Eq(
(
-2 * sqrt(4 * q ** 2 * (m - q) ** 2 + (-m + q) ** 2)
+ sqrt(
(-2 * m ** 2 - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) - 1) ** 2
+ (2 * m ** 2 - 4 * m - sqrt(4 * m ** 4 - 4 * m ** 2 + 8 * m + 1) - 1) ** 2
)
* Abs(q)
)
/ Abs(q),
0,
),
S.Reals,
)
assert solveset_real(eq, q) == unsolved_object
开发者ID:pabloferz,项目名称:sympy,代码行数:44,代码来源:test_solveset.py
示例11: test_solve_sqrt_3
def test_solve_sqrt_3():
R = Symbol('R')
eq = sqrt(2)*R*sqrt(1/(R + 1)) + (R + 1)*(sqrt(2)*sqrt(1/(R + 1)) - 1)
sol = solveset_complex(eq, R)
assert sol == FiniteSet(*[(S(5)/3 + 40/(3*(251 + 3*sqrt(111)*I)**(S(1)/3)) +
(251 + 3*sqrt(111)*I)**(S(1)/3)/3,), ((-160 + (1 +
sqrt(3)*I)*(10 - (1 + sqrt(3)*I)*(251 +
3*sqrt(111)*I)**(S(1)/3))*(251 +
3*sqrt(111)*I)**(S(1)/3))/Mul(6, (1 +
sqrt(3)*I), (251 + 3*sqrt(111)*I)**(S(1)/3),
evaluate=False),)])
eq = -sqrt((m - q)**2 + (-m/(2*q) + S(1)/2)**2) + sqrt((-m**2/2 - sqrt(
4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4)**2 + (m**2/2 - m - sqrt(
4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4)**2)
assert solveset_real(eq, q) == FiniteSet(
m**2/2 - sqrt(4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4,
m**2/2 + sqrt(4*m**4 - 4*m**2 + 8*m + 1)/4 - S(1)/4)
开发者ID:AdrianPotter,项目名称:sympy,代码行数:19,代码来源:test_solveset.py
示例12: test_return_root_of
def test_return_root_of():
f = x ** 5 - 15 * x ** 3 - 5 * x ** 2 + 10 * x + 20
s = list(solveset_complex(f, x))
for root in s:
assert root.func == RootOf
# if one uses solve to get the roots of a polynomial that has a RootOf
# solution, make sure that the use of nfloat during the solve process
# doesn't fail. Note: if you want numerical solutions to a polynomial
# it is *much* faster to use nroots to get them than to solve the
# equation only to get RootOf solutions which are then numerically
# evaluated. So for eq = x**5 + 3*x + 7 do Poly(eq).nroots() rather
# than [i.n() for i in solve(eq)] to get the numerical roots of eq.
assert (
nfloat(list(solveset_complex(x ** 5 + 3 * x ** 3 + 7, x))[0], exponent=False)
== RootOf(x ** 5 + 3 * x ** 3 + 7, 0).n()
)
sol = list(solveset_complex(x ** 6 - 2 * x + 2, x))
assert all(isinstance(i, RootOf) for i in sol) and len(sol) == 6
f = x ** 5 - 15 * x ** 3 - 5 * x ** 2 + 10 * x + 20
s = list(solveset_complex(f, x))
for root in s:
assert root.func == RootOf
s = x ** 5 + 4 * x ** 3 + 3 * x ** 2 + S(7) / 4
assert solveset_complex(s, x) == FiniteSet(*Poly(s * 4, domain="ZZ").all_roots())
# XXX: this comparison should work without converting the FiniteSet to list
# See #7876
eq = x * (x - 1) ** 2 * (x + 1) * (x ** 6 - x + 1)
assert list(solveset_complex(eq, x)) == list(
FiniteSet(
-1,
0,
1,
RootOf(x ** 6 - x + 1, 0),
RootOf(x ** 6 - x + 1, 1),
RootOf(x ** 6 - x + 1, 2),
RootOf(x ** 6 - x + 1, 3),
RootOf(x ** 6 - x + 1, 4),
RootOf(x ** 6 - x + 1, 5),
)
)
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:45,代码来源:test_solveset.py
示例13: test_sol_zero_complex
def test_sol_zero_complex():
# This should return the complex set after it is implemented
raises(NotImplementedError, lambda: solveset_complex(0, x))
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:3,代码来源:test_solveset.py
示例14: test_solve_complex_log
def test_solve_complex_log():
assert solveset_complex(log(x), x) == FiniteSet(1)
assert solveset_complex(1 - log(a + 4*x**2), x) == \
FiniteSet(-sqrt(-a/4 + E/4), sqrt(-a/4 + E/4))
开发者ID:nickle8424,项目名称:sympy,代码行数:4,代码来源:test_solveset.py
示例15: test_solveset_complex_tan
def test_solveset_complex_tan():
s = solveset_complex(tan(x).rewrite(exp), x)
assert s == imageset(Lambda(n, pi*n), S.Integers) - \
imageset(Lambda(n, pi*n + pi/2), S.Integers)
开发者ID:nickle8424,项目名称:sympy,代码行数:4,代码来源:test_solveset.py
示例16: test_sol_zero_complex
def test_sol_zero_complex():
assert solveset_complex(0, x) == S.Complexes
开发者ID:nickle8424,项目名称:sympy,代码行数:2,代码来源:test_solveset.py
示例17: test_solve_complex_unsolvable
def test_solve_complex_unsolvable():
unsolved_object = ConditionSet(x, Eq(2*cos(x) - 1, 0), S.Complexes)
solution = solveset_complex(cos(x) - S.Half, x)
assert solution == unsolved_object
开发者ID:nickle8424,项目名称:sympy,代码行数:4,代码来源:test_solveset.py
示例18: test_solve_polynomial_symbolic_param
def test_solve_polynomial_symbolic_param():
assert solveset_complex((x**2 - 1)**2 - a, x) == \
FiniteSet(sqrt(1 + sqrt(a)), -sqrt(1 + sqrt(a)),
sqrt(1 - sqrt(a)), -sqrt(1 - sqrt(a)))
开发者ID:nickle8424,项目名称:sympy,代码行数:4,代码来源:test_solveset.py
示例19: my_func
def my_func(y, t):
eqn = -(4*z**3 - 9*t*z + 27)*(z**2 - 3*t) - y**2
return solveset_complex(eqn, z)
开发者ID:haessar,项目名称:m2_spec,代码行数:3,代码来源:m2_spec.py
示例20: test_solve_invalid_sol
def test_solve_invalid_sol():
assert 0 not in solveset_real(sin(x)/x, x)
assert 0 not in solveset_complex((exp(x) - 1)/x, x)
开发者ID:nickle8424,项目名称:sympy,代码行数:3,代码来源:test_solveset.py
注:本文中的sympy.solvers.solveset.solveset_complex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论