
// Make newform 624.4.a.g in Magma, downloaded from the LMFDB on 13 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_624_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_624_4_a_g();".
// 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_624_4_a_g();".
// 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_624_a();"
function MakeCharacter_624_a()
    N := 624;
    order := 1;
    char_gens := [79, 469, 209, 145];
    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_624_a_Hecke( : Kf := Kf)
    return MakeCharacter_624_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 := 4;
    raw_aps := [[0], [3], [-12], [-2], [36], [13], [-78], [-74], [96], [18], [214], [-286], [-384], [-524], [-300], [558], [-576], [74], [-38], [456], [-682], [-704], [888], [-1020], [110], [-990], [-1208], [-996], [-1402], [1926], [988], [2100], [-2496], [2464], [216], [898], [-1510], [394], [-84], [1194], [-3156], [-1078], [-3192], [722], [2796], [340], [1924], [-5042], [2676], [-2410], [3726], [-1248], [-4210], [7692], [1326], [6048], [6474], [-5978], [8750], [8976], [592], [-4608], [3166], [-2472], [-3094], [2316], [4426], [866], [2556], [-11014], [-9720], [2988], [2068], [902], [-12818], [1332], [3054], [11162], [-14820], [-9682], [348], [2486], [1812], [-6226], [12544], [8556], [4116], [-6514], [10500], [5542], [5220], [-11592], [-12170], [-1812], [1330], [2688], [5124], [-882], [2320], [21422], [-7040], [-8400], [-19044], [-4698], [8728], [2018], [-11376], [-25596], [-3480], [10010], [-3764], [13610], [6408], [6694], [27250], [-12630], [-14798], [-26232], [-30390], [28740], [-9214], [16598], [-8610], [-804], [-2270], [1782], [-10690], [-11568], [11644], [-15010], [-33410], [6504], [13912], [-23974], [-288], [1514], [15816], [-10154], [-17442], [-8778], [430], [-32976], [1168], [17172], [27146], [-30696], [24842], [11406], [-20540], [-9108], [-24046], [7998], [-24032], [15648], [808], [-39144], [38248], [-54264], [12206], [17664], [51984], [13782], [-14618], [18708], [-48804], [44736], [21004], [9038], [59726], [18258], [31884], [34706], [-16920], [50582], [45520], [-4950], [11230], [25920], [16216], [57134], [3670], [-53004], [50474], [-32148], [-7644], [-34698], [-33262], [22246], [1910], [-47820], [-11842], [16968], [14416], [-60552], [23316], [65982], [-36430], [-38554], [68124], [-40176], [-60372], [41308], [-10834], [-5218], [-56184], [12534], [-60266], [-40932], [19836], [-73208], [80174], [-63570], [55744], [26364], [78228], [-29086], [-53696], [19410], [80904], [71304], [-85570], [-39890], [7620], [-63146], [6180], [6374], [23274], [10536], [94228], [30768], [11234], [69568], [-69302], [61746], [95632], [33648], [32870], [5712], [-9036], [26040], [22248], [-95096], [68416], [118730], [8028], [44808], [102670], [10968], [40030], [-106440], [-109042], [60072], [-10608], [-123190], [52194], [24612], [34238], [-51266], [46566], [-85390], [-13268], [-19332], [254], [-72970], [-56700], [-15284], [-95460], [21648], [-103826], [83610], [-29302], [-82982], [-23794], [-60752], [94250], [18250], [35748], [6050], [-127510], [-110148], [123216], [143998], [109392], [-35566], [-24986], [-45072], [-73762], [-122376], [-33014], [-45042], [20862], [61764], [38964], [-39168], [132266], [81798], [-28172], [67950], [-134988], [134494], [-31174], [-77004], [17728], [-146508], [-52256], [14006], [87540], [69590], [-8832], [134606], [-105936], [117276], [-98178], [-84908], [-66828], [-88846], [-9564], [-150540], [123662], [2514], [-90884], [-67966], [-48642], [-14222], [52428], [-128770], [-97166], [-139430], [112104], [-110118], [104582], [27978], [5488], [156900], [9070], [41544], [-166318], [-52368], [-136690], [21688], [100586], [-127722], [29472], [-175016], [93948], [206676], [-96802], [108106], [-152748], [-225618], [73978], [129998], [-129336], [36700], [-63790], [-119034], [-76716], [1428], [-137730], [-104196], [-83446], [-171054], [50304], [-144828], [-158204], [-168298], [-30684], [164986], [-31282], [-126924], [207988], [184188], [17310], [-113888], [111206], [-151440], [102192], [209234], [-85542], [158006], [205248], [63288], [-124418], [79860], [-244766], [76512], [-15230], [-84238], [95686], [-210384], [-65698], [-73656], [-84348], [-94628], [150060], [-73978], [5794], [-193398], [61324], [-180276], [259130], [-280974], [-182378], [46788], [-121956], [-84224], [-247354], [-222420], [8566], [-32364], [-140830], [36126], [111228], [-135452], [71714], [22662], [282768], [-117776], [-6348], [183888], [10674], [-42838], [253080], [-162708], [293906], [111384], [110148], [292356], [-235550], [80976]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_624_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_624_4_a_g();".
// 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_624_4_a_g(:prec:=1)
    chi := MakeCharacter_624_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_624_4_a_g();".
// 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_624_4_a_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_624_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![12, 1]>,<7,R![2, 1]>],Snew);
    return Vf;
end function;