Sympy 积分的分步解法 [英] Sympy step by step solution of integrals

查看:35
本文介绍了Sympy 积分的分步解法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 sympy 的文档中 http://docs.sympy.org/latest/modules/integrals/integrals.html 我们可以阅读:

In doc of sympy http://docs.sympy.org/latest/modules/integrals/integrals.html we can read:

manualintegrate 模块具有返回所使用步骤的函数(有关更多信息,请参阅模块文档字符串).

The manualintegrate module has functions that return the steps used (see the module docstring for more information).

但是调用 help(sympy.integrals.manualintegrate) 我们得到:

but calling help(sympy.integrals.manualintegrate) we get:

Help on function manualintegrate in module sympy.integrals.manualintegrate:

manualintegrate(f, var)
manualintegrate(f, var)

Compute indefinite integral of a single variable using an algorithm that
resembles what a student would do by hand.

Unlike ``integrate``, var can only be a single symbol.

Examples
========

>>> from sympy import sin, cos, tan, exp, log, integrate
>>> from sympy.integrals.manualintegrate import manualintegrate
>>> from sympy.abc import x
>>> manualintegrate(1 / x, x)
log(x)
>>> integrate(1/x)
log(x)
>>> manualintegrate(log(x), x)
x*log(x) - x
>>> integrate(log(x))
x*log(x) - x
>>> manualintegrate(exp(x) / (1 + exp(2 * x)), x)
atan(exp(x))
>>> integrate(exp(x) / (1 + exp(2 * x)))
RootSum(4*_z**2 + 1, Lambda(_i, _i*log(2*_i + exp(x))))
>>> manualintegrate(cos(x)**4 * sin(x), x)
-cos(x)**5/5
>>> integrate(cos(x)**4 * sin(x), x)
-cos(x)**5/5
>>> manualintegrate(cos(x)**4 * sin(x)**3, x)
cos(x)**7/7 - cos(x)**5/5
>>> integrate(cos(x)**4 * sin(x)**3, x)
cos(x)**7/7 - cos(x)**5/5
>>> manualintegrate(tan(x), x)
-log(cos(x))
>>> integrate(tan(x), x)
-log(sin(x)**2 - 1)/2

See Also
========

sympy.integrals.integrals.integrate
sympy.integrals.integrals.Integral.doit
sympy.integrals.integrals.Integral

我没有看到逐步的解决方案.

I don't see step by step solution.

推荐答案

您正在查看 function manualintegrate 的文档字符串,而不是 module manualintegrate 的文档字符串.该模块是这里,它说

You are looking at the docstring of the function manualintegrate, not of the module manualintegrate. The module is here and it says

该模块还提供了获取用于评估评估的步骤的功能特殊积分,在 integral_steps 函数中.这将返回表示使用的集成规则的嵌套命名元组.

This module also provides functionality to get the steps used to evaluate a particular integral, in the integral_steps function. This will return nested namedtuples representing the integration rules used.

integral_steps 函数记录如下:

返回计算积分所需的步骤.此功能试图尽可能地反映学生将用手做的事情.SymPy Gamma 使用它来提供积分的逐步解释.它用于格式化此函数结果的代码可以在 https://github.com/sympy/sympy_gamma/blob/master/app/logic/intsteps.py.

Returns the steps needed to compute an integral. This function attempts to mirror what a student would do by hand as closely as possible. SymPy Gamma uses this to provide a step-by-step explanation of an integral. The code it uses to format the results of this function can be found at https://github.com/sympy/sympy_gamma/blob/master/app/logic/intsteps.py.

除非您使用 SymPy Gamma,否则 integral_steps 的输出将难以阅读.示例:

Unless you are using SymPy Gamma, the output of integral_steps will be hard to read. Example:

from sympy.integrals.manualintegrate import integral_steps
integral_steps(x*sin(3*x), x)

返回

PartsRule(u=x, dv=sin(3*x), v_step=URule(u_var=_u, u_func=3*x, constant=1/3, substep=ConstantTimesRule(constant=1/3, other=sin(_u), substep=TrigRule(func='sin', arg=_u, context=sin(_u), symbol=_u), context=sin(_u), symbol=_u), context=sin(3*x), symbol=x), second_step=ConstantTimesRule(constant=-1/3, other=cos(3*x), substep=URule(u_var=_u, u_func=3*x, constant=1/3, substep=ConstantTimesRule(constant=1/3, other=cos(_u), substep=TrigRule(func='cos', arg=_u, context=cos(_u), symbol=_u), context=cos(_u), symbol=_u), context=cos(3*x), symbol=x), context=-cos(3*x)/3, symbol=x), context=x*sin(3*x), symbol=x)

SymPy Gamma 网站.

这篇关于Sympy 积分的分步解法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