
// Make newform 5808.2.a.ci in Magma, downloaded from the LMFDB on 10 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_5808_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_5808_2_a_ci();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_5808_2_a_ci();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [-1, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_5808_a();"
function MakeCharacter_5808_a()
    N := 5808;
    order := 1;
    char_gens := [3631, 4357, 1937, 2785];
    v := [1, 1, 1, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

function MakeCharacter_5808_a_Hecke( : Kf := Kf)
    return MakeCharacter_5808_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..prec]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 2;
    raw_aps := [[0, 0], [1, 0], [0, 1], [-1, 0], [0, 0], [1, 2], [3, 3], [4, -3], [1, 2], [6, 0], [3, -5], [-5, 2], [1, 2], [-3, 6], [7, -5], [-1, -1], [-8, -1], [6, -9], [0, 3], [-6, 7], [2, -6], [11, 0], [-1, -4], [-7, 2], [6, -3], [9, -2], [6, -8], [-9, 4], [12, 0], [11, -4], [4, -6], [-5, 11], [11, 2], [9, -9], [3, -2], [6, 8], [12, -6], [7, 3], [4, -13], [10, -13], [11, 4], [5, 4], [7, 10], [5, 3], [-5, 13], [-3, 6], [3, -1], [-1, 10], [7, -10], [-2, -4], [6, 3], [1, 1], [-12, -6], [9, -21], [18, -19], [-6, 15], [-18, 12], [18, -1], [15, -23], [-26, -2], [-2, 6], [13, -14], [15, -21], [-3, 14], [-5, -4], [-13, -10], [-13, 6], [12, -10], [-4, -4], [-9, 6], [-12, 0], [-6, 6], [-24, -3], [9, 16], [15, -16], [9, -6], [-25, 19], [-15, 6], [-15, 27], [4, -4], [-16, 25], [0, -17], [-9, -5], [18, -28], [27, 6], [18, -22], [-14, -8], [-11, 21], [0, 15], [-11, -15], [-11, 16], [-29, -1], [9, -6], [-21, -5], [20, 3], [0, -14], [27, -19], [4, -8], [9, -15], [18, 17], [-19, 19], [-16, 35], [27, -22], [-28, 10], [-6, 5], [28, -6], [-9, -18], [6, -13], [-4, 14], [-3, -16], [-11, 9], [18, 6], [5, -10], [-13, 18], [-5, 23], [-22, 5], [-19, 3], [-37, 13], [-5, 1], [-30, 18], [31, -9], [-21, 24], [-16, -4], [7, 26], [-10, -14], [28, -11], [-3, -23], [15, -38], [11, 3], [14, 22], [3, 0], [-33, 16], [-18, -3], [5, 0], [-33, -6], [24, -17], [21, -10], [-6, 6], [0, -30], [-24, 5], [31, -9], [-27, 22], [13, -24], [-2, 14], [-11, 33], [3, -24], [41, -24], [-29, -2], [27, -12], [-10, -16], [53, -8], [13, 11], [-6, -8], [-31, 38], [22, -33], [-25, 22], [17, -14], [-9, 6], [-33, 14], [-1, -25], [12, -33], [-20, -14], [26, -29], [42, 0], [13, 22], [18, 16], [8, 19], [28, 11], [-37, 13], [24, -6], [36, -25], [-45, 27], [8, -31], [22, -18], [42, -12], [28, -16], [-48, -2], [-38, 16], [-38, 26], [-18, 18], [19, 26], [-5, -26], [-31, 24], [-45, -3], [-2, -29], [-6, 25], [-24, 34], [-3, -25], [-14, 15], [-57, 9], [-24, 21], [-3, 18], [-15, -24], [-18, 12], [36, 3], [-13, 23], [18, -30], [-9, -21], [-18, -4], [-34, 25], [14, -14], [-38, -4], [-38, -18], [-43, -14], [9, 12], [29, 5], [22, -9], [27, 23], [-29, -14], [-18, -12], [14, -39], [33, -34], [12, 0], [-14, 2], [5, -32], [-13, 3], [12, -14], [26, -19], [-31, 8], [-54, 18], [13, 5], [56, 0], [1, -20], [-42, -9], [4, -11], [-21, 20], [-8, 37], [7, 26], [17, 6], [-22, -13], [26, -2], [9, 15], [-35, -4], [-10, 26], [14, 34], [-54, 30], [-1, -3], [2, -22], [-34, 14], [-11, -13], [-18, 34], [4, 15], [-23, 56], [46, 6], [-38, 47], [7, -17], [18, -51], [18, -24], [-3, 46], [-52, -4], [51, 3], [-36, 57], [32, -64], [30, 0], [32, 5], [33, 0], [-5, -18], [-36, -16], [27, 14], [-47, -7], [-50, 3], [23, 14], [24, -29], [-21, -15], [-20, -35], [-25, 4], [-19, 2], [-18, 6], [-36, 4], [15, 39], [-8, 20], [-52, 27], [-5, -40], [12, 9], [-17, 12], [22, -19], [-27, -6], [-5, -28], [-64, 19], [-37, -14], [-39, 1], [-56, 38], [15, -10], [23, 21], [-28, 12], [23, -7], [-51, 3], [17, -1], [-14, 6], [27, 28], [-4, 23], [20, 14], [37, -44], [-9, -42], [33, 33], [61, -5], [-51, -12], [31, -38], [-6, 29], [-22, 27], [27, -32], [39, -74], [29, 3], [-48, -7], [-21, 18], [36, 12], [42, 6], [-10, 24], [-7, 7], [18, -9], [-8, 7], [-27, -36], [9, -21], [75, 3], [27, 6], [-45, 5], [24, -66], [-67, 16], [-26, 24], [33, -38], [-20, -34], [-29, 24], [53, -20], [27, -51], [31, -8], [24, 0], [51, 15], [24, -53], [-52, 53], [12, 4], [-28, 34], [-36, 20], [-3, -51], [48, 0], [-4, -18], [-51, 9], [-9, -27], [33, -24], [44, 15], [-4, 46], [-3, 37], [25, 34], [18, -48], [-23, 66], [3, 38], [42, -42], [7, -31], [-6, 21], [-38, -19], [-62, 50], [-42, 68], [2, 10], [3, -21], [51, -60], [1, -33], [-26, 40], [-46, -2], [0, -17], [36, 0], [-12, 57], [32, -53], [53, -20], [21, 7], [60, -36], [-35, 6], [66, -12], [-33, 67], [78, -15], [32, 4], [9, -9], [10, -22], [-41, 55], [2, -16], [-12, 34], [-18, -3], [-35, -22], [-27, -16], [17, -42], [76, -2], [-33, 36], [62, -16], [-21, 4], [5, -54], [68, -43], [56, 13], [43, -25], [-30, 2], [-32, 21], [-43, 60], [-47, 13], [12, -20], [39, -66], [-59, 25], [39, -34], [-87, 3], [7, 44], [26, -6], [-15, 0], [20, 18], [24, -18], [4, 30], [41, -41], [21, -12], [16, 17], [55, -10], [46, -16], [15, -11], [5, 52], [32, 0], [-20, 58], [7, -9], [16, -23], [41, -43], [20, -41], [89, -14], [-1, -7], [-15, 75], [26, -54], [-16, 58], [44, -58], [-18, -10], [-1, 0], [-24, 42], [-12, 66], [-2, -16], [24, -24], [-51, -6], [-1, 35], [-58, 55], [-45, 46]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_5808_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_5808_2_a_ci();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_5808_2_a_ci(:prec:=2)
    chi := MakeCharacter_5808_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_5808_2_a_ci();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_5808_2_a_ci( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_5808_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-1, -1, 1]>,<7,R![1, 1]>,<13,R![-1, -4, 1]>],Snew);
    return Vf;
end function;