[英]What is the difference between SymPy and Sage?
(Full disclosure: I am the lead developer of SymPy) (完全披露:我是SymPy的首席开发人员)
The first thing you should understand is that SymPy and Sage are not quite the same thing. 你应该首先理解的是,SymPy和Sage并不完全相同。 SymPy is a pure Python library, that does computer algebra. SymPy是一个纯粹的Python库,可以完成计算机代数。 Sage is a collection of open source mathematical software. Sage是一个开源数学软件的集合。 Sage tries to gather together all the major open source mathematics software, and glue it together into a useful system. Sage试图将所有主要的开源数学软件聚集在一起,并将它们粘合在一起形成一个有用的系统。 In fact, Sage includes SymPy as one of its systems. 事实上, Sage将SymPy作为其系统之一。
Here is a short list of (biased) facts for each (I won't call them pros or cons, just facts): 以下是每个(有偏见的)事实的简短列表(我不会称之为利弊,只是事实):
**
as it is in Python, not ^
as it is in many other systems. 例如,对于幂运算符是**
,因为它是在Python,而不是^
因为它在许多其他系统。 from sympy import init_session; init_session()
如果你想对SymPy做同样的事情,推荐的方法是使用IPython笔记本并from sympy import init_session; init_session()
运行from sympy import init_session; init_session()
from sympy import init_session; init_session()
at the top (replace init_session
with init_printing
if you just want printing and not to import everything). from sympy import init_session; init_session()
(如果您只想打印而不是导入所有内容, init_printing
替换为init_session
)。 1/2
without wrapping the integer literals, and it will return a rational. 例如,您可以在不包装整数文字的情况下键入1/2
,它将返回一个有理数。 x^2
gives x squared, not Xor(x, 2)
. x^2
给出x平方,而不是Xor(x, 2)
。 I'm not sure if it automatically defines variables for you by default. 我不确定它是否默认为您自动定义变量。 This means that things that you do in an interactive Sage session might not translate directly to a Python script. 这意味着您在交互式Sage会话中执行的操作可能无法直接转换为Python脚本。 On the other hand, this can be useful for interactive use (btw, SymPy also has isympy -I
that does some similar things). 另一方面,这对于交互式使用非常有用(顺便说isympy -I
,SymPy也有isympy -I
做了类似的事情)。 Maybe that's not what you were looking for. 也许这不是你想要的。 You probably wanted some actual mathematical features. 你可能想要一些实际的数学特征。 But as I said, Sage includes SymPy, so by definition, every feature of SymPy will be a feature of Sage. 但正如我所说,Sage包含SymPy,因此根据定义,SymPy的每个功能都将成为Sage的一个功能。 In practice, this is not necessarily the case because Sage doesn't always use SymPy by default (I'm not sure what the current status of this is actually), so you may have to call to SymPy manually if you want to use it from within Sage. 在实践中,情况不一定是这样,因为Sage默认情况下并不总是使用SymPy(我不确定它的实际状态是什么),因此如果你想使用它,你可能需要手动调用SymPy来自Sage内部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.