
// Make newform 5733.2.a.l in Magma, downloaded from the LMFDB on 19 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_5733_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_5733_2_a_l();".
// 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_5733_2_a_l();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_5733_a();"
function MakeCharacter_5733_a()
    N := 5733;
    order := 1;
    char_gens := [2549, 1522, 5293];
    v := [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_5733_a_Hecke( : Kf := Kf)
    return MakeCharacter_5733_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 := [[2], [0], [-3], [0], [6], [1], [4], [-5], [-3], [5], [3], [-4], [-6], [-1], [7], [9], [8], [10], [-6], [8], [13], [3], [15], [3], [-7], [-14], [4], [4], [-2], [3], [-4], [8], [-4], [18], [18], [0], [8], [-4], [5], [-8], [-23], [-14], [8], [22], [-2], [-4], [-5], [-15], [20], [-14], [-15], [4], [17], [-26], [-2], [15], [0], [-8], [1], [30], [-16], [-19], [33], [-6], [-22], [24], [22], [17], [32], [-11], [-10], [-20], [-14], [30], [-6], [-36], [-30], [13], [32], [13], [-10], [-12], [-6], [-12], [22], [-19], [-36], [0], [-22], [-14], [-22], [-11], [-26], [12], [-16], [2], [-19], [40], [-10], [-40], [-7], [12], [4], [-7], [-17], [-2], [39], [-27], [-11], [10], [-2], [8], [30], [-20], [22], [-9], [-8], [18], [-18], [-17], [33], [1], [22], [12], [-11], [27], [-10], [18], [-46], [-51], [-26], [-36], [-17], [-15], [9], [35], [54], [-37], [18], [31], [52], [6], [-32], [-4], [10], [-8], [-45], [-6], [2], [32], [0], [-30], [-4], [-12], [7], [15], [8], [5], [8], [55], [18], [39], [22], [38], [-10], [17], [4], [28], [-26], [8], [-54], [-30], [-1], [-28], [64], [0], [48], [-54], [-22], [14], [-4], [18], [6], [-23], [46], [18], [55], [35], [6], [9], [36], [66], [-1], [-3], [-21], [12], [54], [29], [11], [-38], [52], [44], [-47], [4], [7], [36], [-17], [33], [36], [-6], [35], [-40], [-32], [60], [-49], [-25], [-53], [-24], [-12], [-32], [53], [-56], [12], [14], [-6], [31], [-24], [-45], [6], [-18], [-46], [-16], [20], [-30], [14], [-49], [66], [20], [-57], [-54], [-12], [74], [-44], [-62], [23], [0], [49], [33], [-32], [-61], [28], [-42], [30], [-78], [18], [24], [-65], [4], [48], [-27], [-61], [43], [-67], [-70], [-2], [-46], [-62], [15], [-6], [46], [6], [68], [70], [77], [-32], [48], [60], [-64], [-52], [-36], [54], [26], [-68], [-59], [-12], [-39], [-61], [48], [-64], [-8], [45], [48], [26], [53], [-67], [-72], [-38], [0], [-28], [55], [-34], [-12], [-9], [-31], [17], [70], [-12], [-16], [-54], [31], [-40], [18], [-38], [41], [64], [0], [33], [10], [-9], [-5], [-64], [-60], [-54], [44], [32], [0], [28], [53], [-36], [26], [14], [-23], [-26], [39], [94], [1], [8], [-70], [14], [38], [-28], [-94], [-30], [88], [-24], [24], [-30], [-48], [81], [18], [23], [-78], [-64], [94], [-74], [-6], [71], [-1], [38], [-58], [6], [42], [-79], [4], [-6], [-17], [25], [6], [-33], [84], [70], [-16], [-51], [44], [-53], [12], [72], [74], [-12], [78], [-87], [-34], [-24], [32], [65], [-17], [-8], [-16], [-92], [28], [46], [-21], [-4], [-100], [20], [25], [-24], [30], [-35], [64], [-77], [-3], [-22], [-13], [33], [-96], [16], [-68], [89], [-77], [16], [87], [31], [-44], [-57], [-92], [-36], [24], [-14], [56], [-39], [58], [-84], [-16], [22], [57], [-91], [84], [65], [-66]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_5733_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_5733_2_a_l();".
// 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_5733_2_a_l(:prec:=1)
    chi := MakeCharacter_5733_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_5733_2_a_l();".
// 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_5733_2_a_l( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_5733_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-2, 1]>,<5,R![3, 1]>,<11,R![-6, 1]>,<17,R![-4, 1]>,<19,R![5, 1]>,<31,R![-3, 1]>],Snew);
    return Vf;
end function;