是否可以显示 SymPy 在 `simplify()` 期间尝试的所有函数?
Is it possible to display all of the functions that SymPy tries during `simplify()`?
SymPy docs 声明如下:
SymPy has dozens of functions to perform various kinds of simplification. There is also one general function called simplify() that attempts to apply all of these functions in an intelligent way to arrive at the simplest form of an expression.
我正在使用 SymPy 作为帮助我重新学习数学的工具,所以如果我可以查看 SymPy 尝试的所有函数,那将非常有用。
是否可以显示 SymPy 在 simplify()
期间尝试的所有功能?我该怎么做?
simplify
来源here. According to it, SymPy attempts the following operations, most of which are documented in simplify module docs(您链接的页面来自SymPy教程,不赘述。)
cancel(expr)
_mexpand(expr).cancel()
together(expr, deep=True)
factor_terms(expr, sign=False)
hyperexpand(expr)
piecewise_fold(expr)
besselsimp(expr)
trigsimp(expr, deep=True)
expand_log(expr, deep=True)
logcombine(expr)
combsimp(expr)
sum_simplify(expr)
product_simplify(expr)
quantity_simplify(expr)
powsimp(expr, combine='exp', deep=True)
powsimp(expr)
expand_power_exp(expand_mul(expr)))
exptrigsimp(expr)
要直接尝试这些,请导入
from sympy import *
from sympy.simplify.simplify import sum_simplify, product_simplify
from sympy.core.function import _mexpand
但是,simplify
并没有将这些方法一一尝试:其中大部分只在表达式匹配某种模式时才使用,也有一些组合使用。
SymPy docs 声明如下:
SymPy has dozens of functions to perform various kinds of simplification. There is also one general function called simplify() that attempts to apply all of these functions in an intelligent way to arrive at the simplest form of an expression.
我正在使用 SymPy 作为帮助我重新学习数学的工具,所以如果我可以查看 SymPy 尝试的所有函数,那将非常有用。
是否可以显示 SymPy 在 simplify()
期间尝试的所有功能?我该怎么做?
simplify
来源here. According to it, SymPy attempts the following operations, most of which are documented in simplify module docs(您链接的页面来自SymPy教程,不赘述。)
cancel(expr)
_mexpand(expr).cancel()
together(expr, deep=True)
factor_terms(expr, sign=False)
hyperexpand(expr)
piecewise_fold(expr)
besselsimp(expr)
trigsimp(expr, deep=True)
expand_log(expr, deep=True)
logcombine(expr)
combsimp(expr)
sum_simplify(expr)
product_simplify(expr)
quantity_simplify(expr)
powsimp(expr, combine='exp', deep=True)
powsimp(expr)
expand_power_exp(expand_mul(expr)))
exptrigsimp(expr)
要直接尝试这些,请导入
from sympy import *
from sympy.simplify.simplify import sum_simplify, product_simplify
from sympy.core.function import _mexpand
但是,simplify
并没有将这些方法一一尝试:其中大部分只在表达式匹配某种模式时才使用,也有一些组合使用。