
// Make newform 624.4.a.l in Magma, downloaded from the LMFDB on 08 December 2025.
// 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_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_624_4_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
        poly := [-43, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 2]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    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_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, 0], [-3, 0], [6, 1], [-22, -1], [-26, 0], [-13, 0], [-10, -2], [30, 5], [4, 12], [66, -12], [70, 15], [34, -14], [14, -7], [0, -14], [-18, 6], [334, -4], [254, 22], [170, -8], [470, 43], [-150, -68], [562, -6], [760, 44], [-262, -42], [950, -1], [-718, -18], [1270, 10], [68, -78], [400, 40], [-614, 60], [350, 68], [1316, -18], [1600, -52], [-66, 105], [1644, -108], [814, 39], [-318, 5], [-2426, 12], [-110, 91], [-122, 70], [1494, -114], [-732, -192], [830, 164], [-88, -40], [-3294, -68], [566, -43], [-1676, 14], [-1804, -72], [-226, 3], [-2726, -92], [4010, 148], [962, 426], [682, 212], [1618, 226], [-4432, -24], [10, -258], [1404, -376], [882, 20], [-3710, 111], [5318, 136], [142, -303], [-456, 266], [-762, -117], [-5030, -11], [3652, 292], [-5418, 96], [718, -83], [-6634, 367], [-6330, -420], [-2892, -588], [762, -546], [-4946, -159], [3366, -642], [-968, 80], [6722, 120], [5006, 121], [6450, 78], [1834, -382], [1506, 754], [8286, 363], [-974, -146], [6864, 564], [7658, -516], [8274, -530], [358, -744], [11020, -374], [5272, 584], [-8018, 455], [-9222, -206], [3934, -199], [-3166, 763], [6104, 224], [910, -424], [6006, 1039], [14472, 0], [9702, -201], [268, -932], [-15154, 521], [-13258, -524], [1524, -788], [13746, -456], [-5356, -1100], [5702, -1209], [-20644, 172], [1178, 1158], [11128, -890], [7962, -668], [-6958, -170], [5766, -773], [7148, -28], [2678, -1832], [-5024, -468], [106, 938], [2294, 209], [12050, -795], [-8822, -1219], [15270, 214], [-15482, -341], [21016, -748], [9066, -504], [356, 1748], [12122, -1458], [6674, 2020], [11710, 632], [-16930, -452], [6342, -265], [12506, 1394], [-20022, 1192], [-2812, 880], [13348, -1130], [-19014, 376], [-4254, -631], [2730, 1244], [9236, 974], [-6310, -144], [-15418, -1259], [-21270, -416], [-6810, 2331], [10834, 977], [-1254, 1702], [-18634, 1564], [18582, -1583], [5974, 439], [-19068, 1982], [17342, 1416], [-18334, 856], [-30762, -540], [19530, 286], [1818, 654], [13676, -532], [-18966, -982], [-13478, -506], [3410, -458], [33968, 946], [28768, 236], [7304, -786], [9408, 44], [19600, -868], [-16482, -103], [19910, -1552], [-2746, 2555], [-19458, 2154], [-13590, 1170], [-17882, -669], [38532, 276], [-13458, 2139], [-19202, -2888], [-3016, -684], [11646, 1568], [21002, 990], [11278, -1102], [-26502, -444], [1746, 2202], [50220, 904], [17810, -3122], [20812, -2514], [5618, -2384], [15634, -1899], [21414, 867], [-24796, 2274], [20826, -1856], [-25254, -1717], [-35500, 2520], [5626, 472], [670, 1735], [-6762, 3630], [12234, 2394], [-30186, -2788], [5102, 2753], [-36022, 1606], [-474, 2934], [51306, -268], [-35062, 938], [7260, -320], [26990, -681], [-3668, 640], [41066, -158], [-32454, -3196], [-5574, -4120], [40982, -2441], [20816, -712], [-43506, -2119], [-35400, -1564], [13242, 2632], [-2406, -1300], [-2234, -4142], [18510, 768], [8886, -2701], [-25064, -3068], [974, -4097], [10896, 4450], [60358, -1352], [45062, -2056], [-992, -448], [-11922, 1804], [67666, -646], [35634, -3488], [-60128, 2496], [69394, -292], [50418, -2700], [-22794, 963], [6014, -4032], [18034, -3521], [-16346, 1963], [-33546, 5015], [-29040, -3444], [2086, 5444], [8930, -6088], [83396, 992], [-19700, -2990], [86638, -858], [22518, 2940], [28260, 1000], [-49258, -1403], [8302, -1306], [8900, -3496], [-28534, -252], [-96870, -482], [-21026, 311], [42580, -3376], [54536, 388], [-61422, 3510], [28144, -3426], [-39216, 1252], [-46118, 1794], [-7746, 1659], [35860, 1460], [23178, 6619], [9974, -2386], [5910, -1475], [9092, 2448], [-27566, 3712], [58686, 2721], [16062, 2896], [25614, -3004], [55218, -3264], [-31202, 3748], [-11998, 456], [-28730, 4373], [-29126, -3158], [67202, -440], [22524, -2150], [37284, 1644], [2306, 5548], [101110, -2360], [24558, -3785], [87660, 2072], [-84946, 1045], [-50674, -4031], [-21814, -5375], [-80122, -1382], [-39702, 1052], [-58050, -1177], [-110710, 994], [-1492, 3738], [69310, 816], [-45858, -1687], [44082, -2112], [874, -9358], [-31014, 7052], [34424, 6088], [-76072, 2584], [-21006, -4493], [-66832, -992], [24642, -7778], [25738, -9723], [-66520, 2356], [-78154, 2400], [84382, -569], [41882, -4931], [-2686, 1450], [54742, -1360], [48828, -4380], [-44706, 4843], [-25786, -1498], [35030, 716], [59842, -850], [9648, 9512], [-11286, -3606], [-3476, 6388], [21850, -4563], [-33766, 6216], [-53002, -143], [-14908, 598], [35828, -752], [-18956, 7024], [-64774, -4878], [-65756, 5284], [23318, 1704], [61774, -8080], [-122718, -2204], [-12108, -7104], [146998, -971], [-41242, -9140], [-135092, -316], [81094, -1902], [19398, -440], [36162, 8436], [-31302, 1230], [-85630, -5430], [48126, -8730], [81536, -3918], [-20942, 2988], [131294, 4732], [-7734, -13619], [-82274, 1031], [15878, 3128], [23282, -9685], [74910, -6597], [35384, 4444], [-53590, -688], [27370, 6912], [48690, 2304], [-71096, -5792], [-101586, -2940], [-4754, -11711], [-37366, -2854], [-69382, -9662], [9558, 5001], [48890, -5022], [87676, -7022], [-33702, 3566], [-147186, 3288], [79814, 1523], [9684, -12618], [-107338, 5937], [-90788, -6276], [58946, 3488], [74722, -2353], [65022, -3042], [10098, -4162], [24854, -3877], [62610, 7330], [-90786, -7805], [-28100, 1810], [-35038, 5388], [-13586, -9756], [-7034, 4806], [-50382, -3152], [-60742, -11550], [-121750, -2914], [63314, -1434], [82734, -1830], [-107268, -7380], [-141806, -2920], [2584, 16370], [-103510, -1924], [18494, 7493], [-19622, -12583], [-41222, -12084], [14216, -4896], [62320, 12778], [-148978, -7254], [25398, -7340], [-169648, -1284], [-110682, -3008], [-69222, -150], [-16, 308], [79034, -12692], [48786, -2196], [236178, -920], [-30282, 11175], [-9698, 7125], [30530, 2939], [-58194, 471], [-82894, 7875], [-5146, 5840], [-53730, -7851], [-63734, 4304], [117894, 9601], [-71428, 1484], [-76246, -11042], [12334, -10321], [-210242, 3568], [3076, 7012], [8830, 12766], [-76018, 13216], [33614, 2021], [-22818, -630], [-9428, -9420], [185950, 629], [-36334, -2154], [135998, 5510], [-76198, 4047], [-49810, 4939], [95182, -12883], [-58632, 1468], [17274, -19864], [120926, -9901], [-60446, 9429], [84086, -7876], [22370, 3576], [-87298, -6888], [134884, 2156], [116144, 4206], [192474, -948], [11462, 7152], [-156590, -5324], [-25496, 2268], [7158, -15789], [73780, 17240], [-212618, 762], [138866, 4326], [26026, -11848], [-41264, 6692], [-51990, -2476], [-267874, 403], [118048, 5304], [35566, 20155], [-64526, 607], [-70480, -6116]];
    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_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_624_4_a_l(:prec:=2)
    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_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_624_4_a_l( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_624_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-136, -12, 1]>,<7,R![312, 44, 1]>],Snew);
    return Vf;
end function;