Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/pkgs/texlive/distros/arch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ texlive-core
texlive-latexextra
texlive-langjapanese
texlive-langcyrillic
texlive-langchinese
1 change: 1 addition & 0 deletions build/pkgs/texlive/distros/debian.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ texlive-lang-japanese
texlive-lang-polish
texlive-lang-portuguese
texlive-lang-spanish
texlive-lang-chinese
1 change: 1 addition & 0 deletions build/pkgs/texlive/distros/fedora.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ texlive-collection-langjapanese
texlive-collection-langpolish
texlive-collection-langportuguese
texlive-collection-langspanish
texlive-collection-langcjk
1 change: 1 addition & 0 deletions build/pkgs/texlive/distros/gentoo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ dev-texlive/texlive-langspanish
dev-texlive/texlive-latexextra
dev-texlive/texlive-latexrecommended
dev-texlive/texlive-mathscience
dev-texlive/texlive-langchinese
3 changes: 3 additions & 0 deletions build/pkgs/texlive/package-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ babel-spanish
# Japanese
jsclasses
ptex

# Chinese
ctex
10 changes: 10 additions & 0 deletions src/doc/en/website/root_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ <h1>Sage Documentation</h1>
<div class="cell doc">
<div class='entry lang-tr'><a href='html/tr/a_tour_of_sage/index.html'>A Tour of Sage</a></div>
</div></div>
<div class="row zh"><div class="cell"></div>
<div class="cell lang">Simplified Chinese</div>
<div class="cell doc">
<div class='entry lang-zh'><a href='html/zh/a_tour_of_sage/index.html'>A Tour of Sage</a></div>
</div></div>
<div class="row last"></div>
<div class="row first">
<div class='cell'><h2>PDF</h2></div>
Expand Down Expand Up @@ -185,6 +190,11 @@ <h1>Sage Documentation</h1>
<div class="cell doc">
<div class='entry lang-tr'><a href='pdf/tr/a_tour_of_sage/a_tour_of_sage.pdf'>A Tour of Sage</a></div>
</div></div>
<div class="row zh"><div class="cell"></div>
<div class="cell lang">Simplified Chinese</div>
<div class="cell doc">
<div class='entry lang-zh'><a href='pdf/zh/a_tour_of_sage/a_tour_of_sage.pdf'>A Tour of Sage</a></div>
</div></div>
<div class="row last"></div>
</div>
</body></html>
55 changes: 55 additions & 0 deletions src/doc/zh/a_tour_of_sage/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# nodoctest
# Numerical Sage documentation build configuration file, created by
# sphinx-quickstart on Sat Dec 6 11:08:04 2008.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are okay, they're removed automatically).
#
# All configuration values have a default; values that are commented out
# serve to show the default.

from sage_docbuild.conf import release
from sage_docbuild.conf import * # NOQA


for tag in feature_tags():
tags.add(tag)


# Add any paths that contain custom static files (such as style sheets),
# relative to this directory to html_static_path. They are copied after the
# builtin static files, so a file named "default.css" will overwrite the
# builtin "default.css". html_common_static_path imported from sage_docbuild.conf
# contains common paths.
html_static_path = [] + html_common_static_path

# Add small view/edit buttons.
html_theme_options.update({
'source_view_link': os.path.join(source_repository, 'blob/develop/src/doc/zh/a_tour_of_sage', '{filename}'),
'source_edit_link': os.path.join(source_repository, 'edit/develop/src/doc/zh/a_tour_of_sage', '{filename}'),
})

# General information about the project.
project = "Sage 之旅"
name = 'a_tour_of_sage'
language = "zh_CN"

# The LaTeX engine to build the docs in Chinese.
# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine
latex_engine = 'xelatex'

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
html_title = project + " v" + release

# Output file base name for HTML help builder.
htmlhelp_basename = name

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
latex_documents = [
('index', name + '.tex', project,
'The Sage Development Team', 'manual'),
]
Binary file added src/doc/zh/a_tour_of_sage/eigen_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 134 additions & 0 deletions src/doc/zh/a_tour_of_sage/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
.. _a-tour-of-sage:

===============
欢迎使用 Sage
===============

这是一篇关于如何使用 Sage 计算器的简短介绍。

Sage 的命令行提示符为 "``sage:``"。在实验以下示例时,你只需输入提示符后的部分。

::

sage: 3 + 5
8

如果你在 Jupyter notebook 中使用 Sage,也可以将提示符后的内容放入输入单元格,然后按 :kbd:`Shift-Enter` 来获取相应的输出。

尖号(^)表示“乘方”。

::

sage: 57.1^100
4.60904368661396e175

在 Sage 中计算一个 :math:`2 \times 2` 矩阵的逆。

