All published worksheets from http://sagenb.org
Image: ubuntu2004
SAGE
Creating a viable free open source alternative to
Maple, Mathematica, and Matlab
William Stein, Associate Professor, University of Washington
Poll
How many of you use mathematics software such as Mathematica, Maple, Matlab, Magma PARI, etc.?
History
Microsoft's Interest in Sage
- Support research in cryptography, combinatorics, graph theory, linear algebra, signal processing, etc.
- Improve the viability of using Windows for higher performance computing (HPC); Sage is mathematical software that could run on a large cluster with no license fee issues.
Sage is 100% Free
Active user community; 964 members of the sage-support mailing list.
Free webapp -- sagenb.org -- has about 3000 users (and there are other servers at universities around the world..)
sagemath.org
sagenb.org
Advantages of Sage
- Python -- general purpose language; huge user base compared to Matlab, Mathematica, Maple and Magma
- Cython -- blazingly fast compiled code
- Integrated web servers -- (twisted, etc.)
- General purpose programming language (not some ad hoc math language)
- Free and Open source
Drawbacks of Sage
So What is Sage?
Reference Manual (over 3000 pages, all new)
PART 2 -- Examples
The first example from the Python tutorial:
Symbolic expressions:
Solve equations
Example: A Huge Integer Determinant
We can also copy this matrix over to Maple and compute the same determinant there...
We can copy to Magma to. This ability to copy objects around is unique to Sage.
Example: A Symbolic Expression
Plotting functions has similar syntax to Mathematica:
Sage can also has 2d plotting that is almost identical to MATLAB:
_fast_float_ yields super-fast evaluation of Sage symbolic expressions -- e.g., here it is 10 times faster than native Python!
Example: Compare Answers with Maple
The command maple(...) fires up Maple (if you have it!), and creates a reference to a live object:
Use Maple objects via a Pythonic notation:
Example: Interactive Image Compression
This illustrates pylab (matplotlib + numpy), Sage plotting, html output, and @interact.
Example: 3d Plots
3d plotting (using jmol) is fast even though it does not use Java3d or OpenGL or require any special signed code or drivers.
Real World Example: Super Fast Code (using Cython)
to sage-support date Sat, Jan 31, 2009 at 11:15 AM Hi, I received first a MemoryError, and later on Sage reported: uitkomst1=[] uitkomst2=[] eind=int((10^9+2)/(2*sqrt(3))) print eind for y in srange(1,eind): test1=is_square(3*y^2+1,True) test2=is_square(48*y^2+1,True) if test1[0] and test1[1]%3==2: uitkomst1.append((y,(2*test1[1]-1)/3)) if test2[0] and test2[1]%3==1: uitkomst2.append((y,(2*test2[1]+1)/3)) print uitkomst1 een=sum([3*x-1 for (y,x) in uitkomst1 if 3*x-1<10^9]) print uitkomst2 twee=sum([3*x+1 for (y,x) in uitkomst2 if 3*x+1<10^9]) print een+twee If you replace 10^9 with 10^6, the above listing works properly. Maybe I made a mistake? Rolandb
I rewrote Roland's code slightly so it wouldn't waste memory by constructing big lists... but the result was slow.
While waiting to see if f_python(10^6) would finish, I decided to try the Cython compiler. I declared a few data types, put %cython at the top of the cell, and wham, it got over 200 times faster.
This is not a contrived example. This is a real world example that came up a this weekend. For C-style computations, Sage (via Cython) is as fast as C.
Example: Do some number theory
Plotting an elliptic curve over a finite field
and finding its group structure...
Creating another random elliptic curve over a bigger finite field and compute its cardinality in seconds:
Some weight 3 modular forms on :