用途和当前限制¶
集成¶
可以通过以下步骤使用全纯函数进行积分:
将被积函数转换为正则函数。
现在将函数的完整表示形式进行整合。
将积分转换回表达式。
示例¶
>>> from sympy.abc import x, a
>>> from sympy import sin
>>> from sympy.holonomic import expr_to_holonomic
>>> expr_to_holonomic(1/(x**2+a), x).integrate(x).to_expr()
atan(x/sqrt(a))/sqrt(a)
>>> expr_to_holonomic(sin(x)/x).integrate(x).to_expr()
Si(x)
如第一个示例所示,我们将函数转换为完整形式,对其结果进行了积分,然后将其转换回符号表达式。
限制¶
转换为表达式并不总是可能的。holonomic 函数应在 x0
处具有超几何级数。
2. Implementation of converting to holonomic sequence currently doesn’t support
Frobenius method
when the solutions need to have \(\log\) terms. This happens
when at least one pair of the roots of the indicial equation differ by an integer and
frobenius method yields linearly dependent series solutions. Since we use this while converting
to expressions, sometimes to_expr()
fails.
3. There doesn’t seem to be a way for computing indefinite integrals, so integrate()
basically computes \(\int_{x_0}^{x} f(x)dx\) if no limits are given, where \(x_0\) is the point at
which initial conditions for the integrand are stored. Sometimes this gives an additional constant in the result.
For instance:
>>> expr_to_holonomic(sin(x)).integrate(x).to_expr()
1 - cos(x)
>>> sin(x).integrate(x)
-cos(x)
\(\sin(x)\) 的不定积分为 \(-\cos(x)\)。但输出结果是 \(-\cos(x) + 1\),即 \(\int_{0}^{x} sin(x)dx\)。虽然两者都被认为是正确的,但 \(-\cos(x)\) 更简单。