| Download
All published worksheets from http://sagenb.org
Project: sagenb.org published worksheets
Views: 168768Image: ubuntu2004
Sage Demo and Introduction
Sage is:
- A large free open source mathematics software project that I direct.
- Web-based at http://sagenb.org or you can run it locally.
- Very powerful for number theory, and also combinatorics, graph theory, and numerical analysis (via scipy).
- Uses Python for the main user language.
GCD
3
5
6
How to make up huge random integers:
10000
3
Time: CPU 0.00 s, Wall: 0.00 s
125 loops, best of 3: 1.82 ms per loop
8
1
0
'Integer(2)**Integer(3)'
1/3
'Integer(1)/Integer(3)'
<type 'sage.rings.rational.Rational'>
Rational Field
Rational Field
0
1
-1
1/2
-1/2
2
-2
1/3
-1/3
3
-3
2/3
-2/3
3/2
-3/2
1/4
-1/4
4
-4
3/4
-3/4
4/3
-4/3
1/5
-1/5
5
-5
2/5
-2/5
5/2
-5/2
3/5
-3/5
5/3
-5/3
4/5
-4/5
5/4
-5/4
1/6
-1/6
6
-6
5/6
-5/6
6/5
-6/5
1/7
-1/7
7
-7
2/7
-2/7
7/2
-7/2
3/7
-3/7
7/3
-7/3
4/7
-4/7
7/4
-7/4
5/7
-5/7
7/5
-7/5
6/7
-6/7
7/6
-7/6
1/8
-1/8
8
-8
3/8
-3/8
8/3
-8/3
5/8
-5/8
8/5
-8/5
7/8
-7/8
8/7
-8/7
1/9
-1/9
9
-9
2/9
-2/9
9/2
-9/2
4/9
-4/9
9/4
-9/4
5/9
-5/9
Enumerating Primes
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
[101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
Sieving Primes
Mersenne Primes
The prime below is the largest known prime. The GIMPS project found it, winning them a \$100,000 prize from the EFF, since it has > ten million digits.
Time: CPU 0.01 s, Wall: 0.01 s
Time: CPU 14.26 s, Wall: 14.44 s
12978189
Last 10 digits:
[3, 9, 6, 2, 0, 7, 4, 6, 1, 3]
First 10 digits:
[1, 1, 5, 2, 5, 1, 7, 9, 6, 6]
Frequency histogram of first digits:
Counting Primes
Function that counts the number of primes up to x
50847534
10 4
100 25
1000 168
10000 1229
100000 9592
Wait, that looks like a nice clean smooth curve? What is it "basically" a plot of?
The Riemann Hypothesis is a conjectural answer to this question...