本文整理汇总了Python中sympy.arg函数的典型用法代码示例。如果您正苦于以下问题:Python arg函数的具体用法?Python arg怎么用?Python arg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: as_real_imag
def as_real_imag(self, deep=True, **hints):
"""
Returns this function as a complex coordinate.
Examples
========
>>> from sympy import I
>>> from sympy.abc import x
>>> from sympy.functions import log
>>> log(x).as_real_imag()
(log(Abs(x)), arg(x))
>>> log(I).as_real_imag()
(0, pi/2)
>>> log(1 + I).as_real_imag()
(log(sqrt(2)), pi/4)
>>> log(I*x).as_real_imag()
(log(Abs(x)), arg(I*x))
"""
from sympy import Abs, arg
if deep:
abs = Abs(self.args[0].expand(deep, **hints))
arg = arg(self.args[0].expand(deep, **hints))
else:
abs = Abs(self.args[0])
arg = arg(self.args[0])
if hints.get('log', False): # Expand the log
hints['complex'] = False
return (log(abs).expand(deep, **hints), arg)
else:
return (log(abs), arg)
开发者ID:baoqchau,项目名称:sympy,代码行数:32,代码来源:exponential.py
示例2: test_atan2
def test_atan2():
assert atan2.nargs == FiniteSet(2)
assert atan2(0, 0) == S.NaN
assert atan2(0, 1) == 0
assert atan2(1, 1) == pi/4
assert atan2(1, 0) == pi/2
assert atan2(1, -1) == 3*pi/4
assert atan2(0, -1) == pi
assert atan2(-1, -1) == -3*pi/4
assert atan2(-1, 0) == -pi/2
assert atan2(-1, 1) == -pi/4
i = symbols('i', imaginary=True)
r = symbols('r', real=True)
eq = atan2(r, i)
ans = -I*log((i + I*r)/sqrt(i**2 + r**2))
reps = ((r, 2), (i, I))
assert eq.subs(reps) == ans.subs(reps)
x = Symbol('x', negative=True)
y = Symbol('y', negative=True)
assert atan2(y, x) == atan(y/x) - pi
y = Symbol('y', nonnegative=True)
assert atan2(y, x) == atan(y/x) + pi
y = Symbol('y')
assert atan2(y, x) == atan2(y, x, evaluate=False)
u = Symbol("u", positive=True)
assert atan2(0, u) == 0
u = Symbol("u", negative=True)
assert atan2(0, u) == pi
assert atan2(y, oo) == 0
assert atan2(y, -oo)== 2*pi*Heaviside(re(y)) - pi
assert atan2(y, x).rewrite(log) == -I*log((x + I*y)/sqrt(x**2 + y**2))
assert atan2(y, x).rewrite(atan) == 2*atan(y/(x + sqrt(x**2 + y**2)))
ex = atan2(y, x) - arg(x + I*y)
assert ex.subs({x:2, y:3}).rewrite(arg) == 0
assert ex.subs({x:2, y:3*I}).rewrite(arg) == -pi - I*log(sqrt(5)*I/5)
assert ex.subs({x:2*I, y:3}).rewrite(arg) == -pi/2 - I*log(sqrt(5)*I)
assert ex.subs({x:2*I, y:3*I}).rewrite(arg) == -pi + atan(2/S(3)) + atan(3/S(2))
i = symbols('i', imaginary=True)
r = symbols('r', real=True)
e = atan2(i, r)
rewrite = e.rewrite(arg)
reps = {i: I, r: -2}
assert rewrite == -I*log(abs(I*i + r)/sqrt(abs(i**2 + r**2))) + arg((I*i + r)/sqrt(i**2 + r**2))
assert (e - rewrite).subs(reps).equals(0)
assert conjugate(atan2(x, y)) == atan2(conjugate(x), conjugate(y))
assert diff(atan2(y, x), x) == -y/(x**2 + y**2)
assert diff(atan2(y, x), y) == x/(x**2 + y**2)
assert simplify(diff(atan2(y, x).rewrite(log), x)) == -y/(x**2 + y**2)
assert simplify(diff(atan2(y, x).rewrite(log), y)) == x/(x**2 + y**2)
开发者ID:AdrianPotter,项目名称:sympy,代码行数:57,代码来源:test_trigonometric.py
示例3: _laplace_transform
def _laplace_transform(f, t, s, simplify=True):
""" The backend function for laplace transforms. """
from sympy import (re, Max, exp, pi, Abs, Min, periodic_argument as arg,
cos, Wild, symbols)
F = integrate(exp(-s*t) * f, (t, 0, oo))
if not F.has(Integral):
return _simplify(F, simplify), -oo, True
if not F.is_Piecewise:
raise IntegralTransformError('Laplace', f, 'could not compute integral')
F, cond = F.args[0]
if F.has(Integral):
raise IntegralTransformError('Laplace', f, 'integral in unexpected form')
a = -oo
aux = True
conds = conjuncts(to_cnf(cond))
u = Dummy('u', real=True)
p, q, w1, w2, w3 = symbols('p q w1 w2 w3', cls=Wild, exclude=[s])
for c in conds:
a_ = oo
aux_ = []
for d in disjuncts(c):
m = d.match(abs(arg((s + w3)**p*q, w1)) < w2)
if m:
if m[q] > 0 and m[w2]/m[p] == pi/2:
d = re(s + m[w3]) > 0
m = d.match(0 < cos(abs(arg(s, q)))*abs(s) - p)
if m:
d = re(s) > m[p]
d_ = d.replace(re, lambda x: x.expand().as_real_imag()[0]).subs(re(s), t)
if not d.is_Relational or (d.rel_op != '<' and d.rel_op != '<=') \
or d_.has(s) or not d_.has(t):
aux_ += [d]
continue
soln = _solve_inequality(d_, t)
if not soln.is_Relational or \
(soln.rel_op != '<' and soln.rel_op != '<='):
aux_ += [d]
continue
if soln.lhs == t:
raise IntegralTransformError('Laplace', f,
'convergence not in half-plane?')
else:
a_ = Min(soln.lhs, a_)
if a_ != oo:
a = Max(a_, a)
else:
aux = And(aux, Or(*aux_))
return _simplify(F, simplify), a, aux
开发者ID:arpitsaan,项目名称:sympy,代码行数:53,代码来源:transforms.py
示例4: test_derivatives_issue_4757
def test_derivatives_issue_4757():
x = Symbol('x', real=True)
y = Symbol('y', imaginary=True)
f = Function('f')
assert re(f(x)).diff(x) == re(f(x).diff(x))
assert im(f(x)).diff(x) == im(f(x).diff(x))
assert re(f(y)).diff(y) == -I*im(f(y).diff(y))
assert im(f(y)).diff(y) == -I*re(f(y).diff(y))
assert Abs(f(x)).diff(x).subs(f(x), 1 + I*x).doit() == x/sqrt(1 + x**2)
assert arg(f(x)).diff(x).subs(f(x), 1 + I*x**2).doit() == 2*x/(1 + x**4)
assert Abs(f(y)).diff(y).subs(f(y), 1 + y).doit() == -y/sqrt(1 - y**2)
assert arg(f(y)).diff(y).subs(f(y), I + y**2).doit() == 2*y/(1 + y**4)
开发者ID:A-turing-machine,项目名称:sympy,代码行数:12,代码来源:test_complexes.py
示例5: _inverse_mellin_transform
def _inverse_mellin_transform(F, s, x_, strip, as_meijerg=False):
""" A helper for the real inverse_mellin_transform function, this one here
assumes x to be real and positive. """
from sympy import (expand, expand_mul, hyperexpand, meijerg, And, Or,
arg, pi, re, factor, Heaviside, gamma, Add)
x = _dummy('t', 'inverse-mellin-transform', F, positive=True)
# Actually, we won't try integration at all. Instead we use the definition
# of the Meijer G function as a fairly general inverse mellin transform.
F = F.rewrite(gamma)
for g in [factor(F), expand_mul(F), expand(F)]:
if g.is_Add:
# do all terms separately
ress = [_inverse_mellin_transform(G, s, x, strip, as_meijerg,
noconds=False) \
for G in g.args]
conds = [p[1] for p in ress]
ress = [p[0] for p in ress]
res = Add(*ress)
if not as_meijerg:
res = factor(res, gens=res.atoms(Heaviside))
return res.subs(x, x_), And(*conds)
try:
a, b, C, e, fac = _rewrite_gamma(g, s, strip[0], strip[1])
except IntegralTransformError:
continue
G = meijerg(a, b, C/x**e)
if as_meijerg:
h = G
else:
h = hyperexpand(G)
if h.is_Piecewise and len(h.args) == 3:
# XXX we break modularity here!
h = Heaviside(x - abs(C))*h.args[0].args[0] \
+ Heaviside(abs(C) - x)*h.args[1].args[0]
# We must ensure that the intgral along the line we want converges,
# and return that value.
# See [L], 5.2
cond = [abs(arg(G.argument)) < G.delta*pi]
# Note: we allow ">=" here, this corresponds to convergence if we let
# limits go to oo symetrically. ">" corresponds to absolute convergence.
cond += [And(Or(len(G.ap) != len(G.bq), 0 >= re(G.nu) + 1),
abs(arg(G.argument)) == G.delta*pi)]
cond = Or(*cond)
if cond is False:
raise IntegralTransformError('Inverse Mellin', F, 'does not converge')
return (h*fac).subs(x, x_), cond
raise IntegralTransformError('Inverse Mellin', F, '')
开发者ID:ALGHeArT,项目名称:sympy,代码行数:49,代码来源:transforms.py
示例6: test_arg
def test_arg():
assert arg(0) == nan
assert arg(1) == 0
assert arg(-1) == pi
assert arg(I) == pi/2
assert arg(-I) == -pi/2
assert arg(1+I) == pi/4
assert arg(-1+I) == 3*pi/4
assert arg(1-I) == -pi/4
p = Symbol('p', positive=True)
assert arg(p) == 0
n = Symbol('n', negative=True)
assert arg(n) == pi
开发者ID:jcockayne,项目名称:sympy-rkern,代码行数:15,代码来源:test_complexes.py
示例7: 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
示例8: arg
def arg(complexe):
if isinstance(complexe, (int, complex, long, float)):
return _cmath.log(complexe).imag
elif isinstance(complexe, _sympy.Basic):
return _sympy.arg(complexe)
else:
return _numpy.imag(_numpy.log(complex))
开发者ID:wxgeo,项目名称:wxgeometrie,代码行数:7,代码来源:universal_functions.py
示例9: polar
def polar(z):
"""polar(z) -> r: float, phi: float
Convert a complex from rectangular coordinates to polar coordinates. r is
the distance from 0 and phi the phase angle.
"""
return (Abs(z), arg(z))
开发者ID:aktech,项目名称:eqpy,代码行数:7,代码来源:_apimappings.py
示例10: test_derivatives_issue1658
def test_derivatives_issue1658():
x = Symbol('x')
f = Function('f')
assert re(f(x)).diff(x) == re(f(x).diff(x))
assert im(f(x)).diff(x) == im(f(x).diff(x))
x = Symbol('x', real=True)
assert Abs(f(x)).diff(x).subs(f(x), 1+I*x).doit() == x/sqrt(1 + x**2)
assert arg(f(x)).diff(x).subs(f(x), 1+I*x**2).doit() == 2*x/(1+x**4)
开发者ID:MichaelMayorov,项目名称:sympy,代码行数:9,代码来源:test_complexes.py
示例11: test_meijerint
def test_meijerint():
from sympy import symbols, expand, arg
s, t, mu = symbols("s t mu", real=True)
assert integrate(
meijerg([], [], [0], [], s * t) * meijerg([], [], [mu / 2], [-mu / 2], t ** 2 / 4), (t, 0, oo)
).is_Piecewise
s = symbols("s", positive=True)
assert integrate(x ** s * meijerg([[], []], [[0], []], x), (x, 0, oo)) == gamma(s + 1)
assert integrate(x ** s * meijerg([[], []], [[0], []], x), (x, 0, oo), meijerg=True) == gamma(s + 1)
assert isinstance(integrate(x ** s * meijerg([[], []], [[0], []], x), (x, 0, oo), meijerg=False), Integral)
assert meijerint_indefinite(exp(x), x) == exp(x)
# TODO what simplifications should be done automatically?
# This tests "extra case" for antecedents_1.
a, b = symbols("a b", positive=True)
assert simplify(meijerint_definite(x ** a, x, 0, b)[0]) == b ** (a + 1) / (a + 1)
# This tests various conditions and expansions:
meijerint_definite((x + 1) ** 3 * exp(-x), x, 0, oo) == (16, True)
# Again, how about simplifications?
sigma, mu = symbols("sigma mu", positive=True)
i, c = meijerint_definite(exp(-((x - mu) / (2 * sigma)) ** 2), x, 0, oo)
assert simplify(i) == sqrt(pi) * sigma * (erf(mu / (2 * sigma)) + 1)
assert c is True
i, _ = meijerint_definite(exp(-mu * x) * exp(sigma * x), x, 0, oo)
# TODO it would be nice to test the condition
assert simplify(i) == 1 / (mu - sigma)
# Test substitutions to change limits
assert meijerint_definite(exp(x), x, -oo, 2) == (exp(2), True)
assert expand(meijerint_definite(exp(x), x, 0, I)[0]) == exp(I) - 1
assert expand(meijerint_definite(exp(-x), x, 0, x)[0]) == 1 - exp(-exp(I * arg(x)) * abs(x))
# Test -oo to oo
assert meijerint_definite(exp(-x ** 2), x, -oo, oo) == (sqrt(pi), True)
assert meijerint_definite(exp(-abs(x)), x, -oo, oo) == (2, True)
assert meijerint_definite(exp(-(2 * x - 3) ** 2), x, -oo, oo) == (sqrt(pi) / 2, True)
assert meijerint_definite(exp(-abs(2 * x - 3)), x, -oo, oo) == (1, True)
assert meijerint_definite(exp(-((x - mu) / sigma) ** 2 / 2) / sqrt(2 * pi * sigma ** 2), x, -oo, oo) == (1, True)
# Test one of the extra conditions for 2 g-functinos
assert meijerint_definite(exp(-x) * sin(x), x, 0, oo) == (S(1) / 2, True)
# Test a bug
def res(n):
return (1 / (1 + x ** 2)).diff(x, n).subs(x, 1) * (-1) ** n
for n in range(6):
assert integrate(exp(-x) * sin(x) * x ** n, (x, 0, oo), meijerg=True) == res(n)
# Test trigexpand:
assert integrate(exp(-x) * sin(x + a), (x, 0, oo), meijerg=True) == sin(a) / 2 + cos(a) / 2
开发者ID:kendhia,项目名称:sympy,代码行数:56,代码来源:test_meijerint.py
示例12: test_invert_complex
def test_invert_complex():
assert invert_complex(x + 3, y, x) == (x, FiniteSet(y - 3))
assert invert_complex(x * 3, y, x) == (x, FiniteSet(y / 3))
assert invert_complex(exp(x), y, x) == (x, imageset(Lambda(n, I * (2 * pi * n + arg(y)) + log(Abs(y))), S.Integers))
assert invert_complex(log(x), y, x) == (x, FiniteSet(exp(y)))
raises(ValueError, lambda: invert_real(S.One, y, x))
raises(ValueError, lambda: invert_complex(x, x, x))
开发者ID:LuckyStrikes1090,项目名称:sympy,代码行数:10,代码来源:test_solveset.py
示例13: test_latex_functions
def test_latex_functions():
assert latex(exp(x)) == "e^{x}"
assert latex(exp(1)+exp(2)) == "e + e^{2}"
f = Function('f')
assert latex(f(x)) == '\\operatorname{f}{\\left (x \\right )}'
beta = Function('beta')
assert latex(beta(x)) == r"\beta{\left (x \right )}"
assert latex(sin(x)) == r"\sin{\left (x \right )}"
assert latex(sin(x), fold_func_brackets=True) == r"\sin {x}"
assert latex(sin(2*x**2), fold_func_brackets=True) == \
r"\sin {2 x^{2}}"
assert latex(sin(x**2), fold_func_brackets=True) == \
r"\sin {x^{2}}"
assert latex(asin(x)**2) == r"\operatorname{asin}^{2}{\left (x \right )}"
assert latex(asin(x)**2,inv_trig_style="full") == \
r"\arcsin^{2}{\left (x \right )}"
assert latex(asin(x)**2,inv_trig_style="power") == \
r"\sin^{-1}{\left (x \right )}^{2}"
assert latex(asin(x**2),inv_trig_style="power",fold_func_brackets=True) == \
r"\sin^{-1} {x^{2}}"
assert latex(factorial(k)) == r"k!"
assert latex(factorial(-k)) == r"\left(- k\right)!"
assert latex(factorial2(k)) == r"k!!"
assert latex(factorial2(-k)) == r"\left(- k\right)!!"
assert latex(binomial(2,k)) == r"{\binom{2}{k}}"
assert latex(FallingFactorial(3,k)) == r"{\left(3\right)}_{\left(k\right)}"
assert latex(RisingFactorial(3,k)) == r"{\left(3\right)}^{\left(k\right)}"
assert latex(floor(x)) == r"\lfloor{x}\rfloor"
assert latex(ceiling(x)) == r"\lceil{x}\rceil"
assert latex(Abs(x)) == r"\lvert{x}\rvert"
assert latex(re(x)) == r"\Re{x}"
assert latex(re(x+y)) == r"\Re {\left (x + y \right )}"
assert latex(im(x)) == r"\Im{x}"
assert latex(conjugate(x)) == r"\overline{x}"
assert latex(gamma(x)) == r"\Gamma\left(x\right)"
assert latex(Order(x)) == r"\mathcal{O}\left(x\right)"
assert latex(lowergamma(x, y)) == r'\gamma\left(x, y\right)'
assert latex(uppergamma(x, y)) == r'\Gamma\left(x, y\right)'
assert latex(cot(x)) == r'\cot{\left (x \right )}'
assert latex(coth(x)) == r'\coth{\left (x \right )}'
assert latex(re(x)) == r'\Re{x}'
assert latex(im(x)) == r'\Im{x}'
assert latex(root(x,y)) == r'x^{\frac{1}{y}}'
assert latex(arg(x)) == r'\arg{\left (x \right )}'
assert latex(zeta(x)) == r'\zeta{\left (x \right )}'
开发者ID:songuke,项目名称:sympy,代码行数:55,代码来源:test_latex.py
示例14: test_issue_7173
def test_issue_7173():
from sympy import cse
x0, x1, x2, x3 = symbols('x:4')
ans = laplace_transform(sinh(a*x)*cosh(a*x), x, s)
r, e = cse(ans)
assert r == [
(x0, pi/2),
(x1, arg(a)),
(x2, Abs(x1)),
(x3, Abs(x1 + pi))]
assert e == [
a/(-4*a**2 + s**2),
0,
((x0 >= x2) | (x2 < x0)) & ((x0 >= x3) | (x3 < x0))]
开发者ID:aprasanna,项目名称:sympy,代码行数:14,代码来源:test_transforms.py
示例15: process_conds
def process_conds(conds):
""" Turn ``conds`` into a strip and auxiliary conditions. """
a = -oo
aux = True
conds = conjuncts(to_cnf(conds))
u = Dummy('u', real=True)
p, q, w1, w2, w3, w4, w5 = symbols('p q w1 w2 w3 w4 w5', cls=Wild, exclude=[s])
for c in conds:
a_ = oo
aux_ = []
for d in disjuncts(c):
m = d.match(abs(arg((s + w3)**p*q, w1)) < w2)
if not m:
m = d.match(abs(arg((s + w3)**p*q, w1)) <= w2)
if not m:
m = d.match(abs(arg((polar_lift(s + w3))**p*q, w1)) < w2)
if not m:
m = d.match(abs(arg((polar_lift(s + w3))**p*q, w1)) <= w2)
if m:
if m[q] > 0 and m[w2]/m[p] == pi/2:
d = re(s + m[w3]) > 0
m = d.match(0 < cos(abs(arg(s**w1*w5, q))*w2)*abs(s**w3)**w4 - p)
if not m:
m = d.match(0 < cos(abs(arg(polar_lift(s)**w1*w5, q))*w2)*abs(s**w3)**w4 - p)
if m and all(m[wild] > 0 for wild in [w1, w2, w3, w4, w5]):
d = re(s) > m[p]
d_ = d.replace(re, lambda x: x.expand().as_real_imag()[0]).subs(re(s), t)
if not d.is_Relational or \
d.rel_op not in ('>', '>=', '<', '<=') \
or d_.has(s) or not d_.has(t):
aux_ += [d]
continue
soln = _solve_inequality(d_, t)
if not soln.is_Relational or \
soln.rel_op not in ('>', '>=', '<', '<='):
aux_ += [d]
continue
if soln.lts == t:
raise IntegralTransformError('Laplace', f,
'convergence not in half-plane?')
else:
a_ = Min(soln.lts, a_)
if a_ != oo:
a = Max(a_, a)
else:
aux = And(aux, Or(*aux_))
return a, aux
开发者ID:harishma,项目名称:sympy,代码行数:47,代码来源:transforms.py
示例16: test_atan2
def test_atan2():
assert atan2.nargs == FiniteSet(2)
assert atan2(0, 0) == S.NaN
assert atan2(0, 1) == 0
assert atan2(1, 1) == pi/4
assert atan2(1, 0) == pi/2
assert atan2(1, -1) == 3*pi/4
assert atan2(0, -1) == pi
assert atan2(-1, -1) == -3*pi/4
assert atan2(-1, 0) == -pi/2
assert atan2(-1, 1) == -pi/4
u = Symbol("u", positive=True)
assert atan2(0, u) == 0
u = Symbol("u", negative=True)
assert atan2(0, u) == pi
assert atan2(y, oo) == 0
assert atan2(y, -oo)== 2*pi*Heaviside(re(y)) - pi
assert atan2(y, x).rewrite(log) == -I*log((x + I*y)/sqrt(x**2 + y**2))
assert atan2(y, x).rewrite(atan) == 2*atan(y/(x + sqrt(x**2 + y**2)))
ex = atan2(y, x) - arg(x + I*y)
assert ex.subs({x:2, y:3}).rewrite(arg) == 0
assert ex.subs({x:2, y:3*I}).rewrite(arg) == 0
assert ex.subs({x:2*I, y:3}).rewrite(arg) == 0
assert ex.subs({x:2*I, y:3*I}).rewrite(arg) == 0
assert conjugate(atan2(x, y)) == atan2(conjugate(x), conjugate(y))
assert diff(atan2(y, x), x) == -y/(x**2 + y**2)
assert diff(atan2(y, x), y) == x/(x**2 + y**2)
assert simplify(diff(atan2(y, x).rewrite(log), x)) == -y/(x**2 + y**2)
assert simplify(diff(atan2(y, x).rewrite(log), y)) == x/(x**2 + y**2)
assert isinstance(atan2(2, 3*I).n(), atan2)
开发者ID:waytai,项目名称:sympy,代码行数:38,代码来源:test_trigonometric.py
示例17: test_issue936
def test_issue936():
x = Symbol('x')
assert Abs(x).expand(trig=True) == Abs(x)
assert sign(x).expand(trig=True) == sign(x)
assert arg(x).expand(trig=True) == arg(x)
开发者ID:MichaelMayorov,项目名称:sympy,代码行数:5,代码来源:test_complexes.py
示例18: test_issue_4035
def test_issue_4035():
x = Symbol("x")
assert Abs(x).expand(trig=True) == Abs(x)
assert sign(x).expand(trig=True) == sign(x)
assert arg(x).expand(trig=True) == arg(x)
开发者ID:extremeplay,项目名称:sympy,代码行数:5,代码来源:test_complexes.py
示例19: test_arg_rewrite
def test_arg_rewrite():
assert arg(1 + I) == atan2(1, 1)
x = Symbol('x', real=True)
y = Symbol('y', real=True)
assert arg(x + I*y).rewrite(atan2) == atan2(y, x)
开发者ID:A-turing-machine,项目名称:sympy,代码行数:6,代码来源:test_complexes.py
示例20: test_arg
def test_arg():
assert arg(0) == nan
assert arg(1) == 0
assert arg(-1) == pi
assert arg(I) == pi/2
assert arg(-I) == -pi/2
assert arg(1 + I) == pi/4
assert arg(-1 + I) == 3*pi/4
assert arg(1 - I) == -pi/4
f = Function('f')
assert not arg(f(0) + I*f(1)).atoms(re)
p = Symbol('p', positive=True)
assert arg(p) == 0
n = Symbol('n', negative=True)
assert arg(n) == pi
x = Symbol('x')
assert conjugate(arg(x)) == arg(x)
e = p + I*p**2
assert arg(e) == arg(1 + p*I)
# make sure sign doesn't swap
e = -2*p + 4*I*p**2
assert arg(e) == arg(-1 + 2*p*I)
# make sure sign isn't lost
x = symbols('x', real=True) # could be zero
e = x + I*x
assert arg(e) == arg(x*(1 + I))
assert arg(e/p) == arg(x*(1 + I))
e = p*cos(p) + I*log(p)*exp(p)
assert arg(e).args[0] == e
# keep it simple -- let the user do more advanced cancellation
e = (p + 1) + I*(p**2 - 1)
assert arg(e).args[0] == e
f = Function('f')
e = 2*x*(f(0) - 1) - 2*x*f(0)
assert arg(e) == arg(-2*x)
assert arg(f(0)).func == arg and arg(f(0)).args == (f(0),)
开发者ID:A-turing-machine,项目名称:sympy,代码行数:41,代码来源:test_complexes.py
注:本文中的sympy.arg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论