本文整理汇总了Python中sympy.core.C.log方法的典型用法代码示例。如果您正苦于以下问题:Python C.log方法的具体用法?Python C.log怎么用?Python C.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.core.C
的用法示例。
在下文中一共展示了C.log方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: eval
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
def eval(cls, arg):
arg = sympify(arg)
if arg.is_Number:
if arg is S.NaN:
return S.NaN
elif arg is S.Infinity:
return S.Infinity
elif arg is S.NegativeInfinity:
return S.NegativeInfinity
elif arg is S.Zero:
return S.Zero
elif arg is S.One:
return C.log(sqrt(2) + 1)
elif arg is S.NegativeOne:
return C.log(sqrt(2) - 1)
elif arg.is_negative:
return -cls(-arg)
else:
if arg is S.ComplexInfinity:
return S.ComplexInfinity
i_coeff = arg.as_coefficient(S.ImaginaryUnit)
if i_coeff is not None:
return S.ImaginaryUnit * C.asin(i_coeff)
else:
if _coeff_isneg(arg):
return -cls(-arg)
示例2: eval
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
def eval(cls, arg):
arg = sympify(arg)
if arg.is_Number:
if arg is S.NaN:
return S.NaN
elif arg is S.Infinity:
return S.Infinity
elif arg is S.NegativeInfinity:
return S.NegativeInfinity
elif arg is S.Zero:
return S.Zero
elif arg is S.One:
return C.log(2**S.Half + 1)
elif arg is S.NegativeOne:
return C.log(2**S.Half - 1)
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.asin(i_coeff)
else:
if arg.as_coeff_mul()[0].is_negative:
return -cls(-arg)
示例3: eval
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
def eval(cls, s):
if s == 1:
return C.log(2)
z = zeta(s)
if not z.has(zeta):
return (1 - 2**(1 - s))*z
示例4: _eval_integral
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
#.........这里部分代码省略.........
# g(x) = const
if g is S.One and not meijerg:
parts.append(coeff*x)
continue
# g(x) = expr + O(x**n)
order_term = g.getO()
if order_term is not None:
h = self._eval_integral(g.removeO(), x)
if h is not None:
h_order_expr = self._eval_integral(order_term.expr, x)
if h_order_expr is not None:
h_order_term = order_term.func(h_order_expr, *order_term.variables)
parts.append(coeff*(h + h_order_term))
continue
# NOTE: if there is O(x**n) and we fail to integrate then there is
# no point in trying other methods because they will fail anyway.
return None
# c
# g(x) = (a*x+b)
if g.is_Pow and not g.exp.has(x) and not meijerg:
a = Wild('a', exclude=[x])
b = Wild('b', exclude=[x])
M = g.base.match(a*x + b)
if M is not None:
if g.exp == -1:
h = C.log(g.base)
else:
h = g.base**(g.exp + 1) / (g.exp + 1)
parts.append(coeff * h / M[a])
continue
# poly(x)
# g(x) = -------
# poly(x)
if g.is_rational_function(x) and not meijerg:
parts.append(coeff * ratint(g, x))
continue
if not meijerg:
# g(x) = Mul(trig)
h = trigintegrate(g, x)
if h is not None:
parts.append(coeff * h)
continue
# g(x) has at least a DiracDelta term
h = deltaintegrate(g, x)
if h is not None:
parts.append(coeff * h)
continue
if not meijerg:
# fall back to the more general algorithm
try:
h = heurisch(g, x, hints=[])
except PolynomialError:
# XXX: this exception means there is a bug in the
示例5: eval
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
def eval(cls, s):
if s == 1:
return C.log(2)
else:
return (1-2**(1-s)) * zeta(s)
示例6: fdiff
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
def fdiff(self, argindex=1):
n = self.args[0]
return catalan(n)*(C.polygamma(0, n + Rational(1, 2)) - C.polygamma(0, n + 2) + C.log(4))
示例7: _eval_integral
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
def _eval_integral(self, f, x):
"""Calculate the anti-derivative to the function f(x).
This is a powerful function that should in theory be able to integrate
everything that can be integrated. If you find something, that it
doesn't, it is easy to implement it.
(1) Simple heuristics (based on pattern matching and integral table):
- most frequently used functions (e.g. polynomials)
- functions non-integrable by any of the following algorithms (e.g.
exp(-x**2))
(2) Integration of rational functions:
(a) using apart() - apart() is full partial fraction decomposition
procedure based on Bronstein-Salvy algorithm. It gives formal
decomposition with no polynomial factorization at all (so it's fast
and gives the most general results). However it needs much better
implementation of RootsOf class (if fact any implementation).
(b) using Trager's algorithm - possibly faster than (a) but needs
implementation :)
(3) Whichever implementation of pmInt (Mateusz, Kirill's or a
combination of both).
- this way we can handle efficiently huge class of elementary and
special functions
(4) Recursive Risch algorithm as described in Bronstein's integration
tutorial.
- this way we can handle those integrable functions for which (3)
fails
(5) Powerful heuristics based mostly on user defined rules.
- handle complicated, rarely used cases
"""
# if it is a poly(x) then let the polynomial integrate itself (fast)
#
# It is important to make this check first, otherwise the other code
# will return a sympy expression instead of a Polynomial.
#
# see Polynomial for details.
if isinstance(f, Poly):
return f.integrate(x)
# Piecewise antiderivatives need to call special integrate.
if f.func is Piecewise:
return f._eval_integral(x)
# let's cut it short if `f` does not depend on `x`
if not f.has(x):
return f*x
# try to convert to poly(x) and then integrate if successful (fast)
poly = f.as_poly(x)
if poly is not None:
return poly.integrate(x).as_basic()
# since Integral(f=g1+g2+...) == Integral(g1) + Integral(g2) + ...
# we are going to handle Add terms separately,
# if `f` is not Add -- we only have one term
parts = []
for g in make_list(f, Add):
coeff, g = g.as_independent(x)
# g(x) = const
if g is S.One:
parts.append(coeff * x)
continue
# c
# g(x) = (a*x+b)
if g.is_Pow and not g.exp.has(x):
a = Wild('a', exclude=[x])
b = Wild('b', exclude=[x])
M = g.base.match(a*x + b)
if M is not None:
if g.exp == -1:
h = C.log(g.base)
else:
h = g.base**(g.exp+1) / (g.exp+1)
parts.append(coeff * h / M[a])
continue
# poly(x)
# g(x) = -------
# poly(x)
if g.is_rational_function(x):
parts.append(coeff * ratint(g, x))
continue
# g(x) = Mul(trig)
#.........这里部分代码省略.........
示例8: canonize
# 需要导入模块: from sympy.core import C [as 别名]
# 或者: from sympy.core.C import log [as 别名]
def canonize(cls, s):
if s == 1:
return C.log(2)
else:
return (1-2**(1-s)) * zeta(s)