::

sage: matrix([[1, 2], [3, 4]])^(-1)
[ -2 1]
[ 3/2 -1/2]

这里我们对一个简单函数进行积分。

::

sage: x = var('x') # 创建符号变量
sage: integrate(sqrt(x) * sqrt(1 + x), x)
1/4*((x + 1)^(3/2)/x^(3/2) + sqrt(x + 1)/sqrt(x))/((x + 1)^2/x^2 - 2*(x + 1)/x + 1)
- 1/8*log(sqrt(x + 1)/sqrt(x) + 1) + 1/8*log(sqrt(x + 1)/sqrt(x) - 1)

这里我们让 Sage 解一个二次方程。在 Sage 中,符号 ``==`` 表示相等。

::

sage: a = var('a')
sage: S = solve(x^2 + x == a, x); S
[x == -1/2*sqrt(4*a + 1) - 1/2, x == 1/2*sqrt(4*a + 1) - 1/2]

结果是一个等式列表。

.. link

::

sage: S[0].rhs() # 方程的右侧
-1/2*sqrt(4*a + 1) - 1/2

Sage 当然可以绘制各种常用函数。

::

sage: show(plot(sin(x) + sin(1.6*x), 0, 40))

.. image:: sin_plot.*


Sage 是一个非常强大的计算器。为了体验它的能力,首先我们创建一个 :math:`500 \times 500` 的随机数矩阵。

::

sage: m = random_matrix(RDF, 500)

Sage 仅需一秒钟就能计算出矩阵的特征值并绘制它们。

.. link

::

sage: e = m.eigenvalues() # 大约 1 秒
sage: w = [(i, abs(e[i])) for i in range(len(e))]
sage: show(points(w))

.. image:: eigen_plot.*


Sage 可以处理非常大的数字,甚至是数百万或数十亿位的数字。

::

sage: factorial(100)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000

::

sage: n = factorial(1000000) # 大约 1 秒
sage: len(n.digits())
5565709

计算 :math:`\pi` 的前 100 位。

::

sage: N(pi, digits=100)
3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068

让 Sage 对一个二元多项式进行因式分解。

::

sage: R.<x,y> = QQ[]
sage: F = factor(x^99 + y^99)
sage: F
(x + y) * (x^2 - x*y + y^2) * (x^6 - x^3*y^3 + y^6) *
(x^10 - x^9*y + x^8*y^2 - x^7*y^3 + x^6*y^4 - x^5*y^5 +
x^4*y^6 - x^3*y^7 + x^2*y^8 - x*y^9 + y^10) *
(x^20 + x^19*y - x^17*y^3 - x^16*y^4 + x^14*y^6 + x^13*y^7 -
x^11*y^9 - x^10*y^10 - x^9*y^11 + x^7*y^13 + x^6*y^14 -
x^4*y^16 - x^3*y^17 + x*y^19 + y^20) * (x^60 + x^57*y^3 -
x^51*y^9 - x^48*y^12 + x^42*y^18 + x^39*y^21 - x^33*y^27 -
x^30*y^30 - x^27*y^33 + x^21*y^39 + x^18*y^42 - x^12*y^48 -
x^9*y^51 + x^3*y^57 + y^60)
sage: F.expand()
x^99 + y^99

Sage 可以在 1 秒内计算出将一亿分解为正整数之和的方式数量。

::

sage: z = Partitions(10^8).cardinality() # 大约 0.1 秒
sage: z
1760517045946249141360373894679135204009...

Sage 是世界上最先进的开源数学软件。
Binary file added src/doc/zh/a_tour_of_sage/sin_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 139 additions & 0 deletions src/doc/zh/tutorial/afterword.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
*********
后记
*********

为什么选择 Python?
====================

Python 的优势
--------------------

尽管必须快速执行的代码是用编译型语言实现的,但 Sage 的主要实现语言是 Python(见 [Py]_ )。
Python 具有以下几点优势:


- **对象保存** 在 Python 中得到了很好的支持。Python 广泛支持将(几乎)任意对象保存到磁盘文件或数据库中。

- 源代码中对函数和包的 **文档** 支持非常好,包括自动提取文档和自动测试所有示例。
这些示例会定期自动测试,并保证如预期工作。

- **内存管理**:Python 现有的内存管理器和垃圾收集器设计精巧且强大,
可以正确处理循环引用,并允许文件中的局部变量。

- Python 拥有许多对 Sage 用户非常有用的 **包**:数值分析和线性代数,2D 和 3D 可视化,
网络(用于分布式计算和服务,例如通过 twisted),数据库支持等。

- **可移植性**:Python 在大多数平台上,只需几分钟即可轻松从源代码编译 Python。

