
// Make newform 2808.2.a.p in Magma, downloaded from the LMFDB on 17 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2808_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_2808_2_a_p();".
// 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_2808_2_a_p();".
// 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 := [-4, -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_2808_a();"
function MakeCharacter_2808_a()
    N := 2808;
    order := 1;
    char_gens := [703, 1405, 2081, 1081];
    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_2808_a_Hecke( : Kf := Kf)
    return MakeCharacter_2808_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], [0, 0], [-1, -1], [2, 1], [-4, 1], [1, 0], [-4, 0], [2, -2], [2, -3], [2, 3], [-2, 3], [2, -3], [-6, 4], [-5, -2], [-1, -3], [0, -1], [1, 2], [-13, 1], [4, -4], [-3, 3], [-12, 0], [8, 0], [-11, 4], [-1, 0], [4, -8], [-8, 1], [5, -7], [-10, 6], [-4, 2], [6, 4], [5, -5], [0, -2], [6, 1], [-15, 3], [5, -11], [0, 8], [-7, -1], [4, -4], [-11, -5], [-16, 2], [-6, -6], [-23, -1], [-12, 3], [-12, 6], [-1, -3], [17, 1], [-13, 0], [4, 0], [-13, -3], [2, 1], [-16, 4], [-8, 2], [8, 2], [26, -2], [14, -4], [-4, -7], [-22, -1], [20, -4], [-1, 3], [-7, 0], [7, 2], [22, 2], [-2, 10], [20, -1], [1, 10], [-18, -4], [14, 2], [9, -8], [6, 6], [-14, -4], [21, 0], [13, -5], [0, 2], [13, -5], [18, 4], [-8, 14], [-14, 12], [16, 3], [27, -2], [10, 2], [24, 2], [-14, 12], [-7, -1], [-10, -7], [-15, -5], [14, -4], [19, 3], [12, 0], [3, -5], [20, -13], [-28, 2], [17, 1], [-10, -5], [12, 0], [16, -2], [4, -9], [3, 3], [-28, 0], [-3, -13], [-28, 3], [-4, 11], [10, -14], [20, 0], [28, 0], [-3, 19], [-6, 4], [-12, 5], [10, -19], [-8, -12], [17, 4], [0, 12], [-24, 9], [9, 5], [24, -10], [-22, 15], [-10, -10], [-4, 4], [10, -7], [8, 2], [-10, 8], [-28, -3], [7, -5], [4, -6], [33, 6], [22, 2], [4, -18], [6, 0], [-8, 13], [0, -18], [28, -13], [26, 4], [21, -7], [0, 2], [6, 10], [-7, 2], [-2, -2], [1, 5], [-28, 6], [-10, -13], [-20, 4], [-16, -6], [46, -4], [-3, 7], [8, -5], [-21, -5], [31, -9], [14, 3], [-10, -12], [-24, 11], [11, 11], [12, 9], [44, 4], [8, 3], [-16, 9], [-1, -7], [-12, -3], [-21, 5], [-30, -11], [-9, -12], [-14, 0], [-19, 6], [10, -22], [-20, 5], [-18, -6], [-9, -10], [-16, 10], [-23, -7], [3, 11], [22, -4], [-6, 21], [-25, 18], [-2, -9], [-14, 14], [-24, 6], [-9, 7], [-6, -14], [-2, 8], [21, 13], [9, -21], [-10, 10], [-16, 8], [-22, 0], [17, 15], [-37, 8], [27, 1], [-18, -17], [-15, -13], [4, 10], [26, -26], [44, 6], [-9, -12], [35, 4], [11, -6], [-3, 25], [6, 10], [10, -2], [-20, 0], [-3, -7], [7, -29], [-52, -3], [15, -17], [17, -9], [-30, 0], [19, 16], [15, -3], [-34, 4], [4, -25], [-6, -4], [43, -4], [-25, -4], [-30, 20], [-40, 17], [-11, 11], [-25, 17], [-35, -9], [-8, -10], [-16, -18], [-24, 20], [16, -12], [45, -7], [13, -11], [-42, 13], [-38, 15], [-6, 13], [24, 18], [-2, 26], [-32, 12], [-30, -14], [-19, 27], [35, -12], [14, 14], [-25, 20], [56, -5], [-6, 18], [-27, -4], [32, -24], [4, -8], [-15, -19], [-12, -4], [10, -19], [19, -14], [0, 11], [-16, 8], [-20, 9], [-30, 9], [2, 3], [-12, -17], [-31, -1], [-24, 12], [-20, 20], [8, 5], [-18, -9], [-24, 18], [-34, -5], [28, 1], [-23, -13], [-33, 11], [22, 16], [-40, 18], [50, 8], [-13, 13], [42, -20], [-50, 1], [18, 0], [-1, 23], [37, -5], [-6, -10], [45, 4], [-26, 20], [-18, 5], [-50, 4], [38, -6], [-50, 10], [75, -3], [43, -4], [36, 9], [7, -4], [-30, 19], [30, -2], [-22, -4], [-26, 14], [56, 7], [-6, 26], [40, 13], [-54, -8], [-30, 5], [49, -10], [-63, -1], [-24, -17], [10, 18], [24, -35], [20, -2], [26, 5], [20, 4], [-46, 16], [-28, -7], [-56, 6], [46, -11], [-12, 14], [46, -14], [-7, 9], [11, 15], [-17, -19], [14, 4], [7, 8], [42, -10], [12, 0], [30, -36], [-8, -8], [-54, 12], [-58, 9], [-2, -22], [68, -4], [-53, 17], [-5, -3], [-29, 4], [-36, 16], [7, 21], [-12, 6], [-60, 12], [-3, 10], [-46, 16], [40, 3], [0, 16], [11, 2], [-15, -15], [48, -16], [-8, 10], [40, 12], [-58, 5], [-12, 13], [-62, 5], [-16, -20], [16, 5], [-34, -6], [24, -19], [30, -31], [21, -16], [14, 4], [32, -6], [6, -27], [-2, -24], [61, -9], [-29, 13], [50, 12], [24, 14], [-5, 27], [-54, 26], [-8, -2], [10, -8], [-30, 4], [6, -6], [-19, -1], [37, 9], [-51, -13], [-48, 2], [21, -41], [9, 4], [-6, -6], [-63, 19], [28, -10], [-6, -16], [34, 22], [45, 19], [32, 25], [29, 8], [-14, 20], [-14, -2], [63, -1], [62, 2], [15, -8], [0, 4], [-20, 11], [-43, -5], [49, -23], [-27, -10], [18, -39], [-22, -24], [-34, 24], [-11, 21], [-18, 24], [21, 17], [-16, -20], [-37, 20], [34, -2], [32, -8], [52, 1], [-33, -1], [10, 8], [6, 18], [-18, -24], [13, -31], [40, -7], [55, 1], [75, 1], [6, 1], [18, -15], [20, -44], [-15, -8], [19, 11], [-44, -2], [22, -12], [52, -12], [-70, 16], [-46, 14], [24, -18], [-20, 15], [39, -9], [-18, -22], [-85, -3], [29, -24], [-8, 6], [-56, 4], [-56, 12], [19, -28], [20, -5], [-11, -19], [-7, 33], [-9, 6], [28, 16], [52, -30], [4, -38], [43, -5], [46, -24], [-26, 10], [6, -38], [8, -14], [7, 8], [-38, 18], [46, -33]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2808_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2808_2_a_p();".
// 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_2808_2_a_p(:prec:=2)
    chi := MakeCharacter_2808_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_2808_2_a_p();".
// 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_2808_2_a_p( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2808_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-2, 3, 1]>,<7,R![2, -5, 1]>,<11,R![8, 7, 1]>],Snew);
    return Vf;
end function;