
// Make newform 448.6.a.ba in Magma, downloaded from the LMFDB on 20 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_448_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_448_6_a_ba();".
// 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_448_6_a_ba();".
// 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 := [282, -107, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [-1, 2, 0], [-291, 10, 4]];
    Rf_basisdens := [1, 1, 3];
    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_448_a();"
function MakeCharacter_448_a()
    N := 448;
    order := 1;
    char_gens := [127, 197, 129];
    v := [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_448_a_Hecke(Kf)
    return MakeCharacter_448_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+1)]];
    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 := 6;
    raw_aps := [[0, 0, 0], [-3, -1, 0], [5, 0, 1], [-49, 0, 0], [-194, 19, -1], [319, -6, -11], [244, 4, 10], [363, 55, -22], [-1280, -65, -15], [3076, 72, 22], [402, -148, -94], [1868, 502, 104], [-7584, 390, 44], [-9902, 25, 149], [-3394, 542, 116], [9410, 518, -294], [5579, -1311, 592], [30461, -820, -91], [-18968, -1, -879], [-25284, 850, 362], [-15202, 1296, -556], [1108, -1000, -52], [-35005, 1239, 874], [10290, 666, 390], [-54044, -5478, -172], [21185, -5374, -1605], [-10618, -1048, 874], [-57076, 847, -259], [10656, -8810, -212], [7432, -8229, -121], [-86164, 3091, -3967], [-133961, -3729, -1746], [145022, 7804, 416], [-48939, -12083, 514], [3742, 22884, 928], [-71228, 19873, -245], [-264497, -13442, 1489], [-246710, -607, 309], [-212702, -4310, 5484], [-120421, -21334, 5001], [177132, 12339, 7769], [64755, 22972, 6431], [-48108, 12026, -182], [115564, 4229, 473], [10638, 14982, -11234], [-483422, -3140, 3642], [-90312, -18249, -5607], [-378596, -27770, -1282], [117403, -14481, -4718], [-74821, 6514, 5017], [-300222, 10324, -844], [86504, 1945, 20527], [-528140, -7258, -7672], [361609, -66599, -10566], [-352318, -45092, -10332], [142924, 87626, -11662], [1068755, -48338, 5437], [242304, 92054, 8970], [1509962, -51536, -10088], [-174278, -58512, -21360], [239103, -59499, -16832], [-174611, -37758, 22783], [2315951, -13465, 6430], [1120040, -30108, 2460], [-1294224, -104382, 5488], [149486, -106810, 9686], [-1850686, 28193, 653], [-1917788, 48249, 17821], [994274, 201621, -15911], [637983, -35364, -22405], [-321558, -42862, -18538], [2355156, -59937, 22829], [-462820, -188226, -522], [-268834, -137868, -6256], [-1797594, 13001, 29793], [95302, 14946, -35928], [-1711172, 75114, 12532], [810119, 50964, 23707], [2685932, 235327, -11777], [372748, -199048, 37758], [4028513, 9395, 22024], [1012322, -109908, 52692], [-2170864, 174707, 55101], [150680, 140844, -68418], [4274984, -2338, 18690], [-4628768, -49267, 36011], [3541546, -37452, 60500], [2469236, 28353, -41155], [-3183069, 22524, -96585], [-415928, 2262, 23482], [-2018705, 130903, 4822], [-6708982, -112768, -14634], [-2122928, -95385, 71241], [-4917328, -143307, -43853], [-2403024, 291681, 42503], [-6153300, -174874, -5674], [-7562577, 58552, 20751], [649208, 64064, 49098], [-2537201, 194289, 58716], [9570406, -77300, 37496], [-2164122, 380833, 132201], [428078, -279402, 91334], [-1720839, 158499, -121064], [-315860, -368261, 24347], [-742674, -223323, 141133], [-6327006, -137530, -27942], [-246543, 272877, 46374], [-5854050, 307552, 127284], [-2478880, -275740, -139228], [-8531774, -510562, 51634], [-5375112, -232432, 72952], [9742340, -196800, -100794], [-4450516, 135549, 81785], [-2578073, 270841, -93244], [1991260, 520740, -85640], [7367732, -3689, 100527], [13290161, -21561, -51684], [-680030, 244356, 65762], [-544520, 581012, 146502], [-857282, 31733, -215795], [9417077, 195498, 55087], [-12009490, -150076, -143008], [-5190493, -325440, -13637], [-5979496, -198953, -55639], [-1172657, -575733, 83194], [2733080, -73500, -131082], [9865396, 1013418, -142100], [1078458, -807290, -156992], [10474302, -509786, -72172], [-10871379, -306364, 98477], [1444426, -234143, 241269], [26588, -123021, 298657], [1117152, 624847, 261537], [-11772628, 445700, -51830], [-7132236, 284946, 24124], [-8262360, -169710, 229832], [-6555407, 605220, -11551], [7850111, 78951, 414966], [-6724429, -402102, -126335], [9991468, 1547249, -233259], [8100163, -433559, -81512], [10887050, -258480, 195112], [23236776, -435286, 60838], [-14344316, 186323, -38015], [8606717, 13916, 2261], [-6205866, 906504, -104566], [-5612605, 482426, -58647], [7793172, -1192732, -47030], [-2189071, 239205, -447514], [-695812, 1059622, -192106], [10227372, -1247366, -320436], [10035662, -637198, -392766], [8198356, -160031, 133523], [-15259930, 1124742, 154204], [14914892, -1082371, -378257], [659308, 425117, 8967], [-12335720, -425934, 4894], [-19470924, -42888, 255206], [-23549978, 484748, -25712], [-353551, 1679282, -367085], [1597686, 1072781, -43395], [-2568126, 65876, 156964], [-13087784, -478461, -410699], [8794827, 1183041, 536080], [-11445866, 986536, 483972], [-4343642, 502016, 724178], [23809032, -1235276, 53004], [27623929, 397672, 324773], [-10726788, 603657, -236587], [-18443533, 454246, -230579], [-13580992, 422065, 603127], [-6683541, 896176, -539861], [-20728772, -1958294, -91806], [35927618, 845212, -3092], [3291210, -730058, -193728], [-32326082, 1587286, 148446], [28707668, -63101, -72175], [30923412, 158416, -405850], [8340556, -224392, 300580], [4277689, 1038834, 406683], [3693408, 2309935, -5055], [-51083303, 1241595, 221728], [-24527488, 1302386, 368120], [-28967006, -1068340, -436220], [4677612, -61647, -568637], [35564455, 2234186, -263659], [32410242, -1153502, 729974], [-11328685, -2197889, -326070], [5335422, 2567396, -158792], [-14790882, -1279988, 661286], [24680570, 142822, -440126], [4888824, -2037565, 50653], [6905868, 2790829, 419919], [-5009041, 215030, -855463], [-44042556, 236881, -12701], [27856230, -697198, 31274], [5007252, 2201813, 855441], [-33860620, -163780, -907022], [-27350706, -1669782, -11190], [-28388760, 337322, -903498], [8657442, -1336922, -327918], [36748158, -1628780, -31666], [-76960287, -354316, -218911], [36063822, -213050, 1023422], [-14654305, -1836147, -1075200], [-374487, -2460870, 877683], [-3738370, -1130248, 619146], [12304202, 3279787, -41013], [24198176, -2775385, -330661], [44440309, 1887021, -34070], [-747548, -2846465, -1126905], [6246205, 2604032, 685145], [-56752876, -1621151, -582309], [-24272953, 1639693, 79472], [-66653888, -379050, -58030], [-16721644, 1289046, -502024], [30798424, 363166, 638354], [-34150624, 159466, -218760], [-86916784, -137748, -68468], [-43187080, 2709592, 776722], [-12181208, 2286072, -1470134], [60166480, -4033658, -822766], [19790122, -2101932, -1238860], [80657240, 2946749, 167899], [-81896141, -1590029, 648598], [-2883872, 4360860, -1320466], [14423490, 5747350, -269446], [16720944, 2539741, -71165], [-20750356, 3934674, 1576538], [49704446, -122801, -265405], [-102106352, -1097436, 190734], [-33453223, -3191553, -297180], [25482080, 351294, -128454], [-21839534, 1585452, -955300], [36708635, -2193683, 1465196], [19004312, -2702918, -172722], [-18366852, 3017684, 1096386], [28647182, 3994600, 494204], [-27194032, -3808455, 293951], [-42967428, -747960, -1348572], [-25070802, -2169929, -2009605], [104631311, 2081993, -12444], [-29192980, 1723106, 1327066], [-14964574, 716642, 171638], [42862470, -4420694, 34338], [35267554, 3137104, 1298406], [-43823792, 4017600, -1166976], [-6019313, -1134309, -462086], [58992322, 1778375, -715321], [3228456, -3983508, -2085036], [11971406, -5378212, -1727152], [-67563350, 1183186, -311546], [-21172860, -682852, -679736], [-73017582, 612706, -1310850], [973973, -3057112, 1788273], [-39008916, 4176047, 123869], [42831672, 604708, 2126414], [-67160703, 3830193, 218370], [63437541, 4094452, 706189], [73471108, -1811060, 2092786], [10400312, -1263351, -192961], [-64867558, 678323, 1132419], [13920021, 3452248, -1386583], [-114051331, -1150096, 132657], [-115434852, -153590, 63052], [91240413, -1250237, -108236], [97260334, -543664, -1603540], [-65603366, 1320634, 303854], [-1016140, -5203513, 827981], [-79302800, 1413234, -1142216], [54479659, -3862410, 1107645], [-38000378, -6878833, 1548395], [92294494, -1771226, 1925838], [54661204, 568579, -1765559], [53068922, -5500920, 1385952], [-9428084, 1695368, -1405980], [-132121278, -4387437, 1220731], [-43628266, -7189954, -418986], [42846000, -750129, 607907], [-88938237, -2935689, 1524474], [-39692252, 5737354, -1841246], [24942880, -286882, 440842], [-69835066, -1349182, 2631696], [162262549, -5472126, -1446473], [-41709045, -1610799, 2129752], [57234028, 5822081, -1118093], [7130906, -2456324, -1945844], [-87148266, -764566, 290914], [15707718, 6464258, 676720], [82294314, 3027026, 2455398], [-46893414, 2969650, -1221746], [54709819, -1755461, -3464562], [139284300, 9789057, -735099], [198577291, 2472737, 187992], [-87641022, 1256796, -231188], [-67700577, 7877376, 171991], [23930048, -7914378, -1458774], [-2730649, -3292798, -908115], [-149424535, 3208617, -2861510], [103009757, 10830223, -679488], [177928924, 2684872, 1043118], [-42667552, -453526, -3442584], [-195669744, -1857510, 41998], [-96240758, 4616867, 2428179], [-175911774, -3896985, -1052265], [51701006, 11032400, -1098604], [73939834, -6072727, -551507], [-153551311, 3580048, 1723277], [-49509480, -6073047, -523569], [-40904966, -7318428, -3629436], [37941428, -1131758, 5174186], [97200036, 1765154, 3328468], [-125644282, 6533612, -2970656], [-87288910, -1176021, -2040829], [-49564564, 515532, -3144080], [-138350478, -4349786, -131446], [-31191647, 1537807, 3167044], [-104584600, -1286914, 695202], [140421214, 3518822, -1878978], [108184474, -10636820, 516748], [-13143791, -10957905, -1251028], [-131279418, 878920, -6028708], [139780297, 3388374, 394455], [-52862476, 6228120, -126660], [-163962652, 2328005, -224535], [20730240, 660196, 91918], [20628638, -6705427, -2656091], [-218412741, -3117375, 1229432], [-28009804, -5811499, 2933031], [-58207640, 4777740, 1350518], [96580038, 7125978, -2270902], [-119166704, -2699616, 2524594], [-307087034, -3989810, -1440244], [53452549, 6240663, 2374664], [36126612, -13085689, -753827], [-75288881, 7406049, -3122100], [171755056, 14967606, -2092260], [200484474, -4845102, -393146], [-242614582, -7376136, 1361328], [-244121194, 1711928, -4913630], [-19677554, -8212458, 321390], [-21159996, 14059651, 570747], [66151803, -7943720, -1313893], [795996, -6470944, 852220], [-5115408, 7647628, 2481494], [114670006, -8322709, 848703], [179508355, -10170344, -1616141], [-75861602, 10871361, 3993873], [241080564, 114174, -1728338], [104895385, -4103404, -365175], [349733885, 2071707, -1825324], [-199688494, 7693552, 3699272], [115589818, 103038, 4427506], [-85923106, -8688500, -2938], [-26803434, 6825270, 2774], [-113344610, 501686, -4335410], [211034898, -15351652, -1928094], [241121451, -5392055, 1453192], [-65167406, -11095496, 1255384], [223543256, -5507137, 1234377], [134803270, -8137784, 2660404], [146669686, 2369720, -4880092], [117047748, -11830665, -6076651], [62792980, 15687469, 4214007], [58518099, 8548523, -1203698], [22245188, 1107513, 2998853], [-18622989, 23983038, 140269], [255829120, -9579661, 3181437], [204314772, -7804487, 3224341], [479041276, 2839117, -731601], [308187117, -2910219, 740370], [-74355048, 10085508, -2862276], [200499926, 364256, -222612], [201496160, -2673540, 258620], [45832806, 13772296, -1095364], [-103684133, 132363, -5198970], [336824648, 4837001, 785999], [50613334, -1318530, 6537102], [224997132, 11354958, -237352], [-232387356, -3641848, 1099622], [-362174505, 4674720, -4019857], [417092700, 12104825, -2573635], [23686728, 1750542, 1273634], [-116381350, 17739320, 6188016], [-65822175, -14874673, -521276], [98287848, -25556706, -1844686], [187785860, 26899948, -3956408], [-7119731, -8321632, 1120601], [-161053176, 20898313, 3898791], [135270022, -13627892, 1049118], [-130209484, -17747195, -2182511], [-47484171, 18165512, 3314617], [89040700, 13294411, 2772737], [173967249, 23665271, -3984796], [217578796, 19716157, 2343799], [-86737602, -10397228, -1803432], [238751258, -6205576, 7598846], [20039976, 9555256, 6959666], [432509812, -5536125, 5277713], [-63121660, -6421180, -923998], [70623665, -18524474, 7894095], [-38317958, -10578608, -4307064], [42263608, -25009630, -4532802], [276707700, -10771100, 6487498], [18295803, 2837798, 999845], [-125255258, 9429344, 992354], [84737314, 9070088, 4062432], [-67305012, -4988179, -2917215], [-77397895, -27964885, -3063160], [202963641, 28258163, -309080], [37460094, -24238182, -3341206], [98586128, 4958840, 5499570], [107919646, -2990599, -6362711], [120042368, 2967753, 9852191], [179135626, 31201844, -1525460], [104134507, 20862832, 2967547], [-16975796, -17366384, -3227364], [-236213290, -24825058, 5275652], [496314988, 1884302, 2700456], [161555388, -24856326, 2323586], [-88229160, 12791282, 4991896], [18404857, 28210324, -2678135], [-254869608, -30732000, 1139440], [-230398883, 18200761, 5308710], [-281439192, 26143426, 2451128], [-395095655, -8230836, -4530343], [315594526, -13129865, 976955], [-49426318, -23703952, -6961608], [-319550067, -11617719, 108854], [19551498, -11752954, -5387016]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_448_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_448_6_a_ba();".
// 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_448_6_a_ba(:prec:=3)
    chi := MakeCharacter_448_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_448_6_a_ba();".
// 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_448_6_a_ba( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_448_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![-3096, -408, 8, 1]>,<5,R![129024, -4516, -14, 1]>],Snew);
    return Vf;
end function;