- **异常处理**:Python 拥有复杂且精巧的异常处理系统,即使代码出现错误,程序也能优雅地恢复。

- **调试器**:Python 包含调试器,因此当代码由于某种原因失败时,
用户可以访问详尽的堆栈跟踪,检查所有相关变量的状态,并上下移动堆栈。

- **性能分析器**:Python 拥有性能分析器,它会运行代码并创建一份详细报告,说明每个函数被调用的次数和时间。

- **一门语言**:不同于 Magma、Maple、Mathematica、Matlab、GP/PARI、GAP、Macaulay 2、Simath 等
那样为数学编写一门 **新语言**,我们使用 Python 语言,它是一种流行的计算机语言,
由数百名经验丰富的软件工程师积极开发和优化。Python 是一个重要的开源成功案例,拥有成熟的开发流程(见 [PyDev]_ )。


.. _section-mathannoy:

预解析器:Sage 与 Python 之间的区别
---------------------------------------------------

Python 的一些数学方面可能会令人困惑,因此 Sage 在多个方面的行为与 Python 不同。


- **指数运算符的表示法**: ``**`` vs ``^``。在 Python 中,
``^`` 表示“异或”,而不是指数运算。因此在 Python 中我们有:

.. CODE-BLOCK:: pycon

>>> 2^8
10
>>> 3^2
1
>>> 3**2
9

``^`` 的这种用法可能略显奇怪,并且对于纯数学研究来说效率不高,因为“异或”函数很少使用。
为了方便起见,Sage 在将所有命令行传递给 Python 之前都会进行预解析,
将不在字符串中的 ``^`` 替换为 ``**``:

::

sage: 2^8
256
sage: 3^2
9
sage: "3^2"
'3^2'

Sage 中的按位异或运算符是 ``^^``。这也适用于就地运算符对于就地运算符 ``^^=``:

::

sage: 3^^2
1
sage: a = 2
sage: a ^^= 8
sage: a
10

- **整数除法**:Python 表达式 ``2/3`` 并不像数学家们所预期的那样:``2/3`` 返回浮点数 ``0.6666...``。
请注意 ``//`` 是欧几里得除法,``2//3`` 返回 ``0``。

我们在 Sage 解释器中通过将整型字面量包装在 ``Integer( )`` 中,并使除法作为有理数的构造函数来处理这个问题。例如:

::

sage: 2/3
2/3
sage: (2/3).parent()
Rational Field
sage: 2//3
0

- **长整数**:Python 原生支持除 C int 类型外的任意精度整数。
这些原生整数的性能显著低于 GMP 所提供的。Sage 使用 GMP C 库来实现任意精度整数。


与某些人为了内部项目修改 Python 解释器不同,我们完全按照原样使用 Python 语言,
并为 IPython 编写预解析器,使 IPython 的命令行行为符合数学家的预期。
这意味着任何现有的 Python 代码都可以在 Sage 中使用。
然而,仍需遵守标准的 Python 规则,以便编写能够导入 Sage 的包。

(例如,要安装在互联网上找到的 Python 库,请按照说明进行操作,
但使用 ``sage -python`` 而不是 ``python``。
通常这意味着输入 ``sage -python setup.py install``。)

我想做出一些贡献。我应该怎么做?
==============================================

如果你想为 Sage 做出贡献,我们会非常感谢你的帮助!贡献可以从实质性代码贡献到向 Sage 添加文档或报告错误。

浏览 Sage 网页以获取开发者信息。你还可以找到一份按优先级和类别排序的 Sage 相关项目列表。
`Sage 开发者指南 <http://doc.sagemath.org/html/en/developer/>`_ 也有一些有用的信息,
你还可以查看 ``sage-devel`` Google 讨论组。

如何引用 Sage?
========================

如果你在论文中使用了 Sage,当引用使用 Sage 的计算时,包含以下内容:
如果你使用 Sage 撰写论文,请将以下内容添加到参考文献中来引用使用 Sage 完成的计算

.. CODE-BLOCK:: text

[Sage] SageMath, the Sage Mathematics Software System (Version 8.7),
The Sage Developers, 2019, https://www.sagemath.org.

(将 8.7 替换为你使用的 Sage 版本)。此外,请尝试追踪在计算中使用了哪些 Sage 组件,
例如 PARI?, GAP?, Singular?, Maxima? 并引用这些系统。如果你不确定计算使用了哪个软件,
可以随时在 ``sage-devel`` Google 讨论组上提问。有关这一点的进一步讨论,请参阅 :ref:`section-univariate`。

------------

如果你恰好刚刚读完这篇教程,并且知道花了多长时间,请在 ``sage-devel`` Google 讨论组上告诉我们。

祝使用 Sage 愉快!
Loading