本文整理汇总了Python中sympy.tan函数的典型用法代码示例。如果您正苦于以下问题:Python tan函数的具体用法?Python tan怎么用?Python tan使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tan函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_minimum
def test_minimum():
x, y = symbols('x y')
assert minimum(sin(x), x) == -S.One
assert minimum(sin(x), x, Interval(1, 4)) == sin(4)
assert minimum(tan(x), x) == -oo
assert minimum(tan(x), x, Interval(-pi/4, pi/4)) == -S.One
assert minimum(sin(x)*cos(x), x, S.Reals) == -S.Half
assert simplify(minimum(sin(x)*cos(x), x, Interval(3*pi/8, 5*pi/8))
) == -sqrt(2)/4
assert minimum((x+3)*(x-2), x) == -S(25)/4
assert minimum((x+3)/(x-2), x, Interval(-5, 0)) == -S(3)/2
assert minimum(x**4-x**3+x**2+10, x) == S(10)
assert minimum(exp(x), x, Interval(-2, oo)) == exp(-2)
assert minimum(log(x) - x, x, S.Reals) == -oo
assert minimum(cos(x), x, Union(Interval(0, 5), Interval(-6, -3))
) == -S.One
assert minimum(cos(x)-sin(x), x, S.Reals) == -sqrt(2)
assert minimum(y, x, S.Reals) == y
raises(ValueError, lambda : minimum(sin(x), x, S.EmptySet))
raises(ValueError, lambda : minimum(log(cos(x)), x, S.EmptySet))
raises(ValueError, lambda : minimum(1/(x**2 + y**2 + 1), x, S.EmptySet))
raises(ValueError, lambda : minimum(sin(x), sin(x)))
raises(ValueError, lambda : minimum(sin(x), x*y, S.EmptySet))
raises(ValueError, lambda : minimum(sin(x), S(1)))
开发者ID:bjodah,项目名称:sympy,代码行数:26,代码来源:test_util.py
示例2: test_ImageSet_simplification
def test_ImageSet_simplification():
from sympy.abc import n, m
assert imageset(Lambda(n, n), S.Integers) == S.Integers
assert imageset(Lambda(n, sin(n)), imageset(Lambda(m, tan(m)), S.Integers)) == imageset(
Lambda(m, sin(tan(m))), S.Integers
)
开发者ID:pabloferz,项目名称:sympy,代码行数:7,代码来源:test_fancysets.py
示例3: test_maximum
def test_maximum():
x, y = symbols('x y')
assert maximum(sin(x), x) == S.One
assert maximum(sin(x), x, Interval(0, 1)) == sin(1)
assert maximum(tan(x), x) == oo
assert maximum(tan(x), x, Interval(-pi/4, pi/4)) == S.One
assert maximum(sin(x)*cos(x), x, S.Reals) == S.Half
assert simplify(maximum(sin(x)*cos(x), x, Interval(3*pi/8, 5*pi/8))
) == sqrt(2)/4
assert maximum((x+3)*(x-2), x) == oo
assert maximum((x+3)*(x-2), x, Interval(-5, 0)) == S(14)
assert maximum((x+3)/(x-2), x, Interval(-5, 0)) == S(2)/7
assert simplify(maximum(-x**4-x**3+x**2+10, x)
) == 41*sqrt(41)/512 + S(5419)/512
assert maximum(exp(x), x, Interval(-oo, 2)) == exp(2)
assert maximum(log(x) - x, x, S.Reals) == -S.One
assert maximum(cos(x), x, Union(Interval(0, 5), Interval(-6, -3))
) == S.One
assert maximum(cos(x)-sin(x), x, S.Reals) == sqrt(2)
assert maximum(y, x, S.Reals) == y
raises(ValueError, lambda : maximum(sin(x), x, S.EmptySet))
raises(ValueError, lambda : maximum(log(cos(x)), x, S.EmptySet))
raises(ValueError, lambda : maximum(1/(x**2 + y**2 + 1), x, S.EmptySet))
raises(ValueError, lambda : maximum(sin(x), sin(x)))
raises(ValueError, lambda : maximum(sin(x), x*y, S.EmptySet))
raises(ValueError, lambda : maximum(sin(x), S(1)))
开发者ID:bjodah,项目名称:sympy,代码行数:27,代码来源:test_util.py
示例4: test_function_range
def test_function_range():
x, y, a, b = symbols('x y a b')
assert function_range(sin(x), x, Interval(-pi/2, pi/2)
) == Interval(-1, 1)
assert function_range(sin(x), x, Interval(0, pi)
) == Interval(0, 1)
assert function_range(tan(x), x, Interval(0, pi)
) == Interval(-oo, oo)
assert function_range(tan(x), x, Interval(pi/2, pi)
) == Interval(-oo, 0)
assert function_range((x + 3)/(x - 2), x, Interval(-5, 5)
) == Union(Interval(-oo, 2/7), Interval(8/3, oo))
assert function_range(1/(x**2), x, Interval(-1, 1)
) == Interval(1, oo)
assert function_range(exp(x), x, Interval(-1, 1)
) == Interval(exp(-1), exp(1))
assert function_range(log(x) - x, x, S.Reals
) == Interval(-oo, -1)
assert function_range(sqrt(3*x - 1), x, Interval(0, 2)
) == Interval(0, sqrt(5))
assert function_range(x*(x - 1) - (x**2 - x), x, S.Reals
) == FiniteSet(0)
assert function_range(x*(x - 1) - (x**2 - x) + y, x, S.Reals
) == FiniteSet(y)
assert function_range(sin(x), x, Union(Interval(-5, -3), FiniteSet(4))
) == Union(Interval(-sin(3), 1), FiniteSet(sin(4)))
assert function_range(cos(x), x, Interval(-oo, -4)
) == Interval(-1, 1)
raises(NotImplementedError, lambda : function_range(
exp(x)*(sin(x) - cos(x))/2 - x, x, S.Reals))
raises(NotImplementedError, lambda : function_range(
log(x), x, S.Integers))
raises(NotImplementedError, lambda : function_range(
sin(x)/2, x, S.Naturals))
开发者ID:certik,项目名称:sympy,代码行数:34,代码来源:test_util.py
示例5: test_tan_rewrite
def test_tan_rewrite():
x = Symbol('x')
neg_exp, pos_exp = exp(-x*I), exp(x*I)
assert tan(x).rewrite(exp) == I*(neg_exp-pos_exp)/(neg_exp+pos_exp)
assert tan(x).rewrite(sin) == 2*sin(x)**2/sin(2*x)
assert tan(x).rewrite(cos) == -cos(x + S.Pi/2)/cos(x)
assert tan(x).rewrite(cot) == 1/cot(x)
开发者ID:haz,项目名称:sympy,代码行数:7,代码来源:test_trigonometric.py
示例6: test_hyper_as_trig
def test_hyper_as_trig():
from sympy.simplify.fu import _osborne as o, _osbornei as i, TR12
eq = sinh(x)**2 + cosh(x)**2
t, f = hyper_as_trig(eq)
assert f(fu(t)) == cosh(2*x)
e, f = hyper_as_trig(tanh(x + y))
assert f(TR12(e)) == (tanh(x) + tanh(y))/(tanh(x)*tanh(y) + 1)
d = Dummy()
assert o(sinh(x), d) == I*sin(x*d)
assert o(tanh(x), d) == I*tan(x*d)
assert o(coth(x), d) == cot(x*d)/I
assert o(cosh(x), d) == cos(x*d)
for func in (sinh, cosh, tanh, coth):
h = func(pi)
assert i(o(h, d), d) == h
# /!\ the _osborne functions are not meant to work
# in the o(i(trig, d), d) direction so we just check
# that they work as they are supposed to work
assert i(cos(x*y), y) == cosh(x)
assert i(sin(x*y), y) == sinh(x)/I
assert i(tan(x*y), y) == tanh(x)/I
assert i(cot(x*y), y) == coth(x)*I
assert i(sec(x*y), y) == 1/cosh(x)
assert i(csc(x*y), y) == I/sinh(x)
开发者ID:AdrianPotter,项目名称:sympy,代码行数:26,代码来源:test_fu.py
示例7: trig_rule
def trig_rule(integral):
integrand, symbol = integral
if isinstance(integrand, sympy.sin) or isinstance(integrand, sympy.cos):
arg = integrand.args[0]
if not isinstance(arg, sympy.Symbol):
return # perhaps a substitution can deal with it
if isinstance(integrand, sympy.sin):
func = 'sin'
else:
func = 'cos'
return TrigRule(func, arg, integrand, symbol)
if isinstance(integrand, sympy.tan):
rewritten = sympy.sin(*integrand.args) / sympy.cos(*integrand.args)
elif isinstance(integrand, sympy.cot):
rewritten = sympy.cos(*integrand.args) / sympy.sin(*integrand.args)
elif isinstance(integrand, sympy.sec):
arg = integrand.args[0]
rewritten = ((sympy.sec(arg)**2 + sympy.tan(arg) * sympy.sec(arg)) /
(sympy.sec(arg) + sympy.tan(arg)))
elif isinstance(integrand, sympy.csc):
arg = integrand.args[0]
rewritten = ((sympy.csc(arg)**2 + sympy.cot(arg) * sympy.csc(arg)) /
(sympy.csc(arg) + sympy.cot(arg)))
return RewriteRule(
rewritten,
integral_steps(rewritten, symbol),
integrand, symbol
)
开发者ID:cstrobach83,项目名称:sympy,代码行数:32,代码来源:manualintegrate.py
示例8: test_heurisch_trigonometric
def test_heurisch_trigonometric():
assert heurisch(sin(x), x) == -cos(x)
assert heurisch(pi*sin(x) + 1, x) == x - pi*cos(x)
assert heurisch(cos(x), x) == sin(x)
assert heurisch(tan(x), x) in [
log(1 + tan(x)**2)/2,
log(tan(x) + I) + I*x,
log(tan(x) - I) - I*x,
]
assert heurisch(sin(x)*sin(y), x) == -cos(x)*sin(y)
assert heurisch(sin(x)*sin(y), y) == -cos(y)*sin(x)
# gives sin(x) in answer when run via setup.py and cos(x) when run via py.test
assert heurisch(sin(x)*cos(x), x) in [sin(x)**2 / 2, -cos(x)**2 / 2]
assert heurisch(cos(x)/sin(x), x) == log(sin(x))
assert heurisch(x*sin(7*x), x) == sin(7*x) / 49 - x*cos(7*x) / 7
assert heurisch(1/pi/4 * x**2*cos(x), x) == 1/pi/4*(x**2*sin(x) -
2*sin(x) + 2*x*cos(x))
assert heurisch(acos(x/4) * asin(x/4), x) == 2*x - (sqrt(16 - x**2))*asin(x/4) \
+ (sqrt(16 - x**2))*acos(x/4) + x*asin(x/4)*acos(x/4)
assert heurisch(sin(x)/(cos(x)**2+1), x) == -atan(cos(x)) #fixes issue 13723
assert heurisch(1/(cos(x)+2), x) == 2*sqrt(3)*atan(sqrt(3)*tan(x/2)/3)/3
assert heurisch(2*sin(x)*cos(x)/(sin(x)**4 + 1), x) == atan(sqrt(2)*sin(x)
- 1) - atan(sqrt(2)*sin(x) + 1)
assert heurisch(1/cosh(x), x) == 2*atan(tanh(x/2))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:31,代码来源:test_heurisch.py
示例9: test_evalc
def test_evalc():
x = Symbol("x", real=True)
y = Symbol("y", real=True)
z = Symbol("z")
assert ((x+I*y)**2).expand(complex=True) == x**2+2*I*x*y - y**2
assert expand_complex(z**(2*I)) == I*im(z**(2*I)) + re(z**(2*I))
assert exp(I*x) != cos(x)+I*sin(x)
assert exp(I*x).expand(complex=True) == cos(x)+I*sin(x)
assert exp(I*x+y).expand(complex=True) == exp(y)*cos(x)+I*sin(x)*exp(y)
assert sin(I*x).expand(complex=True) == I * sinh(x)
assert sin(x+I*y).expand(complex=True) == sin(x)*cosh(y) + \
I * sinh(y) * cos(x)
assert cos(I*x).expand(complex=True) == cosh(x)
assert cos(x+I*y).expand(complex=True) == cos(x)*cosh(y) - \
I * sinh(y) * sin(x)
assert tan(I*x).expand(complex=True) == tanh(x) * I
assert tan(x+I*y).expand(complex=True) == \
((sin(x)*cos(x) + I*cosh(y)*sinh(y)) / (cos(x)**2 + sinh(y)**2)).expand()
assert sinh(I*x).expand(complex=True) == I * sin(x)
assert sinh(x+I*y).expand(complex=True) == sinh(x)*cos(y) + \
I * sin(y) * cosh(x)
assert cosh(I*x).expand(complex=True) == cos(x)
assert cosh(x+I*y).expand(complex=True) == cosh(x)*cos(y) + \
I * sin(y) * sinh(x)
assert tanh(I*x).expand(complex=True) == tan(x) * I
assert tanh(x+I*y).expand(complex=True) == \
((sinh(x)*cosh(x) + I*cos(y)*sin(y)) / (sinh(x)**2 + cos(y)**2)).expand()
开发者ID:BDGLunde,项目名称:sympy,代码行数:34,代码来源:test_complex.py
示例10: test_periodicity
def test_periodicity():
x = Symbol('x')
y = Symbol('y')
assert periodicity(sin(2*x), x) == pi
assert periodicity((-2)*tan(4*x), x) == pi/4
assert periodicity(sin(x)**2, x) == 2*pi
assert periodicity(3**tan(3*x), x) == pi/3
assert periodicity(tan(x)*cos(x), x) == 2*pi
assert periodicity(sin(x)**(tan(x)), x) == 2*pi
assert periodicity(tan(x)*sec(x), x) == 2*pi
assert periodicity(sin(2*x)*cos(2*x) - y, x) == pi/2
assert periodicity(tan(x) + cot(x), x) == pi
assert periodicity(sin(x) - cos(2*x), x) == 2*pi
assert periodicity(sin(x) - 1, x) == 2*pi
assert periodicity(sin(4*x) + sin(x)*cos(x), x) == pi
assert periodicity(exp(sin(x)), x) == 2*pi
assert periodicity(log(cot(2*x)) - sin(cos(2*x)), x) == pi
assert periodicity(sin(2*x)*exp(tan(x) - csc(2*x)), x) == pi
assert periodicity(cos(sec(x) - csc(2*x)), x) == 2*pi
assert periodicity(tan(sin(2*x)), x) == pi
assert periodicity(2*tan(x)**2, x) == pi
assert periodicity(sin(x)**2 + cos(x)**2, x) == S.Zero
assert periodicity(tan(x), y) == S.Zero
assert periodicity(exp(x), x) is None
assert periodicity(log(x), x) is None
assert periodicity(exp(x)**sin(x), x) is None
assert periodicity(sin(x)**y, y) is None
开发者ID:Salmista-94,项目名称:sympy,代码行数:30,代码来源:test_util.py
示例11: __init__
def __init__(self, dt, wheelbase):
EKF.__init__(self, 3, 2, 2)
self.dt = dt
self.wheelbase = wheelbase
a, x, y, v, w, theta, time = symbols(
'a, x, y, v, w, theta, t')
d = v*time
beta = (d/w)*sympy.tan(a)
r = w/sympy.tan(a)
self.fxu = Matrix([[x-r*sympy.sin(theta)+r*sympy.sin(theta+beta)],
[y+r*sympy.cos(theta)-r*sympy.cos(theta+beta)],
[theta+beta]])
self.F_j = self.fxu.jacobian(Matrix([x, y, theta]))
self.V_j = self.fxu.jacobian(Matrix([v, a]))
self.subs = {x: 0, y: 0, v:0, a:0, time:dt, w:wheelbase, theta:0}
self.x_x = x
self.x_y = y
self.v = v
self.a = a
self.theta = theta
开发者ID:XNShen,项目名称:Kalman-and-Bayesian-Filters-in-Python,代码行数:26,代码来源:ekf4.py
示例12: test_tanh
def test_tanh():
x, y = symbols('xy')
k = Symbol('k', integer=True)
assert tanh(nan) == nan
assert tanh(oo) == 1
assert tanh(-oo) == -1
assert tanh(0) == 0
assert tanh(1) == tanh(1)
assert tanh(-1) == -tanh(1)
assert tanh(x) == tanh(x)
assert tanh(-x) == -tanh(x)
assert tanh(pi) == tanh(pi)
assert tanh(-pi) == -tanh(pi)
assert tanh(2**1024 * E) == tanh(2**1024 * E)
assert tanh(-2**1024 * E) == -tanh(2**1024 * E)
assert tanh(pi*I) == 0
assert tanh(-pi*I) == 0
assert tanh(2*pi*I) == 0
assert tanh(-2*pi*I) == 0
assert tanh(-3*10**73*pi*I) == 0
assert tanh(7*10**103*pi*I) == 0
assert tanh(pi*I/2) == tanh(pi*I/2)
assert tanh(-pi*I/2) == -tanh(pi*I/2)
assert tanh(5*pi*I/2) == tanh(5*pi*I/2)
assert tanh(7*pi*I/2) == tanh(7*pi*I/2)
assert tanh(pi*I/3) == sqrt(3)*I
assert tanh(-2*pi*I/3) == sqrt(3)*I
assert tanh(pi*I/4) == I
assert tanh(-pi*I/4) == -I
assert tanh(17*pi*I/4) == I
assert tanh(-3*pi*I/4) == I
assert tanh(pi*I/6) == I/sqrt(3)
assert tanh(-pi*I/6) == -I/sqrt(3)
assert tanh(7*pi*I/6) == I/sqrt(3)
assert tanh(-5*pi*I/6) == I/sqrt(3)
assert tanh(pi*I/105) == tan(pi/105)*I
assert tanh(-pi*I/105) == -tan(pi/105)*I
assert tanh(2 + 3*I) == tanh(2 + 3*I)
assert tanh(x*I) == tan(x)*I
assert tanh(k*pi*I) == 0
assert tanh(17*k*pi*I) == 0
assert tanh(k*pi*I/2) == tan(k*pi/2)*I
开发者ID:Aang,项目名称:sympy,代码行数:60,代码来源:test_hyperbolic.py
示例13: test_issue_2033
def test_issue_2033():
r, t = symbols("r,t")
assert solve([r - x ** 2 - y ** 2, tan(t) - y / x], [x, y]) == [
(-sqrt(r * sin(t) ** 2) / tan(t), -sqrt(r * sin(t) ** 2)),
(sqrt(r * sin(t) ** 2) / tan(t), sqrt(r * sin(t) ** 2)),
]
assert solve([exp(x) - sin(y), 1 / y - 3], [x, y]) == [(log(sin(S(1) / 3)), S(1) / 3)]
assert solve([exp(x) - sin(y), 1 / exp(y) - 3], [x, y]) == [(log(-sin(log(3))), -log(3))]
assert solve([exp(x) - sin(y), y ** 2 - 4], [x, y]) == [(log(-sin(2)), -2), (log(sin(2)), 2)]
eqs = [exp(x) ** 2 - sin(y) + z ** 2, 1 / exp(y) - 3]
assert solve(eqs) == [
{x: log(-sqrt(-z ** 2 - sin(log(3)))), y: -log(3)},
{x: log(sqrt(-z ** 2 - sin(log(3)))), y: -log(3)},
]
assert solve(eqs, x, z) == [{x: log(-sqrt(-z ** 2 + sin(y)))}, {x: log(sqrt(-z ** 2 + sin(y)))}]
assert solve(eqs, x, y) == [
(log(-sqrt(-z ** 2 - sin(log(3)))), -log(3)),
(log(sqrt(-z ** 2 - sin(log(3)))), -log(3)),
]
assert solve(eqs, y, z) == [(-log(3), -sqrt(-exp(2 * x) - sin(log(3)))), (-log(3), sqrt(-exp(2 * x) - sin(log(3))))]
eqs = [exp(x) ** 2 - sin(y) + z, 1 / exp(y) - 3]
assert solve(eqs) == [{x: log(-sqrt(-z - sin(log(3)))), y: -log(3)}, {x: log(sqrt(-z - sin(log(3)))), y: -log(3)}]
assert solve(eqs, x, z) == [{x: log(-sqrt(-z + sin(y)))}, {x: log(sqrt(-z + sin(y)))}]
assert solve(eqs, x, y) == [(log(-sqrt(-z - sin(log(3)))), -log(3)), (log(sqrt(-z - sin(log(3)))), -log(3))]
assert solve(eqs, z, y) == [(-exp(2 * x) - sin(log(3)), -log(3))]
assert solve((sqrt(x ** 2 + y ** 2) - sqrt(10), x + y - 4)) == [{x: 1, y: 3}, {x: 3, y: 1}]
assert solve((sqrt(x ** 2 + y ** 2) - sqrt(10), x + y - 4), x, y) == [(1, 3), (3, 1)]
开发者ID:vipulnsward,项目名称:sympy,代码行数:27,代码来源:test_solvers.py
示例14: newton
def newton():
x1 = Symbol("x1")
y1 = Symbol("y1")
m = 0.2
a = 0.7
e = 0.0001
f1 = tan(x1 * y1 + m) - x1
f2 = a * x1 ** 2 + 2 * y1 ** 2 - 1
y11 = diff(f1, x1)
y12 = diff(f1, y1)
y21 = diff(f2, x1)
y22 = diff(f2, y1)
j = Matrix([[y11, y12], [y21, y22]])
j1 = j.inv()
x0 = 0.75
y0 = 0.4
xn = x0 - j1[0, 0].subs(x1, x0).subs(y1, y0) * f1.subs(x1, x0).subs(y1, y0)
- j1[0, 1].subs(x1, x0).subs(y1, y0) * f2.subs(x1, x0).subs(y1, y0)
yn = y0 - j1[1, 0].subs(x1, x0).subs(y1, y0) * f1.subs(x1, x0).subs(y1, y0)
- j1[1, 1].subs(x1, x0).subs(y1, y0) * f2.subs(x1, x0).subs(y1, y0)
count2 = 0
while (abs(xn - x0) > e) or (abs(yn - y0) > e):
x0 = xn
y0 = yn
calcul = j1[0, 0].subs(x1, x0).subs(y1, y0) * f1.subs(x1, x0).subs(y1, y0) - j1[0, 1].subs(x1, x0).subs(y1, y0) * f2.subs(x1, x0).subs(y1, y0)
xn = x0 - calcul
yn = y0 - j1[1, 0].subs(x1, x0).subs(y1, y0) * f1.subs(x1, x0).subs(y1, y0) - j1[1, 1].subs(x1, x0).subs(y1, y0) * f2.subs(x1, x0).subs(y1, y0)
count2 += 1
print("x = ", xn, " ", "y = ", yn, " - ", count2, " iterations")
print("graph processing...")
plot_implicit(Or(Eq(a * x1 ** 2 + 2 * y1 ** 2, 1), Eq(tan(x1 * y1 + m) - x1, 0)), (x1, -5, 5), (y1, -5, 5))
开发者ID:keipa,项目名称:bsuir-labs,代码行数:32,代码来源:main.py
示例15: sp_derive
def sp_derive():
import sympy as sp
vars = 'G_s, s_n, s_p_n, w_n, dw_n, ds_n, G_s, G_w, c, phi'
syms = sp.symbols(vars)
for var, sym in zip(vars.split(','), syms):
globals()[var.strip()] = sym
s_n1 = s_n + ds_n
w_n1 = w_n + dw_n
tau_trial = G_s * (s_n1 - s_p_n)
print 'diff', sp.diff(tau_trial, ds_n)
print tau_trial
sig_n1 = G_w * w_n1
print sig_n1
tau_fr = (c + sig_n1 * sp.tan(phi)) * sp.Heaviside(sig_n1 - c / sp.tan(phi))
print tau_fr
d_tau_fr = sp.diff(tau_fr, dw_n)
print d_tau_fr
f_trial = sp.abs(tau_trial) - tau_fr
print f_trial
d_gamma = f_trial / G_s
print 'd_gamma'
sp.pretty_print(d_gamma)
print 'd_gamma_s'
sp.pretty_print(sp.diff(d_gamma, ds_n))
print 'tau_n1'
tau_n1 = sp.simplify(tau_trial - d_gamma * G_s * sp.sign(tau_trial))
sp.pretty_print(tau_n1)
print 'dtau_n1_w'
dtau_n1_w = sp.diff(tau_n1, dw_n)
sp.pretty_print(dtau_n1_w)
print 'dtau_n1_s'
dtau_n1_s = sp.diff(d_gamma * sp.sign(tau_trial), ds_n)
print dtau_n1_s
s_p_n1 = s_p_n + d_gamma * sp.sign(tau_trial)
print s_p_n1
开发者ID:sarosh-quraishi,项目名称:simvisage,代码行数:59,代码来源:mats1D5_pressure_sensitive.py
示例16: test_basic1
def test_basic1():
assert limit(x, x, oo) == oo
assert limit(x, x, -oo) == -oo
assert limit(-x, x, oo) == -oo
assert limit(x**2, x, -oo) == oo
assert limit(-x**2, x, oo) == -oo
assert limit(x*log(x), x, 0, dir="+") == 0
assert limit(1/x, x, oo) == 0
assert limit(exp(x), x, oo) == oo
assert limit(-exp(x), x, oo) == -oo
assert limit(exp(x)/x, x, oo) == oo
assert limit(1/x - exp(-x), x, oo) == 0
assert limit(x + 1/x, x, oo) == oo
assert limit(x - x**2, x, oo) == -oo
assert limit((1 + x)**(1 + sqrt(2)), x, 0) == 1
assert limit((1 + x)**oo, x, 0) == oo
assert limit((1 + x)**oo, x, 0, dir='-') == 0
assert limit((1 + x + y)**oo, x, 0, dir='-') == (1 + y)**(oo)
assert limit(y/x/log(x), x, 0) == -y*oo
assert limit(cos(x + y)/x, x, 0) == sign(cos(y))*oo
raises(NotImplementedError, lambda: limit(Sum(1/x, (x, 1, y)) -
log(y), y, oo))
assert limit(Sum(1/x, (x, 1, y)) - 1/y, y, oo) == Sum(1/x, (x, 1, oo))
assert limit(gamma(1/x + 3), x, oo) == 2
assert limit(S.NaN, x, -oo) == S.NaN
assert limit(Order(2)*x, x, S.NaN) == S.NaN
assert limit(Sum(1/x, (x, 1, y)) - 1/y, y, oo) == Sum(1/x, (x, 1, oo))
assert limit(gamma(1/x + 3), x, oo) == 2
assert limit(S.NaN, x, -oo) == S.NaN
assert limit(Order(2)*x, x, S.NaN) == S.NaN
assert limit(1/(x - 1), x, 1, dir="+") == oo
assert limit(1/(x - 1), x, 1, dir="-") == -oo
assert limit(1/(5 - x)**3, x, 5, dir="+") == -oo
assert limit(1/(5 - x)**3, x, 5, dir="-") == oo
assert limit(1/sin(x), x, pi, dir="+") == -oo
assert limit(1/sin(x), x, pi, dir="-") == oo
assert limit(1/cos(x), x, pi/2, dir="+") == -oo
assert limit(1/cos(x), x, pi/2, dir="-") == oo
assert limit(1/tan(x**3), x, (2*pi)**(S(1)/3), dir="+") == oo
assert limit(1/tan(x**3), x, (2*pi)**(S(1)/3), dir="-") == -oo
assert limit(1/cot(x)**3, x, (3*pi/2), dir="+") == -oo
assert limit(1/cot(x)**3, x, (3*pi/2), dir="-") == oo
# approaching 0
# from dir="+"
assert limit(1 + 1/x, x, 0) == oo
# from dir='-'
# Add
assert limit(1 + 1/x, x, 0, dir='-') == -oo
# Pow
assert limit(x**(-2), x, 0, dir='-') == oo
assert limit(x**(-3), x, 0, dir='-') == -oo
assert limit(1/sqrt(x), x, 0, dir='-') == (-oo)*I
assert limit(x**2, x, 0, dir='-') == 0
assert limit(sqrt(x), x, 0, dir='-') == 0
assert limit(x**-pi, x, 0, dir='-') == zoo
assert limit((1 + cos(x))**oo, x, 0) == oo
开发者ID:FireJade,项目名称:sympy,代码行数:57,代码来源:test_limits.py
示例17: test_basic1
def test_basic1():
assert limit(x, x, oo) == oo
assert limit(x, x, -oo) == -oo
assert limit(-x, x, oo) == -oo
assert limit(x**2, x, -oo) == oo
assert limit(-x**2, x, oo) == -oo
assert limit(x*log(x), x, 0, dir="+") == 0
assert limit(1/x, x, oo) == 0
assert limit(exp(x), x, oo) == oo
assert limit(-exp(x), x, oo) == -oo
assert limit(exp(x)/x, x, oo) == oo
assert limit(1/x - exp(-x), x, oo) == 0
assert limit(x + 1/x, x, oo) == oo
assert limit(x - x**2, x, oo) == -oo
assert limit((1 + x)**(1 + sqrt(2)), x, 0) == 1
assert limit((1 + x)**oo, x, 0) == oo
assert limit((1 + x)**oo, x, 0, dir='-') == 0
assert limit((1 + x + y)**oo, x, 0, dir='-') == (1 + y)**(oo)
assert limit(y/x/log(x), x, 0) == -oo*sign(y)
assert limit(cos(x + y)/x, x, 0) == sign(cos(y))*oo
assert limit(gamma(1/x + 3), x, oo) == 2
assert limit(S.NaN, x, -oo) == S.NaN
assert limit(Order(2)*x, x, S.NaN) == S.NaN
assert limit(1/(x - 1), x, 1, dir="+") == oo
assert limit(1/(x - 1), x, 1, dir="-") == -oo
assert limit(1/(5 - x)**3, x, 5, dir="+") == -oo
assert limit(1/(5 - x)**3, x, 5, dir="-") == oo
assert limit(1/sin(x), x, pi, dir="+") == -oo
assert limit(1/sin(x), x, pi, dir="-") == oo
assert limit(1/cos(x), x, pi/2, dir="+") == -oo
assert limit(1/cos(x), x, pi/2, dir="-") == oo
assert limit(1/tan(x**3), x, (2*pi)**(S(1)/3), dir="+") == oo
assert limit(1/tan(x**3), x, (2*pi)**(S(1)/3), dir="-") == -oo
assert limit(1/cot(x)**3, x, (3*pi/2), dir="+") == -oo
assert limit(1/cot(x)**3, x, (3*pi/2), dir="-") == oo
# test bi-directional limits
assert limit(sin(x)/x, x, 0, dir="+-") == 1
assert limit(x**2, x, 0, dir="+-") == 0
assert limit(1/x**2, x, 0, dir="+-") == oo
# test failing bi-directional limits
raises(ValueError, lambda: limit(1/x, x, 0, dir="+-"))
# approaching 0
# from dir="+"
assert limit(1 + 1/x, x, 0) == oo
# from dir='-'
# Add
assert limit(1 + 1/x, x, 0, dir='-') == -oo
# Pow
assert limit(x**(-2), x, 0, dir='-') == oo
assert limit(x**(-3), x, 0, dir='-') == -oo
assert limit(1/sqrt(x), x, 0, dir='-') == (-oo)*I
assert limit(x**2, x, 0, dir='-') == 0
assert limit(sqrt(x), x, 0, dir='-') == 0
assert limit(x**-pi, x, 0, dir='-') == oo*sign((-1)**(-pi))
assert limit((1 + cos(x))**oo, x, 0) == oo
开发者ID:asmeurer,项目名称:sympy,代码行数:57,代码来源:test_limits.py
示例18: test_csc
def test_csc():
x = symbols('x', real=True)
z = symbols('z')
# https://github.com/sympy/sympy/issues/6707
cosecant = csc('x')
alternate = 1/sin('x')
assert cosecant.equals(alternate) == True
assert alternate.equals(cosecant) == True
assert csc.nargs == FiniteSet(1)
assert csc(0) == zoo
assert csc(pi) == zoo
assert csc(pi/2) == 1
assert csc(-pi/2) == -1
assert csc(pi/6) == 2
assert csc(pi/3) == 2*sqrt(3)/3
assert csc(5*pi/2) == 1
assert csc(9*pi/7) == -csc(2*pi/7)
assert csc(I) == -I/sinh(1)
assert csc(x*I) == -I/sinh(x)
assert csc(-x) == -csc(x)
assert csc(x).rewrite(exp) == 2*I/(exp(I*x) - exp(-I*x))
assert csc(x).rewrite(sin) == 1/sin(x)
assert csc(x).rewrite(cos) == csc(x)
assert csc(x).rewrite(tan) == (tan(x/2)**2 + 1)/(2*tan(x/2))
assert csc(z).conjugate() == csc(conjugate(z))
assert (csc(z).as_real_imag() ==
(sin(re(z))*cosh(im(z))/(sin(re(z))**2*cosh(im(z))**2 +
cos(re(z))**2*sinh(im(z))**2),
-cos(re(z))*sinh(im(z))/(sin(re(z))**2*cosh(im(z))**2 +
cos(re(z))**2*sinh(im(z))**2)))
assert csc(x).expand(trig=True) == 1/sin(x)
assert csc(2*x).expand(trig=True) == 1/(2*sin(x)*cos(x))
assert csc(x).is_real == True
assert csc(z).is_real == None
assert csc(x).as_leading_term() == csc(x)
assert csc(0).is_bounded == False
assert csc(x).is_bounded == None
assert csc(pi/2).is_bounded == True
assert series(csc(x), x, x0=pi/2, n=6) == \
1 + (x - pi/2)**2/2 + 5*(x - pi/2)**4/24 + O((x - pi/2)**6, (x, pi/2))
assert series(csc(x), x, x0=0, n=6) == \
1/x + x/6 + 7*x**3/360 + 31*x**5/15120 + O(x**6)
assert csc(x).diff(x) == -cot(x)*csc(x)
开发者ID:Eskatrem,项目名称:sympy,代码行数:56,代码来源:test_trigonometric.py
示例19: test_sec
def test_sec():
x = symbols('x', real=True)
z = symbols('z')
assert sec.nargs == FiniteSet(1)
assert sec(0) == 1
assert sec(pi) == -1
assert sec(pi/2) == zoo
assert sec(-pi/2) == zoo
assert sec(pi/6) == 2*sqrt(3)/3
assert sec(pi/3) == 2
assert sec(5*pi/2) == zoo
assert sec(9*pi/7) == -sec(2*pi/7)
assert sec(I) == 1/cosh(1)
assert sec(x*I) == 1/cosh(x)
assert sec(-x) == sec(x)
assert sec(x).rewrite(exp) == 1/(exp(I*x)/2 + exp(-I*x)/2)
assert sec(x).rewrite(sin) == sec(x)
assert sec(x).rewrite(cos) == 1/cos(x)
assert sec(x).rewrite(tan) == (tan(x/2)**2 + 1)/(-tan(x/2)**2 + 1)
assert sec(x).rewrite(pow) == sec(x)
assert sec(x).rewrite(sqrt) == sec(x)
assert sec(z).conjugate() == sec(conjugate(z))
assert (sec(z).as_real_imag() ==
(cos(re(z))*cosh(im(z))/(sin(re(z))**2*sinh(im(z))**2 +
cos(re(z))**2*cosh(im(z))**2),
sin(re(z))*sinh(im(z))/(sin(re(z))**2*sinh(im(z))**2 +
cos(re(z))**2*cosh(im(z))**2)))
assert sec(x).expand(trig=True) == 1/cos(x)
assert sec(2*x).expand(trig=True) == 1/(2*cos(x)**2 - 1)
assert sec(x).is_real == True
assert sec(z).is_real == None
assert sec(x).as_leading_term() == sec(x)
assert sec(0).is_bounded == True
assert sec(x).is_bounded == None
assert sec(pi/2).is_bounded == False
assert series(sec(x), x, x0=0, n=6) == 1 + x**2/2 + 5*x**4/24 + O(x**6)
# https://github.com/sympy/sympy/issues/7166
assert series(sqrt(sec(x))) == 1 + x**2/4 + 7*x**4/96 + O(x**6)
assert sec(x).diff(x) == tan(x)*sec(x)
# Taylor Term checks
assert sec(z).taylor_term(4, z) == 5*z**4/24
assert sec(z).taylor_term(6, z) == 61*z**6/720
assert sec(z).taylor_term(5, z) == 0
开发者ID:waytai,项目名称:sympy,代码行数:56,代码来源:test_trigonometric.py
示例20: test_manualintegrate_trigonometry
def test_manualintegrate_trigonometry():
assert manualintegrate(sin(x), x) == -cos(x)
assert manualintegrate(tan(x), x) == -log(cos(x))
assert manualintegrate(sec(x), x) == log(sec(x) + tan(x))
assert manualintegrate(csc(x), x) == -log(csc(x) + cot(x))
assert manualintegrate(sin(x) * cos(x), x) in [sin(x) ** 2 / 2, -cos(x)**2 / 2]
assert manualintegrate(-sec(x) * tan(x), x) == -sec(x)
assert manualintegrate(csc(x) * cot(x), x) == -csc(x)
开发者ID:cstrobach83,项目名称:sympy,代码行数:10,代码来源:test_manual.py
注:本文中的sympy.tan函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论