
// Make newform 441.8.a.m in Magma, downloaded from the LMFDB on 04 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_441_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_441_8_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_441_8_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
        poly := [-266, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_441_a();"
function MakeCharacter_441_a()
    N := 441;
    order := 1;
    char_gens := [344, 199];
    v := [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_441_a_Hecke( : Kf := Kf)
    return MakeCharacter_441_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 := 8;
    raw_aps := [[5, -1], [0, 0], [-170, -20], [0, 0], [2620, -308], [-3998, 288], [-14014, -556], [32332, -936], [-40600, -1060], [216954, 2088], [19696, -10152], [-356290, 3024], [7242, -39540], [254084, -11952], [-779456, -16088], [-1013150, -31136], [-577204, 53384], [4834, -38664], [-2221924, -36936], [-8184, -38172], [-187898, -290808], [1188368, -53784], [-3612204, -159984], [1134730, -485012], [-8072114, -122184], [878390, 341588], [-1572872, -777384], [-957172, 894428], [6193910, -761184], [-2634642, 242208], [-1436464, -1218312], [-7968380, 2101168], [15605350, -535496], [-3384812, 542448], [-29055742, -1112224], [-18748648, 1369872], [1684018, 2156472], [-34864756, -4369464], [5852616, 1871016], [-18604130, -783260], [-5554796, 3408724], [-8303798, 364608], [56904320, 3855236], [91598882, -3845232], [-14102958, 547008], [93839704, -5868720], [-110549428, -2293776], [-42391232, -7515072], [88438340, 7096712], [144765850, -92880], [-13681114, 2673464], [-52067616, 9270300], [4241566, 18091944], [-289113252, 12809784], [271735714, 11805676], [-398186744, 6258412], [42657278, -878068], [-111419408, 18787464], [118561022, 1253664], [97107798, -20153832], [179402836, -4556952], [-696126570, -1516236], [-325987316, 14587416], [-158507992, -16392184], [-180064730, -11614176], [-15252982, -13541584], [-664352476, -6296976], [-11653006, 40047696], [-1053846644, -22410620], [391497106, 4778424], [-666205534, 4225268], [557698520, -47569036], [-600505904, 43566048], [960733790, 27482400], [698176916, 34270704], [1037889904, 25425712], [406934338, 50752936], [-13470014, -88705800], [-167978194, -42310552], [-932449082, 108240840], [197790420, -103586856], [-1021782034, 58269024], [-680288192, -131288348], [-1176266402, 57419568], [-1812187496, 35972784], [-606641572, 127868708], [-200484546, -75154848], [-2163456838, -65669184], [-988553826, 150894612], [-560511472, 171762120], [-753876236, 105810376], [492414608, -87821464], [587167304, -182499840], [57250956, -125688012], [-2455886452, -1677024], [1899508968, 123853968], [-879018866, 33905932], [-3212531254, 59777444], [4277959396, -33543072], [3813893078, -65644704], [2305217516, -20367576], [2298604282, -177736496], [-3397719484, 101143352], [-1353629482, 363122024], [747723860, -289135368], [1007134558, 111909168], [-3688346100, -236996328], [-1837515854, 152253652], [-5645563880, -133249004], [-4349658794, 340498800], [6835950784, -111323664], [-1876023682, 209307888], [-179197530, 97584024], [4472306308, 79618464], [-8054123608, -217890504], [3790988446, -117454328], [-77155220, -341146440], [3668498696, -176152072], [4655650058, -522651688], [2495088420, 358637964], [1079743258, -58555080], [1291794722, 101988720], [2405160070, 13744228], [-1418008916, -406470956], [9352715500, -165855600], [-3301965702, -155083896], [5219237438, 790229952], [-2894487488, -744638528], [3231632200, -436497480], [6217571074, -58847040], [-10756182004, -441156024], [-7298640552, 532773204], [-3802474432, -630496800], [-9920222866, -47006208], [-3199911014, -390598196], [849524494, -454389264], [-10156406602, 385504388], [-23645588468, -169587648], [-694561554, -1018759356], [17751765862, -162311600], [7642124836, -936198000], [-2056643710, -1419911536], [19759165160, -387463176], [8763267228, 79929132], [18702927202, 261098784], [15581888040, -315260664], [3583477450, 1198131480], [-23369977894, -284002228], [-3940215260, 1449792648], [17250719456, 747396572], [14717344982, -1230091920], [-4392043086, 308294340], [-11136933268, 188707968], [584947672, 1839263368], [10122675092, 206796240], [12150356256, 806091876], [26271753608, -42144192], [-21827034446, -102947300], [-11441645594, 74596320], [13872911342, 1777398092], [41913642116, 312932012], [-16907411082, -451319232], [1478099432, -1110683304], [20184994684, -294625424], [12131473582, 1020403816], [-19549392232, -1226009152], [29968767776, 929386656], [2468228842, -2962313640], [-16909753870, 1001083248], [24084055510, -887886284], [5053776988, 1858674700], [43382411986, -68724072], [-4757434168, 68148116], [23053783898, 1881063072], [19097862880, -2198120976], [47547163242, -685458828], [-8802503644, -413258616], [-7273538366, -2152034936], [4357661032, -1444025160], [42979271122, -2068944552], [-16762063120, -2581958952], [-34122834060, 1162696080], [37105070078, -2756570688], [73648416058, -22598780], [3755018272, -254570228], [11865397142, 1762559204], [5872133558, 461388096], [-26155088516, 2309384448], [39689990618, 613065024], [14296134416, -3159434656], [13663142878, -1641459672], [-58765462260, -1189510260], [-49674159988, 2605996800], [-4293330098, -1252447532], [-60597076508, -155826596], [-39740876710, -145218892], [36851378354, -2471464368], [92604771206, -1494605952], [-8838705822, 5885054940], [-62042720840, -1135099496], [1925494522, 4124353648], [90511441312, -351305568], [-47363442278, -247842288], [5453828254, -264909096], [66081361020, 2257146672], [73580257694, -2234500060], [39098163472, -187077600], [43989455636, -902803156], [13668932166, -4975011408], [8432799988, 1421259048], [-14497407214, -6768442080], [45433665414, 1282035996], [-629180968, 3730438080], [-21089555252, -6808762784], [37226516504, -746164648], [64674471862, 1701379296], [44607281840, -2048255136], [41160035330, -1747196476], [87905757464, 853134860], [-36836878566, 7583356392], [-73510078882, 4029199200], [-33105883592, -5869271592], [59077635518, -2863494832], [-98655481408, 6754419648], [-48796244076, 6001890432], [-88780354546, 5175249552], [-25814862326, 1485780268], [-23225367728, 2141009932], [77843030344, -1626384600], [7697666780, -3093255916], [18687130262, 8395221312], [-85747777700, -5478965352], [-112095844000, 1694311488], [90708956614, -7560147008], [-23997358364, 5253142104], [12533869136, 2645117600], [186744906334, 3007229688], [-97039015294, 4903931600], [-53858658948, 9066922068], [12901738968, 596382480], [2461680484, 12275046292], [-54980042540, -5324985648], [-123649571384, -4419025920], [-31380516826, -3898311840], [-228209313582, 3727873980], [-59052242696, 2740515832], [21823969312, 1056473784], [75392024996, -86985112], [11614863140, -64221480], [27358096560, 249333036], [137336034710, 3973542624], [-99847066238, 2233931380], [-80067861464, 1689273892], [-52327632506, 15166612008], [-53757069106, -3961090396], [-6887869324, 18987866636], [-267918272818, 1029766176], [113400586468, 6875364456], [-197364368202, -8852925948], [92577192358, 5471186400], [32620030544, 6870461544], [-128421967212, -3806531388], [-48254570006, -463259088], [133044118786, 939148632], [92311958354, 14025151844], [24316023052, -9577513440], [-246293410854, 3704268336], [-1432863318, -5359721628], [-315013297468, -3955802616], [-220345420766, -12008247128], [69444202690, -11508937560], [208831299932, 12845240928], [-38546998730, -18392483160], [128342940080, -8807520528], [-97414997522, -4021346088], [101041906552, 8597716920], [-118369751476, -9818367796], [99772025174, -1770851808], [281153549594, 763456752], [98963875732, -18048783608], [-13471626784, -14064687136], [-34529671624, 6037792920], [101005410648, 4231869024], [-14103394934, 18188376408], [-123831343292, -7199775072], [-52739447200, 15911352068], [106507991090, 7204587552], [-39346033950, -23774013504], [349993933768, 522718056], [-464107962846, 3026055084], [-521135433830, 342544], [389695673396, 2113915856], [37779647222, 21715041560], [-359530770756, -1465998888], [9759750566, -9011944512], [113468435630, -6428990428], [-13797581984, -31794807312], [-67105693578, -237411300], [-32922389156, 8261475976], [-63578811092, -25473001968], [-201809683274, 4748250672], [20487097322, -30950392552], [-324457068208, -20845852344], [202618596516, -26097119652], [126330098612, 7671374136], [-214180796926, -25743516624], [-406657881764, 4878692836], [-128079733838, -30712442544], [-11777294104, 36346523828], [-399251878258, -18222733440], [-360068240720, 9589846432], [-401100754670, -6642548120], [375077017022, -14991986440], [-339106311508, 20495165184], [736844858952, 1336712460], [-396180999578, -21111757272], [54171314436, -17005188768], [-606814288352, 15087228892], [-9537828674, -732257208], [-52780914930, 1194195912], [-510722049476, 8594434728], [-7872397462, -12309879888], [103590679038, 10923441396], [-77047830784, 5702071392], [167316431590, -32754199952], [-393249775970, -17833103208], [-288073615732, -30048926184], [-181186950284, 51443594424], [-676839297040, -9394097404], [102539084898, -21249061512], [527724083654, 14599887552], [100324116154, -13555295048], [-304132854896, 10499995656], [-703862208172, -4158275848], [502789509812, -7010642664], [62847771660, -17787587400], [91328233094, -34075033200], [-740984696222, 13284366508], [305336158342, -3212573544], [-96514244768, 60316061832], [89990973566, 35150937984], [-47969661738, 13894614744], [-330428071002, 10164132924], [951176368088, -5308217712], [85074469466, 50227537112], [-286391268396, -21181414212], [652714735354, -5680962000], [630640929188, -4968782064], [311642681424, 19172735088], [-130450389818, -2218363820], [143905842508, -17420530680], [-21958575910, -4480402896], [-591686429958, 252373680], [467017567072, -28464677280], [-1021909224226, 2401325568], [21888488106, -42696672300], [-74255758064, 59940606688], [115406408540, -19940521936], [287130726830, -35062815136], [353053734216, 44972610036], [-457522613554, 41163875712], [280987677658, -14613492260], [974894672512, 2999303332], [-467741276452, -12728029588], [-33301232516, 9729792144], [674701766522, -32305757040], [-533772993186, 14743564380], [402990137768, 13484814984], [-1065913378102, -14892487056], [589614675748, -24587460140], [154224208852, -28390718376], [382774022000, 49246849748], [-910194542430, -32879456880], [539719567768, 46367547912], [-398333714506, -58106642976], [-620764224556, -30632151952], [-744046517808, 29264972076], [1504732086430, 13526783568], [665662280578, 27053318164], [-337946207642, 14836753800], [929292132494, -322520332], [-93013779450, -89573280816], [605794248584, -27322870608], [1015728359902, -23893346192], [-470923068116, -54610838208], [-348613747048, 7074598304], [-28069807888, -100180987920], [-703755008870, -22503761280], [648476807108, -28493949240], [544826970576, -72959937624], [7007156258, -270725184], [1005150249430, -45835841876], [539824084204, -41012934596], [-193293567044, -98450962920], [1377438533864, -26272586428], [184539233930, 38869743888], [1124058148432, 25068320208], [543165328362, 59847496500], [917779839572, 22352341320], [-1096070215790, 24432808504], [-204114238622, 77683902696], [-766665543298, 9389697920], [557168570576, 10060145208], [961897732762, 33387286924], [681899107046, 4367314988], [909964817944, 73983894048], [1523376867302, 20547078624], [-295362550482, -62026187856], [-732103831364, -11452463856], [-1627692861068, -24828055112], [-162494909426, 111526426512], [1177451361938, -29377704280], [875234162028, -54988270908], [1087019736668, -17790270192], [-1090129528006, -82788557184], [397656714622, 29813454748], [1177509824096, -14881140820], [538964932984, 28514878344], [-1013718761694, -69772884732], [311984548360, -42262088648], [876761415610, 7591082008], [1134487391722, -32757905304], [-2029776839184, 6377647956], [192402023676, 74329767888], [-2049959717642, 33978603600], [642008424110, 17345502692], [2026567904324, -23406229036], [-1327699764522, -61401097944], [729066744292, 7846531488], [-1951085192968, 36447049064]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_441_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_441_8_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_441_8_a_m(:prec:=2)
    chi := MakeCharacter_441_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_441_8_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_441_8_a_m( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_441_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<2,R![-246, -9, 1]>,<5,R![-74100, 360, 1]>,<13,R![-7230524, 7708, 1]>],Snew);
    return Vf;
end function;