Kri*_*chu 3 python math latex sympy ipython
我想知道如何让 sympy 表现得像字面意思一样呈现表达式并且不会发生分解(sqrt 下的 4)
from sympy import init_session
init_session(quiet=true)
from sympy.interactive import printing
printing.init_printing(use_latex=True)
a=sqrt(4*A**2*Z**2)
a
Run Code Online (Sandbox Code Playgroud)
给
2 * sqrt(a**2*Z**2)
Run Code Online (Sandbox Code Playgroud)
我宁愿把它写成最初写的(在教育文本的过程中)。那么如何防止 sympy 进行任何简化或解决呢?
使用“evaluate(False)”块来停止简化/评估规则:
(我使用的是 Python 3.4,sympy 0.7)
with evaluate(False):
print(sqrt(4*x))
sqrt(4*x)
>>>
Run Code Online (Sandbox Code Playgroud)