SymPy和Sage有什么区别? [英] What is the difference between SymPy and Sage?

查看:217
本文介绍了SymPy和Sage有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SymPy

What is the difference between SymPy and Sage a.k.a. SageMath?

推荐答案

(完整披露:我是SymPy的首席开发人员)

(Full disclosure: I am the lead developer of SymPy)

您应该了解的第一件事是SymPy和Sage不太一样. SymPy是一个纯Python库,可以进行计算机代数运算. Sage是开源数学软件的集合. Sage尝试将所有主要的开源数学软件聚集在一起,并将其粘合到一个有用的系统中.实际上, Sage包含SymPy 作为其系统之一.

The first thing you should understand is that SymPy and Sage are not quite the same thing. SymPy is a pure Python library, that does computer algebra. Sage is a collection of open source mathematical software. Sage tries to gather together all the major open source mathematics software, and glue it together into a useful system. In fact, Sage includes SymPy as one of its systems.

下面是每个(有偏见的)事实的简短列表(我不会称其为优缺点,只是事实):

Here is a short list of (biased) facts for each (I won't call them pros or cons, just facts):

  • SymPy is completely standalone. It has no dependencies other than Python.
  • Despite being standalone, it is full featured as a computer algebra system. If you want to do numerics, you are encouraged to use other libraries in the scientific Python ecosystem.
  • SymPy is BSD licensed. For many people, this doesn't matter, but if you want to include SymPy in something else, it's nice to know that you can pretty much do whatever you want with the code.
  • SymPy does not try to change Python. SymPy takes the philosophy that Python is doing things well, so it should do things the Python way. For example, the operator for exponentiation is ** as it is in Python, not ^ as it is in many other systems.
  • SymPy can be used as a library. Since SymPy is just a Python module, you can just import it and use it in any place that uses Python. There are a lot of really cool apps and libraries out there that use SymPy in the background to do symbolics (in many cases, in places where you might not even realize that symbolics are being used).
  • Sage包含了您可能想进行数学处理的开源世界中的所有内容(包括SymPy).这包括许多对数字有用的库,例如八度.
  • 贤者是GPL.如果您喜欢整个FSF软件自由的支配,那么您将获得更大的权力.您也必须在GPL许可下才能在自己的应用程序中重用源代码.
  • Sage很难用作库.另一方面,它有一个非常漂亮的笔记本界面.如果要对SymPy执行相同的操作,建议的方法是使用IPython笔记本并在顶部运行from sympy import init_session; init_session()(如果只想打印而不要导入所有内容,则将init_session替换为init_printing).
  • Sage在Python之上包含一些DSL.例如,您可以键入1/2而不包装整数文字,它将返回一个有理数. x^2给出x的平方,而不是Xor(x, 2).我不确定默认情况下是否会自动为您定义变量.这意味着您在交互式Sage会话中执行的操作可能不会直接转换为Python脚本.另一方面,这对于交互使用可能很有用(顺便说一句,SymPy也具有isympy -I可以做一些类似的事情).
  • Sage includes everything (including SymPy) from the open source world that you might want to do mathematics. This includes many libraries that are useful for numerics, like octave.
  • Sage is GPL. If you like the whole FSF software freedom shpel, then more power to you. You can't reuse the source code in your own application without licensing your application under the GPL as well.
  • Sage is hard to use as a library. On the other hand, it has a very nice notebook interface. If you want to do the same with SymPy, the recommended way is to use the IPython notebook and run 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).
  • Sage includes a bit of a DSL on top of Python. For example, you can type 1/2 without wrapping the integer literals, and it will return a rational. x^2 gives x squared, not 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. On the other hand, this can be useful for interactive use (btw, SymPy also has isympy -I that does some similar things).

也许这不是您想要的.您可能想要一些实际的数学功能.但是正如我所说,Sage包含SymPy,因此根据定义,SymPy的每个功能都将是Sage的功能.实际上,并不一定是这样,因为默认情况下Sage并不总是使用SymPy(我不确定它的当前状态是什么),因此,如果要使用它,可能必须手动调用SymPy.从贤者内部.

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. 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.

这篇关于SymPy和Sage有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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