0% found this document useful (0 votes)
59 views

Quickref NT

This document provides a summary of key concepts in elementary number theory and modular arithmetic, including definitions for integers, greatest common divisors, prime numbers, modular arithmetic, and continued fractions. It also briefly introduces elliptic curves and some of their key properties.

Uploaded by

Patangka Auau
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Quickref NT

This document provides a summary of key concepts in elementary number theory and modular arithmetic, including definitions for integers, greatest common divisors, prime numbers, modular arithmetic, and continued fractions. It also briefly introduces elliptic curves and some of their key properties.

Uploaded by

Patangka Auau
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Sage Quick Reference:

Elementary Number Theory Modular Arithmetic and Congruences Continued Fractions


William Stein k=12; m = matrix(ZZ, k, [(i*j)%k for i in [0..k-1] for j in [0..k-1]]); m.plot(cmap=’gray’) continued_fraction(pi)
Sage Version 3.4 0 1 2 3 4 5 6 7 8 9 10 11
0 0
http://wiki.sagemath.org/quickref 1 1 1
2 2 π =3+
GNU Free Document License, extend for your own use 3 3
1
4 4
7+
5 5
1
15 +
6 6 1
Everywhere m, n, a, b, etc. are elements of ZZ 7 7 1+
8 8 292 + · · ·
ZZ = Z = all integers 9 9
10 10
11
0 1 2 3 4 5 6 7 8 9 10 11
11 continued fraction: c=continued fraction(x, bits)
Integers convergents: c.convergents()
. . . , −2, −1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, . . . Euler’s φ(n) function: euler phi(n)
n divided by m has remainder n % m convergent numerator pn = c.pn(n)
Kronecker symbol ab = kronecker symbol(a,b)

gcd(n,m), gcd(list) convergent denominator qn = c.qn(n)
Quadratic residues: quadratic residues(n)
extended gcd g = sa + tb = gcd(a, b): g,s,t=xgcd(a,b) value: c.value()
Quadratic non-residues: quadratic residues(n)
lcm(n,m), lcm(list) ring Z/nZ = Zmod(n) = IntegerModRing(n)
Elliptic Curves
binomial coefficient m

n = binomial(m,n) a modulo n as element of Z/nZ: Mod(a, n)
EllipticCurve([0,0,1,-1,0]).plot(plot_points=300,thickness=3)
digits in a given base: n.digits(base) primitive root modulo n = primitive root(n) 1.5
1
number of digits: n.ndigits(base) inverse of n (mod m): n.inverse mod(m) 0.5
-1 -0.5 0.5 1 1.5
-0.5
(base is optional and defaults to 10) power an (mod m): power mod(a, n, m) -1
-1.5
-2
divides n | m: n.divides(m) if nk = m some k Chinese remainder theorem: x = crt(a,b,m,n)
divisors – all d with d | n: n.divisors() finds x with x ≡ a (mod m) and x ≡ b (mod n) E = EllipticCurve([a1 , a2 , a3 , a4 , a6 ])
factorial – n! = n.factorial() discrete log: log(Mod(6,7), Mod(3,7)) y 2 + a1 xy + a3 y = x3 + a2 x2 + a4 x + a6
order of a (mod n) =Mod(a,n).multiplicative order()
Prime Numbers conductor N of E =E.conductor()
square root of a (mod n) =Mod(a,n).sqrt()
discriminant ∆ of E =E.discriminant()
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, . . .
Special Functions rank of E = E.rank()
factorization: factor(n)
free generators for E(Q) = E.gens()
primality testing: is prime(n), is pseudoprime(n) complex_plot(zeta, (-30,5), (-8,8))
j-invariant = E.j invariant()
prime power testing: is prime power(n)
8 Np = #{solutions to E modulo p} = E.Np(prime)
π(x) = #{p : p ≤ x is prime} = prime pi(x) 6
4 ap = p + 1 − Np =E.ap(prime)
set of prime numbers: Primes() 2 P an
-30 -25 -20 -15 -10 -5 5
L(E, s) = ns = E.lseries()
{p : m ≤ p < n and p prime} =prime range(m,n) -2
-4 ords=1 L(E, s) = E.analytic rank()
prime powers: prime powers(m,n) -6
-8
first n primes: primes first n(n)
Elliptic Curves Modulo p
next and previous primes: next prime(n),
1 1 EllipticCurve(GF(997), [0,0,1,-1,0]).plot()
Q P
previous prime(n), next probable prime(n) ζ(s) = p −s = ns = zeta(s)
R x 1−p1 1000

prime powers: Li(x) = 2 log(t) dt = Li(x) 750

500

next prime power(n), pevious prime power(n) R∞


Γ(s) = 0 ts−1 e−t dt = gamma(s) 250

Lucas-Lehmer test for primality of 2p − 1 250 500 750 1000

def is_prime_lucas_lehmer(p): E = EllipticCurve(GF(p), [a1 , a2 , a3 , a4 , a6 ])


s = Mod(4, 2^p - 1) #E(Fp ) = E.cardinality()
for i in range(3, p+1): s = s^2 - 2
generators for E(Fp ) = E.gens()
return s == 0
E(Fp ) =E.points()

You might also like