本文整理汇总了Python中sympy.core.basic.C.coth方法的典型用法代码示例。如果您正苦于以下问题:Python C.coth方法的具体用法?Python C.coth怎么用?Python C.coth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.core.basic.C
的用法示例。
在下文中一共展示了C.coth方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eval
# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import coth [as 别名]
def eval(cls, arg):
if arg.is_Number:
if arg is S.NaN:
return S.NaN
if arg is S.Zero:
return S.ComplexInfinity
if arg.could_extract_minus_sign():
return -cls(-arg)
i_coeff = arg.as_coefficient(S.ImaginaryUnit)
if i_coeff is not None:
return -S.ImaginaryUnit * C.coth(i_coeff)
pi_coeff = arg.as_coefficient(S.Pi)
if pi_coeff is not None:
if pi_coeff.is_Integer:
return S.ComplexInfinity
if pi_coeff.is_Rational:
cst_table = {
2 : S.Zero,
3 : 1 / sqrt(3),
4 : S.One,
6 : sqrt(3)
}
try:
result = cst_table[pi_coeff.q]
if (2*pi_coeff.p // pi_coeff.q) % 4 in (1, 3):
return -result
else:
return result
except KeyError:
pass
if arg.is_Add:
x, m = _peeloff_pi(arg)
if m:
if (m*2/S.Pi) % 2 == 0:
return cot(x)
else:
return -tan(x)
if arg.func is acot:
return arg.args[0]
if arg.func is atan:
x = arg.args[0]
return 1 / x
if arg.func is asin:
x = arg.args[0]
return sqrt(1 - x**2) / x
if arg.func is acos:
x = arg.args[0]
return x / sqrt(1 - x**2)
示例2: canonize
# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import coth [as 别名]
def canonize(cls, arg):
if arg.is_Number:
if arg is S.NaN:
return S.NaN
#elif arg is S.Zero:
# return S.ComplexInfinity
elif arg.is_negative:
return -cls(-arg)
else:
i_coeff = arg.as_coefficient(S.ImaginaryUnit)
if i_coeff is not None:
return -S.ImaginaryUnit * C.coth(i_coeff)
else:
pi_coeff = arg.as_coefficient(S.Pi)
if pi_coeff is not None:
#if pi_coeff.is_integer:
# return S.ComplexInfinity
if pi_coeff.is_Rational:
cst_table = {
2 : S.Zero,
3 : 1 / sqrt(3),
4 : S.One,
6 : sqrt(3)
}
try:
result = cst_table[pi_coeff.q]
if (2*pi_coeff.p // pi_coeff.q) % 4 in (1, 3):
return -result
else:
return result
except KeyError:
pass
coeff, terms = arg.as_coeff_terms()
if coeff.is_negative:
return -cls(-arg)
if isinstance(arg, acot):
return arg.args[0]
if isinstance(arg, atan):
x = arg.args[0]
return 1 / x
if isinstance(arg, asin):
x = arg.args[0]
return sqrt(1 - x**2) / x
if isinstance(arg, acos):
x = arg.args[0]
return x / sqrt(1 - x**2)
示例3: eval
# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import coth [as 别名]
def eval(cls, arg):
if arg.is_Number:
if arg is S.NaN:
return S.NaN
if arg is S.Zero:
return S.ComplexInfinity
if arg.could_extract_minus_sign():
return -cls(-arg)
i_coeff = arg.as_coefficient(S.ImaginaryUnit)
if i_coeff is not None:
return -S.ImaginaryUnit * C.coth(i_coeff)
pi_coeff = _pi_coeff(arg, 2)
if pi_coeff is not None:
if pi_coeff.is_integer:
return S.ComplexInfinity
if not pi_coeff.is_Rational:
narg = pi_coeff*S.Pi
if narg != arg:
return cls(narg)
return None
if pi_coeff.is_Rational:
narg = (((pi_coeff + S.Half) % 1) - S.Half)*S.Pi
# see cos() to specify which expressions should be
# expanded automatically in terms of radicals
cresult, sresult = cos(narg), cos(narg-S.Pi/2)
if not isinstance(cresult, cos) \
and not isinstance(sresult, cos):
if sresult == 0:
return S.ComplexInfinity
return cresult / sresult
if narg != arg:
return cls(narg)
if arg.is_Add:
x, m = _peeloff_pi(arg)
if m:
cotm = cot(m)
if cotm == 0:
return -tan(x)
cotx = cot(x)
if cotm is S.ComplexInfinity:
return cotx
if cotm.is_Rational:
return (cotm*cotx - 1) / (cotm + cotx)
return None
if arg.func is acot:
return arg.args[0]
if arg.func is atan:
x = arg.args[0]
return 1 / x
if arg.func is atan2:
y, x = arg.args
return x/y
if arg.func is asin:
x = arg.args[0]
return sqrt(1 - x**2) / x
if arg.func is acos:
x = arg.args[0]
return x / sqrt(1 - x**2)
示例4: eval
# 需要导入模块: from sympy.core.basic import C [as 别名]
# 或者: from sympy.core.basic.C import coth [as 别名]
def eval(cls, arg):
if arg.is_Number:
if arg is S.NaN:
return S.NaN
if arg is S.Zero:
return S.ComplexInfinity
if arg.could_extract_minus_sign():
return -cls(-arg)
i_coeff = arg.as_coefficient(S.ImaginaryUnit)
if i_coeff is not None:
return -S.ImaginaryUnit * C.coth(i_coeff)
pi_coeff = _pi_coeff(arg, 2)
if pi_coeff is not None:
if pi_coeff.is_integer:
return S.ComplexInfinity
if not pi_coeff.is_Rational:
narg = pi_coeff*S.Pi
if narg != arg:
return cls(narg)
return None
cst_table = {
2 : S.Zero,
3 : 1 / sqrt(3),
4 : S.One,
6 : sqrt(3)
}
try:
result = cst_table[pi_coeff.q]
if (2*pi_coeff.p // pi_coeff.q) % 4 in (1, 3):
return -result
else:
return result
except KeyError:
if pi_coeff.p > pi_coeff.q:
p, q = pi_coeff.p % pi_coeff.q, pi_coeff.q
if 2 * p > q:
return -cls(Rational(q - p, q)*S.Pi)
return cls(Rational(p, q)*S.Pi)
else:
newarg = pi_coeff*S.Pi
if newarg != arg:
return cls(newarg)
return None
if arg.is_Add:
x, m = _peeloff_pi(arg)
if m:
if (m*2/S.Pi) % 2 == 0:
return cot(x)
else:
return -tan(x)
if arg.func is acot:
return arg.args[0]
if arg.func is atan:
x = arg.args[0]
return 1 / x
if arg.func is atan2:
y, x = arg.args
return x/y
if arg.func is asin:
x = arg.args[0]
return sqrt(1 - x**2) / x
if arg.func is acos:
x = arg.args[0]
return x / sqrt(1 - x**2)