Post on 28-Dec-2015
Introduction to SAGE for Number Theory
Pure and Applied Number Theory School2015.8.11
Cheolmin ParkNIMS
SAGE (System for Algebra and Geometry Experimenta-tion):
open-source mathematics software
Sage is a free open-source mathematics software system licensed under the GPL. It combines the power of many existing open-source packages into a common Python-based interface. ◦ Mission: Creating a viable free open source alter-
native to Magma, Maple, Mathematica and Mat-lab.
http://www.sagemath.org/ Current version: 6.8 Free, open source
Sage: what is it?
Sage provides ◦ Basic Algebra and Calculus
Solving Equations, Differentiation, … ◦ Plotting 2,3-dimensional plots ◦ Linear Algebra, Polynomials, Groups ◦ p-adic numbers ◦ Elliptic Curve, …
Easy to use
Sage: introduction
SAGE is Linux based software.
If you want to use SAGE on Window OS, you need to install VirtualBox for Window
which can run linux in Window OS.
Refer to “install guide” in www.sagemath.org/
We use SAGE Online!!!◦ https://cloud.sagemath.com/
Installing SAGE
https://cloud.sagemath.com/
IE9 cannot connect to this site. In this case, use higher version of IE or chrome
browser.
If you already have account, sign in
If not, you need to create account.◦ It is for free.◦ Click item “First, agree to the Terms of Service”◦ Write Name/Email/ Choose a password◦ Click item “Create account for free”
https://cloud.sagemath.com/
Create New Project…
Title…and click “create project”
Click item “⨁New”
https://cloud.sagemath.com/projects
Click “Sage Worksheet”
A very brief Tour of Sage
Run code: click or shift+Enter◦ e.g. 2+3 shift+Enter
Sage uses = for assignment Comparison check: ==, <=, >=, <, > Basic arithmetic
◦ **, ^: exponentiation ( 2^3 == 2**3)◦ %: remainder (10%3)◦ //: quotient◦ sqrt(10), sin(5), sin(pi)
Run, Assignment, Comparison, Arithmetic
Sage use for calling function ◦ variable.function() or function(variable)◦ (eg1) n=2015 n.factor() factor(n)◦ (eg2) M=matrix(2, 2, [1,pi, e,5]) M.det() det(M)
For defining function,
Call and define function
(eg1)def f(a,b): return a+b
(eg2)def fm(a,b): if a >=b: c=a else: c=b return c
Note: indentation is important.
var('x y') f = x^3 * e^(y*x) * sin(y*x); f.diff(x) latex(f.diff(x)) show(f.diff(x)) f(x,3): You can evaluate f at y=3 plot(f(x,3))
Calculus
CC: complex field RR: real field QQ: rational field ZZ: integer ring Integers(n): ring Z/nZ of integers modulo n GF(p): finite field of order p GF(p^n): finite field of order p^n QQ[x]: Univariate Polynomial Ring in x over Ra-
tional Field QQ[x,y]: Multivariate Polynomial Ring in x, y
over Rational Field
Rings and Fields
k.<x> = CC[] (k is univariate polynomial ring in x over complex field)
f=x^3+x factor(f) f.roots()
Change field and try factor(f), f.roots()
Example of Rings and Fields
EllipticCurve(fields(rings),[a1,a2,a3,a4,a5]):Elliptic Curve defined by y^2 + a1*x*y +
a3*y = x^3 + a2*x^2 + a4*x + a5 over Fields
Example ◦ EllipticCurve(QQ,[10,20,30,40,50])◦ k=EllipticCurve(GF(127),[10,20,30,40,50])◦ k.order(), P=k.random_point(), Q=k(75,4)◦ 123*P, P+Q
Elliptic curves
mod(8+5, 7) == (8+5)%7 : (8+5) mod 7 pow(3,6,11) : 3^6 mod 11 inverse_mod(2,19): 2^-1 mod 19 gcd(12, 36); xgcd(3,5) functions related to prime
◦ prime_factor(n), divisors(n), next_prime(n), nth_prime(i), is_prime(n), prime_pi(n) (# of primes less than n), euler_phi(n), primitive_root(p)…
x=crt(y1,y2,p1,p2): x mod p1 =y1, x mod p2 =y2
Basic number functions
P.<x>=QQ[] K.<a>=NumberField(x^2+1) R.<y> = K[]
f = y^2 + y + 1 L.<b> = K.extension(f)
S.<c>=CyclotomicField(n)
Number field
P.<x>=QQ[] K.<a>=NumberField(x^2+1)
OK=K.ring_of_integers() O3 = K.order(3*a); O3 #Z+3aZ O3.gens()
Order
K.<a> = NumberField(x^2 + 23) I = K.fractional_ideal(2, 1/2*a - 1/2) J = I^2 I*J factor(I) factor(J) is_prime(I) I = K.fractional_ideal(2) I.factor() K.class_group()
Fractional ideal of Number field
You can use reference manual or quick search in www.sage.org
use help() in Sage
function??: can see source code of function◦ factor??
Tab completion: Type obj followed by tab to see all completions of obj.◦ fac+tab
Help in SAGE
Thank you!