
// Make newform 3024.2.a.bd in Magma, downloaded from the LMFDB on 01 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_3024_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_3024_2_a_bd();".
// 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_3024_2_a_bd();".
// 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_3024_a();"
function MakeCharacter_3024_a()
    N := 3024;
    order := 1;
    char_gens := [1135, 757, 785, 2593];
    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_3024_a_Hecke( : Kf := Kf)
    return MakeCharacter_3024_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], [4], [1], [4], [3], [-7], [-2], [1], [1], [9], [2], [6], [-11], [6], [-9], [5], [-6], [-7], [7], [-14], [6], [4], [-3], [-8], [10], [-17], [-12], [16], [-8], [0], [-1], [22], [-10], [-3], [-10], [17], [1], [8], [-8], [12], [-9], [-12], [5], [26], [7], [1], [-8], [9], [-14], [-4], [-12], [-10], [0], [30], [-9], [4], [-3], [8], [-10], [-28], [6], [2], [8], [-26], [-18], [31], [27], [-18], [25], [15], [11], [25], [-38], [8], [4], [-14], [6], [30], [2], [33], [-6], [-24], [8], [-9], [-26], [4], [-29], [-14], [-22], [8], [-8], [-26], [-24], [-28], [24], [-6], [-15], [16], [-36], [-36], [1], [-11], [12], [39], [10], [25], [-18], [-21], [-28], [-39], [-6], [14], [14], [4], [-28], [4], [-42], [3], [28], [-14], [23], [0], [48], [40], [-2], [-40], [-48], [29], [-15], [-12], [-51], [-6], [-12], [-13], [4], [4], [-18], [-18], [-32], [26], [-13], [38], [-42], [-26], [10], [53], [27], [-2], [-1], [-8], [15], [19], [12], [-12], [48], [-22], [-30], [-52], [-2], [2], [8], [40], [15], [-42], [-36], [-26], [35], [11], [-36], [-34], [-23], [51], [-9], [24], [-29], [-33], [23], [16], [-1], [48], [61], [28], [-29], [-37], [6], [24], [-8], [45], [30], [16], [6], [-37], [8], [6], [-61], [-19], [34], [33], [36], [45], [-57], [-10], [-54], [33], [60], [1], [0], [-12], [-2], [-49], [70], [42], [-7], [18], [8], [-46], [14], [25], [-1], [-14], [32], [24], [8], [36], [-34], [53], [-40], [-57], [30], [0], [56], [-58], [-12], [52], [60], [-14], [-39], [18], [50], [-38], [-50], [7], [12], [17], [-54], [15], [-20], [49], [15], [-20], [-9], [9], [10], [26], [-14], [32], [48], [40], [44], [50], [-28], [-2], [-2], [9], [-28], [18], [22], [11], [6], [-3], [-68], [60], [4], [46], [-33], [-2], [-6], [-2], [-33], [-18], [42], [-72], [47], [-48], [-80], [30], [53], [-41], [21], [-42], [-39], [-24], [-55], [-10], [18], [-80], [18], [21], [30], [-50], [15], [-10], [-30], [43], [-79], [-52], [65], [-80], [68], [84], [61], [58], [79], [5], [56], [45], [-16], [-4], [12], [70], [-74], [48], [-46], [-80], [-16], [-53], [-34], [85], [-70], [80], [-22], [60], [52], [65], [-19], [30], [-83], [62], [-16], [-46], [-78], [-72], [-78], [-75], [-78], [95], [61], [0], [72], [-44], [-73], [-45], [9], [28], [38], [-40], [-84], [50], [-56], [-8], [53], [-55], [22], [38], [-22], [48], [-36], [-35], [34], [92], [51], [-89], [-25], [-38], [93], [61], [-80], [26], [86], [-42], [-44], [32], [6], [-52], [-58], [70], [73], [59], [40], [-25], [72], [34], [58], [23], [21], [65], [65], [57], [47], [-25], [-36], [26], [-53], [60], [64], [40], [12], [88], [7], [34], [-73], [-80], [75], [83], [98], [25], [-64], [-51], [-34], [59], [23], [88], [-69], [104], [76], [-88], [-12], [-42], [16]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3024_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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