# SageMath

**SageMath**（旧称 **Sage**）是一个自由、开源的数学软件系统，以 GPL 许可证发布。它将数百个现有的开源软件包——包括 NumPy、SciPy、matplotlib、SymPy、Maxima、GAP、FLINT 和 R——整合在统一的基于 Python 的语言以及一套接口和封装之下。<sup>[1](https://www.sagemath.org/index)</sup> 其公开使命是打造一个可行的自由开源替代品，以取代 Magma、Maple、Mathematica 和 MATLAB。<sup>[1](https://www.sagemath.org/index)</sup> 该项目始于 2005 年，由当时在华盛顿大学（University of Washington）的威廉·斯坦（William Stein）领导，此后在数百人的贡献下不断发展壮大。<sup>[2](https://www.cambridge.org/core/books/abs/foundations-of-computational-mathematics-budapest-2011/sage-creating-a-viable-free-open-source-alternative-to-magma-maple-mathematica-and-matlab/1B56AE947F1AA7ED9AF56AC6E7621D55)</sup>

| 关键事实 | 详情 |
|---|---|
| 许可证与状态 | 以 GPL 发布的自由开源软件；主仓库位于 GitHub 的 sagemath 组织下<sup>[1](https://www.sagemath.org/index)</sup><sup> • </sup><sup>[3](https://github.com/sagemath/sage)</sup> |
| 主要语言 | Python 是接口语言和主要实现语言；对性能关键的代码则用 Cython、C/C++、Fortran 95、GAP、Common Lisp、Singular 或 PARI/GP 编写<sup>[4](https://doc.sagemath.org/html/en/tutorial/afterword.html)</sup><sup> • </sup><sup>[5](https://doc.sagemath.org/html/en/developer/coding_in_other.html)</sup> |
| 构建于 | NumPy、SciPy、matplotlib、SymPy、Maxima、GAP、FLINT、R 以及许多其他软件包之上<sup>[1](https://www.sagemath.org/index)</sup> |
| 使命 | 成为 Magma、Maple、Mathematica 和 MATLAB 的可行自由开源替代品<sup>[1](https://www.sagemath.org/index)</sup><sup> • </sup><sup>[2](https://www.cambridge.org/core/books/abs/foundations-of-computational-mathematics-budapest-2011/sage-creating-a-viable-free-open-source-alternative-to-magma-maple-mathematica-and-matlab/1B56AE947F1AA7ED9AF56AC6E7621D55)</sup> |
| 创立 | 2005 年，由威廉·斯坦（华盛顿大学）创立<sup>[2](https://www.cambridge.org/core/books/abs/foundations-of-computational-mathematics-budapest-2011/sage-creating-a-viable-free-open-source-alternative-to-magma-maple-mathematica-and-matlab/1B56AE947F1AA7ED9AF56AC6E7621D55)</sup> |
| 近期版本 | 下载页面上列出的最新稳定版为 10.9 版；GitHub 发布页列出 10.10 版，发布于 2026 年 9 月 28 日<sup>[6](https://www.sagemath.org/download-source.html)</sup><sup> • </sup><sup>[7](https://github.com/sagemath/sage/releases)</sup> |
| 网页访问 | SageMathCell 用于在网页中嵌入单次计算；CoCalc 是由关联公司 SageMath, Inc. 提供的付费在线服务<sup>[8](https://www.sagemath.org/sagecell/)</sup><sup> • </sup><sup>[9](https://wiki.sagemath.org/SageMath)</sup> |

## 目的与设计目标

Sage 项目启动的初衷，是为数学家提供一个自由系统，具备四大主流商业系统的重要数学功能，且速度相当、支持二维和三维图形、拥有交互式界面和文档。威廉·斯坦的项目描述指出，这样的替代品并不能直接替换原系统：它不必运行用 Magma、Maple、Mathematica 或 MATLAB 各自专有语言编写的程序，因此在理念上可以不同于——譬如——Octave，后者重新实现了 MATLAB 语言。<sup>[2](https://www.cambridge.org/core/books/abs/foundations-of-computational-mathematics-budapest-2011/sage-creating-a-viable-free-open-source-alternative-to-magma-maple-mathematica-and-matlab/1B56AE947F1AA7ED9AF56AC6E7621D55)</sup>

项目的常见问题解答阐述了其基本原则：将科学交流所特有的开放交换与同行评审应用于数学软件的开发，使计算结果可以通过阅读源代码来核查。Sage 是一个以志愿者为基础的项目，由一支由学生、教师、研究人员和软件工程师组成的国际团队提供支持。<sup>[10](https://doc.sagemath.org/html/en/faq/faq-general.html)</sup>

## 架构

**Python 充当黏合剂。** 主要实现语言是 Python，之所以选择它而非发明一门新的数学语言，教程的后记列出了诸多优势，包括对象保存、文档示例的自动测试、健壮的内存管理器、可移植性、异常处理、调试器和性能分析器。Sage 没有修改 Python 解释器，而是直接使用 Python，并为 IPython 添加了一个预解析器，使命令行行为符合数学上的预期。<sup>[4](https://doc.sagemath.org/html/en/tutorial/afterword.html)</sup> 该预解析器做了两处数学家会立刻注意到的改动：`^` 变为幂运算（Python 中的 `**`），而 `^^` 保留给按位异或；诸如 `2/3` 的整数除法产生精确的有理数 2/3，而非浮点值。<sup>[4](https://doc.sagemath.org/html/en/tutorial/afterword.html)</sup>

**编译代码以提升速度。** 由于某些计算在使用静态类型的编译语言时能快上几个数量级，Sage 支持 Cython——Python 的一种编译形式，同时允许任意 C 变量声明和直接调用 C 库；编译文件使用 `.spyx` 扩展名。<sup>[11](https://www.sagemath.org/doc/tutorial/programming.html)</sup> 任意精度整数通过 GMP C 库实现，而非使用 Python 原生的整数，后者较慢。<sup>[4](https://doc.sagemath.org/html/en/tutorial/afterword.html)</sup> 一份较早的常见问题解答统计，Sage 库本身包含超过 70 万行新的 Python 和 Cython 代码。<sup>[12](https://doc-gitlab.sagemath.org/pdf/en/faq/faq.pdf)</sup>

## 与其他系统的接口

Sage 通过 C 库接口和用伪终端与系统文件实现的解释器接口，为外部计算软件提供统一接口。Sage 捆绑了 GAP、PARI、Singular 和 Maxima；它不包含 Octave、Magma、Maple 或 Mathematica，但如果单独安装了这些程序，则可以使用与它们的接口。每次解释器调用都有开销，因此通过 GAP 接口计算 `2+2` 数千次，比直接在 Sage 中计算要慢。<sup>[13](https://sagemath.gitlab.io/documentation/html/en/reference/interfaces/)</sup>

为避免这种延迟，Sage 包含了 libgap，即 GAP 内核的共享库版本。调用共享库的延迟远低于伪终端接口大约 10 毫秒的往返时间，并且避免了中间将数据转换为字符串；GAP 对象可以通过 `.sage()` 方法转换回 Sage 矩阵。<sup>[5](https://doc.sagemath.org/html/en/developer/coding_in_other.html)</sup> 开发者指南还记录了 PARI C 库接口——例如用于某些繁重的整数矩阵计算，如弗罗贝尼乌斯形式——以及一个类似 Python 的 Singular 接口。<sup>[5](https://doc.sagemath.org/html/en/developer/coding_in_other.html)</sup>

## 数学覆盖范围

参考手册将 Sage 的功能组织为代数、数论、代数与算术几何（包括椭圆曲线和超椭圆曲线）、组合数学、图论、几何与拓扑、同调代数以及数值计算等多个领域。<sup>[14](https://doc.sagemath.org/html/en/reference/)</sup> 功能导览描述了从基础代数、微积分和数论，到密码学、数值计算、交换代数、群论、组合数学、图论和精确线性代数的覆盖范围。<sup>[15](https://www.sagemath.org/tour.html)</sup>

SageManifolds 最初是一个独立的张量分析与微分几何软件包，现在是 SageMath 的内部软件包，无需额外安装；2017 年的一项研究使用它计算了施瓦茨席尔德（Schwarzschild）和克尔（Kerr）时空的克里斯托费尔符号、里奇张量和爱因斯坦张量。<sup>[16](https://arxiv.org/html/1703.09738)</sup>

## 安装与访问

Sage 试图支持所有主要的 Linux 发行版、较新版本的 macOS，以及通过 Windows Subsystem for Linux 或虚拟化支持的 Windows；Windows 上的首选途径是 WSL 搭配一个 Linux 发行版，如 Ubuntu。<sup>[3](https://github.com/sagemath/sage)</sup> 完整源代码附带所有标准依赖项，安装到一个隔离目录中，不干扰周围系统。<sup>[6](https://www.sagemath.org/download-source.html)</sup> 从 8.x 版本系列开始的一项开发工作，允许许多依赖项由操作系统发行版、Homebrew 或 conda-forge 提供的系统软件包来满足，从而减少编译时间和安装体积。<sup>[12](https://doc-gitlab.sagemath.org/pdf/en/faq/faq.pdf)</sup>

不想安装任何东西的用户可以使用 SageMathCell——一个允许在任何网页中嵌入 Sage 计算的网页界面——或者 CoCalc，一个由私营公司 SageMath, Inc. 提供的在线计算与协作环境，该公司与 Sage 项目有关联但相互独立。<sup>[8](https://www.sagemath.org/sagecell/)</sup><sup> • </sup><sup>[9](https://wiki.sagemath.org/SageMath)</sup>

## 在研究中的应用与基准测试

2022 年夏季的独立积分测试在一套通用测试集上比较了各计算机代数系统。Mathematica 13.1 求解了 97.99% 的积分，Maple 2022.1 求解了 84.53%；在通过 SageMath 调用的系统中，FriCAS 1.3.8 求解了 79.33%，Giac 1.9.0-13 求解了 58.37%，Maxima 5.46 求解了 56.86%，而 SymPy 1.10.1 在直接从 Python 调用时求解了 41.89%。测试组织者指出，通过 SageMath 调用的系统的一些失败可能反映的是接口问题，而非底层计算机代数系统本身。<sup>[17](https://groups.google.com/g/sci.math.symbolic/c/cqT39iLaHKA)</sup>

SageMath 还已成为 AI 系统的计算后端。2026 年一项在 RealMath 基准上对使用 SageMath 增强的大语言模型智能体的评估报告称，在所评估的模型中，SageMath 访问平均带来 9.7 个百分点的提升，各模型的提升幅度从 1.5 到 27.8 个百分点不等。<sup>[18](https://arxiv.org/html/2607.06820)</sup>

## References

1. [SageMath - Open-Source Mathematical Software System](https://www.sagemath.org/index)
2. [W. Stein. Sage: Creating a Viable Free Open Source Alternative to Magma, Maple, Mathematica, and MATLAB. Foundations of Computational Mathematics, Budapest 2011, Cambridge University Press](https://www.cambridge.org/core/books/abs/foundations-of-computational-mathematics-budapest-2011/sage-creating-a-viable-free-open-source-alternative-to-magma-maple-mathematica-and-matlab/1B56AE947F1AA7ED9AF56AC6E7621D55)
3. [sagemath/sage: Main repository of SageMath, GitHub](https://github.com/sagemath/sage)
4. [Afterword: Why Python? Sage Tutorial](https://doc.sagemath.org/html/en/tutorial/afterword.html)
5. [Using External Libraries and Interfaces, Sage Developer Guide](https://doc.sagemath.org/html/en/developer/coding_in_other.html)
6. [SageMath - Source Code Distribution (stable)](https://www.sagemath.org/download-source.html)
7. [Releases, sagemath/sage, GitHub](https://github.com/sagemath/sage/releases)
8. [Sage Cell Server / About SageMathCell](https://www.sagemath.org/sagecell/)
9. [SageMath, SageMath Wiki](https://wiki.sagemath.org/SageMath)
10. [FAQ: General, Sage Documentation](https://doc.sagemath.org/html/en/faq/faq-general.html)
11. [Programming, Sage Tutorial](https://www.sagemath.org/doc/tutorial/programming.html)
12. [Sage FAQ (PDF)](https://doc-gitlab.sagemath.org/pdf/en/faq/faq.pdf)
13. [Interpreter Interfaces, Sage 9.4 Reference Manual](https://sagemath.gitlab.io/documentation/html/en/reference/interfaces/)
14. [Sage Reference Manual](https://doc.sagemath.org/html/en/reference/)
15. [SageMath Feature Tour](https://www.sagemath.org/tour.html)
16. [Birkandan et al. Symbolic and Numerical Analysis in General Relativity with Open Source Computer Algebra Systems. arXiv:1703.09738](https://arxiv.org/html/1703.09738)
17. [CAS independent integration tests, summer 2022 edition, sci.math.symbolic](https://groups.google.com/g/sci.math.symbolic/c/cqT39iLaHKA)
18. [Snopov & Magai. Evaluating SageMath-Augmented LLM Agents for Computational and Experimental Mathematics. arXiv:2607.06820](https://arxiv.org/html/2607.06820)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Computational and symbolic algebra › Computer algebra systems

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/sagemath

English original: https://www.edgepedia.org/sagemath
