// Magma code for working with number field 2.2.5.1

// Some of these functions may take a long time to execute (this depends on the field).

// Define the number field: 
R<x> := PolynomialRing(Rationals()); K<a> := NumberField(x^2 - x - 1);

// Defining polynomial: 
DefiningPolynomial(K);

// Degree over Q: 
Degree(K);

// Signature: 
Signature(K);

// Discriminant: 
OK := Integers(K); Discriminant(OK);

// Ramified primes: 
PrimeDivisors(Discriminant(OK));

// Autmorphisms: 
Automorphisms(K);

// Integral basis: 
IntegralBasis(K);

// Class group: 
ClassGroup(K);

// Unit group: 
UK, fUK := UnitGroup(K);

// Unit rank: 
UnitRank(K);

// Generator for roots of unity: 
K!f(TU.1) where TU,f is TorsionUnitGroup(K);

// Fundamental units: 
[K|fUK(g): g in Generators(UK)];

// Regulator: 
Regulator(K);

// Analytic class number formula: 
/* self-contained Magma code snippet to compute the analytic class number formula */
Qx<x> := PolynomialRing(Rationals()); K<a> := NumberField(x^2 - x - 1);
OK := Integers(K); DK := Discriminant(OK);
UK, fUK := UnitGroup(OK); clK, fclK := ClassGroup(OK);
r1,r2 := Signature(K); RK := Regulator(K); RR := Parent(RK);
hK := #clK; wK := #TorsionSubgroup(UK);
2^r1 * (2*Pi(RR))^r2 * RK * hK / (wK * Sqrt(RR!Abs(DK)));

// Intermediate fields: 
L := Subfields(K); L[2..#L];

// Galois group: 
G = GaloisGroup(K);

// Frobenius cycle types: 
// to obtain a list of $[e_i,f_i]$ for the factorization of the ideal $p\mathcal{O}_K$ for $p=7 in Magma:
p := 7; [<pr[2], Valuation(Norm(pr[1]), p)> : pr in Factorization(p*Integers(K))];