
// Make newform 624.4.a.t in Magma, downloaded from the LMFDB on 05 September 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_t();".
// 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_t();".
// 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 := [-8, -16, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-1, 2, 0], [-21, -4, 2]];
    Rf_basisdens := [1, 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, 0], [-3, 0, 0], [1, 0, -1], [-11, -3, 0], [4, -1, -3], [13, 0, 0], [-50, -4, 0], [-33, 3, -8], [12, -16, 4], [4, 10, 4], [-91, 27, 2], [112, -24, -14], [165, -2, 17], [96, 30, -2], [6, -27, 21], [-246, -54, -6], [582, -41, -1], [76, 12, -14], [-19, -21, 38], [336, 67, -7], [-112, -120, 6], [4, -24, 12], [262, -15, 5], [503, 58, 15], [1072, -24, -2], [180, -170, -64], [672, -42, -38], [768, 152, -20], [166, 144, -32], [480, 116, 34], [358, -54, -36], [-344, 96, -76], [1125, 134, 73], [90, -276, 58], [675, -88, -47], [-1285, 117, -10], [324, -240, 86], [-299, -111, 144], [358, -115, 117], [-1692, 2, 124], [-524, -226, -150], [-1648, -228, 174], [-1204, 46, 6], [-1638, -36, 140], [-3459, 88, -13], [-770, 54, -240], [-520, -132, -136], [-823, -141, 158], [784, 253, -245], [-2830, -108, 96], [-724, -276, 190], [144, 543, 69], [4840, 48, -98], [2832, 10, 290], [-656, 628, -62], [-1188, 14, 94], [2864, 218, -256], [-483, -459, 136], [-2314, 12, -276], [2509, -306, -7], [-858, 318, -20], [1023, 20, 145], [-3461, -51, 210], [-1152, -360, 0], [3474, -24, 32], [1777, -60, 83], [-1511, -1017, -210], [-2982, 624, -136], [240, 256, 116], [-1160, 1092, 358], [2189, 394, -171], [-4290, 537, 369], [4598, 276, 74], [-4070, -156, -728], [-1377, 471, 364], [1094, -485, -105], [-2482, -78, 22], [-256, -612, 294], [-2017, -698, -237], [-1124, 852, 214], [4228, -1288, -312], [-4630, -36, -624], [11694, 107, 223], [7588, -60, -74], [-1244, 378, 810], [8840, -312, 148], [6803, 38, 359], [1532, 540, 990], [5453, 476, 119], [-6931, -63, 380], [8448, 438, 222], [-7764, -763, -509], [3801, -141, 550], [-1584, -1474, -434], [1857, -681, -98], [-716, 1726, 214], [725, 1780, -489], [8064, 696, 1158], [-6470, -1116, 258], [6522, 264, 1052], [8102, -864, 314], [-5637, -1472, 233], [-2580, 106, 422], [12584, -824, -690], [-446, 2334, -456], [6722, -1416, 264], [2206, 1157, 993], [-8245, 1158, 175], [-10120, 1698, -74], [9658, 2400, -272], [1066, -252, 174], [14668, 1488, -170], [17249, -970, -475], [-3597, 3477, 298], [5803, -459, 1062], [7066, 1460, 852], [13369, -801, 318], [-9920, 188, -276], [-8208, -1538, 620], [-2576, -824, 52], [-2976, -396, 182], [-19160, 1092, 250], [-3862, 1902, 214], [0, 439, -655], [-1383, -1221, -350], [3646, 2766, 338], [19438, 60, -476], [-5088, 976, 1232], [-1454, -3030, -1248], [-17574, 1812, -448], [883, 573, -246], [-12960, 443, -335], [17380, 1134, 1230], [904, -672, 274], [9325, 1982, -1335], [-4986, -2028, 1040], [9947, -688, 1361], [11327, 2733, 230], [14282, 386, 938], [-29508, 712, 194], [1639, 435, -1992], [13279, -2552, 253], [2508, 498, 1114], [5068, -1485, 17], [12356, 360, 318], [-2136, -1007, -277], [-14436, -1236, 554], [1780, 912, -766], [-16540, 1176, -352], [-8486, -2145, -2329], [3788, -900, 354], [8960, 1540, -1518], [-3094, 1278, -2008], [-14940, 3086, 262], [-13686, -2238, 604], [-18796, -798, 154], [-6300, 540, 1696], [14517, 362, -515], [-23296, -1164, -534], [14819, -3732, -1259], [9954, 3671, 2035], [2520, -3352, 670], [-7727, 5475, -402], [-17676, -1124, -1108], [-7329, 6118, -13], [-32756, 3261, 947], [3746, 6108, -1522], [-3146, -1536, -2120], [-28152, 456, 230], [5148, -4902, 996], [30240, -4311, -441], [5644, 600, 70], [9320, 676, 444], [-1344, -696, -874], [-27216, -1326, 886], [-20310, -5776, 1552], [4503, 813, 982], [-19473, -3492, -2343], [9656, 1794, 2198], [-3822, 1788, 3008], [-15851, -2571, -3312], [792, -3834, 1062], [-7144, -1848, 234], [-13533, -2766, 1539], [5654, 5225, 2513], [5538, -1438, -2534], [-6848, 1884, 646], [22783, 1587, 1560], [-10168, 2628, -2574], [6894, 5665, -2335], [-3404, 5100, 2062], [5074, -503, -1295], [40262, -2424, -94], [35647, 496, 1405], [43584, 202, -1702], [24420, 5476, -2338], [-16766, 4080, 1888], [17110, -840, 3256], [23575, -3402, -1237], [-34932, -2478, 2634], [-15879, -568, 1399], [46522, 2364, 3030], [26470, 96, -1064], [26084, 5676, 414], [53970, 119, -1781], [42322, 4042, 1354], [-5299, -1521, 1862], [-34028, 628, 1612], [-37613, -5342, 3139], [-20590, -2550, 188], [10004, -4812, -1002], [25242, 966, 3294], [-42128, 684, 492], [26968, 2791, 4009], [-19478, -8237, 3019], [-52762, -264, -1884], [-13412, -6612, 144], [7570, -4420, 1332], [39576, -5389, -959], [39999, 3552, 909], [13718, -6396, -3708], [-33523, -135, -1252], [-11677, -3450, 1303], [-13699, -1497, -1906], [50520, -3430, -542], [-22790, -1584, 3628], [19866, -1736, -2920], [-51460, -4382, -1758], [15254, 3306, 2468], [5726, 1275, 5491], [-69504, 1788, -970], [14470, -6552, -4446], [69067, -525, -1848], [31986, -8640, -2664], [-8638, -6528, -514], [30792, 1251, 2697], [74828, 2352, 882], [-26353, 2716, 2793], [60716, 1498, -2130], [-39440, -2530, -4542], [6790, -9019, -831], [14138, -2550, 3188], [-46472, 2124, -2076], [-28152, 4860, 302], [4407, 734, 2707], [15024, 7656, -288], [57569, 5133, 500], [-33066, -5257, -2969], [-81041, -261, 408], [35532, 5048, -1628], [-12166, -2196, 3528], [44629, 3322, -3347], [-17412, -7551, -1857], [44146, 7608, -3008], [36060, 2634, -2388], [32992, -2861, 3133], [-24586, 11304, 576], [6511, -2505, 732], [24666, 8862, -1002], [11590, -840, 5716], [42390, -930, 4072], [12244, 2000, 912], [-18538, -4296, 5472], [-55202, -3144, -3488], [41355, 4070, 3679], [34484, -2172, -436], [-3983, -4156, -2301], [33045, -10698, 441], [-89753, -5619, 2118], [-23296, -5518, -2992], [-63940, -6948, -318], [-57867, -4845, 982], [11332, -3936, -4862], [544, -3258, -1230], [29550, 1464, 1748], [13679, 2679, -304], [60964, 433, 19], [4108, 1560, -4730], [-55982, -6972, 2404], [14820, 1882, 542], [36408, -3838, 2206], [-25907, 12165, 1776], [-44324, 1338, -7486], [76376, 2280, -774], [-105437, 2181, -54], [116200, 1932, 380], [-26228, 804, 6526], [28299, 12072, -807], [27391, 12537, -2058], [19192, 2588, -3870], [31902, 2806, -4486], [-20016, -680, 644], [6495, 850, -1153], [-14106, 2683, -1573], [4468, -8664, 2686], [12278, 11994, -530], [-9354, 8700, 3922], [-122770, -482, -2550], [73052, 8420, 2876], [44755, -17199, -4698], [13514, 7824, 3552], [24077, -13872, -3725], [-44536, 7086, 3938], [23312, -9648, -5204], [18034, -8652, -5958], [40572, -10704, -4846], [-8260, 2862, -3350], [7342, -6732, -620], [-41820, 7241, -4913], [-148890, -3372, -892], [71264, -3854, -2826], [16077, 13576, 4259], [30260, -16440, -4046], [-32728, 19176, 284], [12698, 5617, 7749], [12758, -15768, -4764], [31944, 19393, -1729], [-8858, 3171, 1871], [25216, 5268, -3086], [46902, 10456, 6812], [-33752, 12366, 5166], [46558, 11856, -4268], [-45738, -14854, 6862], [-34545, -15099, 3202], [42843, 13554, 699], [-48948, -8076, 3854], [75121, -7323, -4392], [42929, 14799, 5006], [22012, -11584, -2004], [28308, -2882, 6488], [70790, 2268, -1308], [-10872, -978, 3012], [74324, -1392, 7748], [8336, -14729, -951], [21551, -14889, 5324], [119266, 7233, -4999], [10900, 9588, 898], [-83807, -9086, -1823], [15812, 10416, 5250], [42788, 19170, -2710], [-26556, 8796, 6050], [38876, -352, -5350], [-51137, -4884, 1913], [97936, 3690, 3942], [-111767, -2284, 1083], [-7104, -8898, 10134], [18478, -1944, -4376], [4073, 1137, -9076], [-1642, 7013, -7099], [54470, -5506, 3074], [35877, -11541, -4994], [-18228, 12660, 2294], [100119, -3860, 4217], [8230, 1242, 2460], [-18436, -2052, 42], [-57788, 10068, -6658], [-8986, 20221, -3315], [24108, -6755, 4175], [29520, -9768, -8034], [90694, 7323, -5857], [36012, 3156, 11234], [55098, 20872, -6184], [-73680, -1690, -1598], [-135732, 3053, -4913], [-13804, -10614, -8434], [120796, 6972, -4274], [19101, -3136, 10099], [24527, -4899, 9890], [125976, 7500, 3962], [-70824, -3260, 1904], [19824, 8130, -11270], [7522, 16017, 10085], [-118206, -6198, -1614], [39888, 6276, -4460], [11310, -9876, 7244], [49050, 3213, 7101], [34992, -9236, 9812], [22930, -7584, -2384], [-32674, 8012, -5632], [71148, -9396, 2270], [98715, 1152, 13785], [9393, -9634, -5555], [6469, 24825, 8820], [-45021, 19422, 10047], [-66343, 10389, 2480], [-49268, -13195, 11307], [-1377, -15885, -12452], [7452, -9384, -4162], [-111773, -13077, 8604], [66872, -9506, 10818], [57272, 2892, 3858], [95227, 19720, -3239], [32732, -14181, 2473], [168196, -16884, -2940], [169550, 8893, 6525], [-27668, -25116, 1702], [-90593, -3501, -4116], [20646, -9588, -5568], [-1072, -4944, 308], [-47019, -9476, -14425], [2264, 15552, -11910], [-62682, -8972, 8240], [23285, -111, 404], [105111, -8478, 7911], [-72059, -6460, 3999], [57592, -26244, -2316], [54118, -12180, 10420], [-9497, 6662, 603], [-48705, -3543, -2726], [-135408, -12745, 2281], [134714, 4416, 8424], [-50798, -10850, -16994], [-24240, 34312, 620], [-71644, 870, 1778], [34302, 12768, 4916], [-67758, 36714, 4602], [167504, -4013, -1743], [192208, 8892, -4596], [-245349, 3166, -1465], [-84532, -656, -7548], [-62704, 16282, -6192], [165348, -10392, 2678], [-20812, -3517, -1051], [-122896, -11484, -6128], [22190, -11952, -7212], [-121393, 17756, -223], [8304, -11226, 15486], [24207, -23262, -3393], [31405, -99, 372], [-24348, 11746, -862]];
    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_t();".
// 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_t(:prec:=3)
    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_t();".
// 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_t( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_624_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-864, -252, -4, 1]>,<7,R![-1984, -288, 30, 1]>],Snew);
    return Vf;
end function;