
// Make newform 3024.2.a.m in Magma, downloaded from the LMFDB on 23 December 2025.
// 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_m();".
// 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_m();".
// 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], [-1], [1], [5], [0], [-2], [1], [-1], [-4], [9], [5], [9], [10], [6], [-12], [-14], [0], [8], [-13], [-2], [-6], [-4], [9], [16], [14], [1], [12], [7], [2], [0], [22], [-16], [20], [-6], [-10], [8], [4], [10], [-7], [24], [18], [-3], [-10], [10], [13], [22], [-5], [6], [28], [-14], [24], [14], [-24], [-27], [-21], [-13], [-24], [-19], [10], [20], [-18], [5], [-8], [-8], [18], [4], [27], [-3], [-26], [3], [4], [-35], [-17], [14], [-10], [20], [-30], [12], [-10], [6], [-27], [-15], [-4], [-24], [11], [-10], [13], [-31], [14], [-26], [32], [-26], [9], [-10], [36], [-18], [15], [-11], [-3], [-12], [-22], [-4], [-30], [-18], [-14], [14], [-9], [-27], [8], [-12], [-15], [-14], [11], [-38], [22], [13], [42], [30], [17], [28], [26], [-27], [-9], [4], [20], [-25], [-30], [32], [-18], [-18], [-21], [-18], [42], [22], [40], [-19], [0], [33], [20], [-1], [10], [-34], [-33], [10], [-4], [-16], [-3], [25], [16], [-50], [15], [-32], [36], [-30], [-24], [-4], [42], [-28], [-13], [-17], [-44], [-2], [36], [-60], [-30], [4], [38], [17], [21], [4], [-14], [48], [-45], [9], [-25], [60], [10], [-17], [-28], [6], [-10], [43], [-58], [37], [45], [54], [-44], [-45], [-48], [-56], [12], [62], [-50], [-15], [55], [-43], [-62], [57], [42], [-48], [51], [14], [48], [0], [18], [-20], [39], [42], [4], [41], [-37], [-18], [10], [-12], [8], [-52], [-53], [-61], [64], [-14], [32], [12], [14], [-42], [29], [13], [1], [21], [-3], [-57], [11], [44], [-30], [1], [-72], [34], [-24], [-36], [-68], [-19], [-65], [-29], [-21], [61], [6], [45], [-16], [4], [57], [-2], [-78], [24], [46], [-59], [-1], [59], [3], [-10], [-58], [2], [19], [4], [-14], [3], [71], [-24], [-10], [-58], [-24], [78], [16], [0], [-20], [-38], [-9], [-61], [18], [58], [-24], [18], [-18], [-54], [14], [45], [-1], [-39], [22], [19], [-63], [6], [18], [-48], [46], [-61], [33], [19], [-6], [-12], [-75], [-62], [84], [26], [87], [-74], [-25], [-41], [-22], [71], [23], [42], [26], [44], [-44], [13], [-64], [-12], [67], [80], [30], [4], [1], [-15], [86], [44], [-88], [22], [35], [-52], [46], [-43], [10], [21], [-28], [44], [-68], [-63], [-7], [14], [11], [-1], [-12], [18], [60], [54], [-12], [62], [-8], [84], [-18], [-77], [-58], [-60], [39], [-29], [-41], [-26], [-36], [34], [-40], [10], [61], [-56], [5], [20], [-67], [75], [30], [-5], [-13], [-91], [-24], [-22], [-73], [-83], [6], [-16], [22], [31], [44], [57], [2], [-40], [-42], [77], [-26], [46], [88], [-4], [80], [-34], [51], [-85], [-8], [40], [-69], [-19], [-5], [54], [40], [62], [-84], [-34], [29], [15], [-41], [-23], [-60], [-95], [8], [4], [82], [44], [60], [-82], [-29], [53], [56], [18], [-50], [28], [32], [29], [90], [-70], [-82], [76], [48], [-33], [-88]];
    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_m();".
// 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_m(: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_m();".
// 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_m( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_3024_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![1, 1]>,<11,R![-5, 1]>,<17,R![2, 1]>],Snew);
    return Vf;
end function;