The primary implementation language of SAGE is Python (see [Py]), though code that must be fast is implemented in a compiled language. Using Python has several advantages:
People who do research mathematics and use Python often run into a few problems:
**
versus ^
. In Python, ^
means
``xor'', not exponentiation, so in Python we have
>>> 2^8 10 >>> 3^2 1 >>> 3**2 9
This might be easy for some people to get used to, but for a person
used to typing LaTeX this appears odd; it is also inefficient for
pure math research, since exclusive or is rarely used. For
convenience, SAGE pre-parses all command lines before passing them to
Python, replacing instances of ^
that are not in strings with
**
:
sage: 2^8 256 sage: 3^2 9 sage: "3^2" '3^2'
2/3
has much different
behavior in Python than
in any standard math system. In Python, if 2/3
returns the floating point number 0.6666...
, and
making 2//3
return 0
.
We deal with this in the SAGE interpreter, by wrapping integer
literals in ZZ( )
and making division a constructor for
rational numbers. For example:
sage: 2/3 2/3 sage: 2//3 0 sage: int(2)/int(3) 0
L
at
the end to distinguish them from int's (and this won't change
any time soon). SAGE also implements
arbitrary precision integers, using the GMP C-library, and these
print without an L
.
Rather than modifying the Python interpreter (as I've heard some people have done for internal projects), we use the Python language exactly as is, and write a pre-parser for IPython so that the command line behavior of IPython is what a mathematician expects. This means any existing Python code can be used in SAGE. However, one must still obey the standard Python rules when writing packages that will be imported into SAGE.
Note:
To install a random Python library that you find on the internet,
follow the directions, but run sage-python
instead of python
.
Very often this means typing sage-python setup.py install
.
If you would like to contribute to SAGE, your help will be greatly
appreciated! It can range from substantial code contributions to
simply adding to the SAGE documentation. Just email William Stein at
wstein@gmail.com
or post it to
sage-forum@lists.sourceforge.net
. Also look at the SAGE web
site, where there is a long list of SAGE-related projects ordered by
priority and category.
SAGE is now sufficiently mature that there are tons of projects to work on that involve exposing more functionality of the included backend systems (Gap, PARI, Singular, etc.). This is mostly fun design work, since the really hard nitty gritty algorithmic implementation details and optimization has already been done, e.g., in Gap or PARI or Singular.
If you submit or post your code, put a copyright notice on the code that makes clear that you are releasing it under the GPL or a more liberal license. I cannot include any code with SAGE that doesn't have an explicitly stated GPL-compatible copyright.
For example, you could put the following at the top of your source file.
############################################################################## # SAGE: System for Algebra and Geometry Experimentation # # Copyright (C) 2006 Your name <your email> # Copyright (C) 2006 William Stein <wstein@gmail.com> (optional) # # Distributed under the terms of the GNU General Public License (GPL) # # http://www.gnu.org/licenses/ ##############################################################################
Note: It is not required for you to share the copyright with me, though I prefer it since it gives me flexibility regarding the code.
If you write a paper using SAGE,
please reference computations done with SAGE by including
[SJ] in your bibliography. Moreover, please attempt to track
down what components of SAGE are used for your computation,
e.g., PARI?, Gap?, Singular? Maxima? and also cite those systems.
If you are in doubt about what software your computation uses,
feel free to contact me (wstein@gmail.com
) and I'll try to
figure it out. See Section 2.2.1 for further
discussion of this point.
If you happen to have just read straight through this tutorial, and
have some sense of how long it took you, please let me know
(email wstein@gmail.com
).
Have fun with SAGE!
See About this document... for information on suggesting changes.