
// Make newform 30.12.c.b in Magma, downloaded from the LMFDB on 07 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_30_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_30_c_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_30_12_c_b();".
// 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_30_12_c_b();".
// 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 := [173683668788100, 0, 30638651521, 0, 350078, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [0, 175039, 0, 1, 0, 0], [-6151994261460, -46925470052, 156981082, -875195, 1198, -3], [-4613646454980, 97497589614, -230154201, 1166962, -1089, 4], [-9227292909960, 46925470052, -181996392, 875195, -588, 3], [4613646454980, 114805407004, 230154201, 1750390, 1089, 6]];
    Rf_basisdens := [1, 13178910, 1396964460, 1396964460, 1396964460, 1396964460];
    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_30_c();"
function MakeCharacter_30_c()
    N := 30;
    order := 2;
    char_gens := [11, 7];
    v := [2, 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_30_c_Hecke();"
function MakeCharacter_30_c_Hecke( : Kf := false)
    N := 30;
    order := 2;
    char_gens := [11, 7];
    char_values := [[1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 12;
    raw_aps := [[0, -32, 0, 0, 0, 0], [0, -243, 0, 0, 0, 0], [-1654, 378, 1, 0, 0, 0], [-1, -22462, -3, 2, 5, 8], [292249, 14, 47, -42, -37, 70], [40, 105013, 120, 153, -200, -87], [-62, -958183, -186, 225, 310, 597], [-678436, -176, -396, 528, 660, -880], [652, 16622556, 1956, -1368, -3260, -5280], [11947536, -873, -15174, 2619, -9936, -4365], [-20381518, -3112, -22878, 9336, -4206, -15560], [496, 311868061, 1488, -13591, -2480, -16567], [334454162, 16738, -21796, -50214, -122224, 83690], [-1484, -326803304, -4452, 71428, 7420, 80332], [35858, 730133860, 107574, 232920, -179290, 17772], [-24236, 2331238159, -72708, 102447, 121180, 247863], [-678071517, 35646, 515549, -106938, 301673, 178230], [-2064124286, 68008, 860472, -204024, 452424, 340040], [-128562, -1693311972, -385686, -19568, 642810, 751804], [2284081946, 227164, 493038, -681492, -869946, 1135820], [-23688, 18296671590, -71064, -64778, 118440, 77350], [-2240425038, 453216, -2111238, -1359648, -4830534, 2266080], [626292, 19151519600, 1878876, 7653852, -3131460, 3896100], [-21239777598, 250656, -1038248, -751968, -2542184, 1253280], [-58204, -105084666988, -174612, -5593844, 291020, -5244620], [100905369052, 2134811, 7538902, -6404433, -5269964, 10674055], [728765, 65653388822, 2186295, -10244050, -3643825, -14616640], [1513308, -24250964940, 4539924, 13531968, -7566540, 4452120], [-126414649138, -1262130, 6720516, 3786390, 14293296, -6310650], [-2820226, 78391437497, -8460678, 752481, 14101130, 17673837], [-6758881, -103236611134, -20276643, -30374878, 33794405, 10178408], [294558497183, -1793258, -23736351, 5379774, -12976803, -8966290], [246798, 539012032479, 740394, -45674361, -1233990, -47155149], [92227596418, -13029020, 54647766, 39087060, 132821886, -65145100], [-523394114756, 3931643, -89791750, -11794929, -113381608, 19658215], [1043128285646, 23553560, 54760014, -70660680, -86561346, 117767800], [3840104, 417230484143, 11520312, 72109363, -19200520, 49068739], [23303094, 185996838984, 69909282, 121239164, -116515470, -18579400], [-10749796, 604655494952, -32249388, -14103756, 53748980, 50395020], [22561888, -1251941987191, 67685664, -96743799, -112809440, -232115127], [-1330344774869, -53583658, 36044021, 160750974, 357545969, -267918290], [2354013310674, -31678054, 148014180, 95034162, 338082504, -158390270], [2903404303550, 48381292, 120749922, -145143876, -169537830, 241906460], [-56243428, -129344975842, -168730284, 42806614, 281217140, 380267182], [32950104, -1721613533623, 98850312, -343713807, -164750520, -541414431], [-1307233908358, 72815224, 335093202, -218445672, -101798142, 364076120], [222603063062, 134344012, 647065026, -403032036, -158999046, 671720060], [82162737, 5293542909438, 246488211, 240370006, -410813685, -252606416], [128552996, 453596031192, 385658988, 1036975572, -642764980, 265657596], [6334371685794, -49499306, 468004212, 148497918, 765000048, -247496530], [193409058, 2333009821939, 580227174, -170011845, -967045290, -1330466193], [-2164832418146, -68305012, -1075302110, 204915036, -665472038, -341525060], [-8180416722074, -88265148, -329083128, 264795444, 200507760, -441325740], [997055345471, 193552450, -573621015, -580657350, -1734935715, 967762250], [-312102686, 10598221277947, -936308058, -1031122269, 1560513430, 841493847], [472918048, -4223784406704, 1418754144, 1926560412, -2364590240, -910947876], [-16892227723416, 91526433, -150688530, -274579299, -699847128, 457632165], [-17719876649214, -360944336, -469194894, 1082833008, 1696471122, -1804721680], [-19454352, 5863656443313, -58363056, -1297551547, 97271760, -1180825435], [-17875209366450, 156638988, 3598699896, -469916964, 2658865968, 783194940], [-488315030, -12403122877196, -1464945090, 2869808600, 2441575150, 5799698780], [140982936, -32159632064505, 422948808, 2222881839, -704914680, 1376984223], [-265359572, 28259321091244, -796078716, 831360888, 1326797860, 2423518320], [-6133807233602, 189750812, 1489117794, -569252436, 350612922, 948754060], [1009677332, 30266589911414, 3029031996, -2315863250, -5048386660, -8373927242], [-127184032, 28559824599363, -381552096, -3494401461, 635920160, -2731297269], [13960130298892, 1577565384, 904990860, -4732696152, -8560401444, 7887826920], [1819203296, -33861771100954, 5457609888, 7213249958, -9096016480, -3701969818], [305253608, 20080595792168, 915760824, 1625604948, -1526268040, -205916700], [93853224556878, 1452739244, 3899310264, -4358217732, -4817125200, 7263696220], [-2121839102, -81193517134957, -6365517306, -5968158453, 10609195510, 6762876159], [75072323722468, 616394504, 637278276, -1849183512, -3061088748, 3081972520], [-41778697, -9273987276310, -125336091, 77511242, 208893485, 328183424], [-2880444344, 143857986605353, -8641333032, -7450814763, 14402221720, 9831851301], [-98139762951646, -1789009492, -5345356626, 5367028476, 5388700326, -8945047460], [-2364373694, -144631225692544, -7093121082, -12432235068, 11821868470, 1754007096], [32466103823240, 2170486363, 19501467838, -6511459089, 6478549660, 10852431815], [-6265478176, 90571477169165, -18796434528, -13248636007, 31327390880, 24344233049], [116572135628382, 1470356382, 21733274764, -4411069146, 12911136472, 7351781910], [2216247402150, -524261246, 4316184072, 1572783738, 7461751548, -2621306230], [-68843447960499, -801580626, -14359659797, 2404741878, -9550176041, -4007903130], [95940551037798, -5123774534, -20169946476, 15371323602, 10572700728, -25618872670], [265520302341460, -315799048, -23267108620, 947397144, -21372314332, -1578995240], [5104243712, 144867861018338, 15312731136, 40285969882, -25521218560, 9660507610], [11691779829714, -6785457696, -33335357382, 20356373088, 7377388794, -33927288480], [-8252202560, -66443445355304, -24756607680, -2828831436, 41261012800, 46684383924], [223968205398938, 442863646, -24353462868, -1328590938, -27010644744, 2214318230], [6143525604, -12644133249240, 18430576812, 9976244816, -30717628020, -26884908808], [26791475294732, 6372205513, 18884347686, -19116616539, -19348885392, 31861027565], [-4509829245, 313659180679290, -13529487735, -28157636454, 22549146225, -1098660984], [-2901285432, -337325453699736, -8703856296, 48876622452, 14506427160, 66284335044], [78362292695770, -439319596, 45569016382, 1317958788, 48204933958, -2196597980], [-16779742595, -75418654891682, -50339227785, -76107987642, 83898712975, 24570467928], [-18153474855601, -1450082162, -2618111775, 4350246486, 6082381197, -7250410810], [-370394944890896, 4053947000, 60013952424, -12161841000, 35690270424, 20269735000], [23656326050, -351251006094484, 70968978150, 29069873856, -118281630250, -112868082444], [213748855129948, 18490270691, 10353863262, -55470812073, -100587760884, 92451353455], [-665421355090274, 10715613194, -58990069676, -32146839582, -123283748840, 53578065970], [-3564258778, 702879943499696, -10692776334, -41374341868, 17821293890, -19988789200], [42572631912410, 5866427618, 100518058260, -17599282854, 65319492552, 29332138090], [4835155724, -854131235736832, 14505467172, -85308615892, -24175778620, -114319550236], [30239926544, 218923426752353, 90719779632, -69989507631, -151199632720, -251429066895], [16602810064, -223402186604944, 49808430192, -117201619620, -83014050320, -216818480004], [-363886525220710, -26825619530, -157491375884, 80476858590, 3462341296, -134128097650], [-353492243213044, 19281513488, -97478319492, -57844540464, -213167400420, 96407567440], [6533317468, -1196424679156580, 19599952404, -25074747268, -32666587340, -64274652076], [-26868549308, -1494923611905356, -80605647924, -65575635984, 134342746540, 95635659864], [-54849191298, 287929858133169, -164547573894, -185200119927, 274245956490, 143895027861], [-163041752948284, 40988665552, 67760147220, -122965996656, -178171846092, 204943327760], [-1951748426040290, 12734845222, 52212432096, -38204535666, -24196639236, 63674226110], [47874649297, -616867125002018, 143623947891, 206239564870, -239373246485, -81008330912], [33386987832, 2209133890439511, 100160963496, -46317639941, -166934939160, -246639566933], [-2188319874, -1395069711648491, -6564959622, -2492260947, 10941599370, 10637658297], [3222138304180478, -9639253996, 83769065802, 28917761988, 141604589778, -48196269980], [-1819388777214418, -23742344184, -110014274250, 71227032552, 32439790854, -118711720920], [-1330908010187110, 38617307758, 90758949260, -115851923274, -140944897288, 193086538790], [34043393690, 2819832892609160, 102130181070, 307433662236, -170216968450, 103173300096], [-50966163634, -738399918311716, -152898490902, -21012252048, 254830818170, 284784729756], [-26837333868, -2566403332692571, -80512001604, 24868581741, 134186669340, 185892584949], [-1581746123111943, -43287258606, -144626762473, 129861775818, 115096789163, -216436293030], [-1250282553093590, 20665721716, 268676667288, -61997165148, 144682336992, 103328608580], [-61357162424, -973958404355666, -184071487272, -460406202906, 306785812120, -92263228362], [72813262244, 1476475809497391, 218439786732, -269599803849, -364066311220, -706479377313], [-27051908252, -565352076330096, -81155724756, 586271557836, 135259541260, 748583007348], [-64172733841864, -72362715760, -622545967224, 217088147280, -188369672664, -361813578800], [-1160528962624708, 90134512333, -246607444006, -270403536999, -787414518004, 450672561665], [-2130051717923070, -185821637310, -600198449724, 557464911930, 514731374136, -929108186550], [-1863823855707360, 129879594504, 565103126920, -389638783512, -214174440104, 649397972520], [45559394565, 1606669371760326, 136678183695, -275252226066, -227796972825, -548608593456], [-13192154656, -6368158196848633, -39576463968, -152136483613, 65960773280, -72983555677], [1144599367369116, 46061131856, -630927502596, -138183395568, -907294293732, 230305659280], [-62308662898, 2816724579538136, -186925988694, -264211369812, 311543314490, 109640607576], [8508390108125662, -26340689840, -203101583994, 79022069520, -45057444954, -131703449200], [-10784443640, 2634865174071217, -32353330920, -865388411659, 53922218200, -800681749819], [4773659484118438, -90785490682, 49334694060, 272356472046, 594047638152, -453927453410], [-4181557621018214, 46885903550, 248998990752, -140657710650, -32316430548, 234429517750], [-108047119104, -1837292279880951, -324141357312, -936779127615, 540235595520, -288496412991], [-47740544042, 9490843467330328, -143221632126, 429072558332, 238702720210, 715515822584], [-161331470824, 737955888964071, -483994412472, -1263194000793, 806657354120, -295205175849], [2564409997216614, 57322670406, 844303751004, -171968011218, 500367728568, 286613352030], [2860430041652822, 132280373108, -360948045222, -396841119324, -1154630283870, 661401865540], [8348443342742176, -50664069127, -369711157826, 151992207381, -65726743064, -253320345635], [29828435059, 115556951151178, 89485305177, 1630219011786, -149142175295, 1451248401432], [16326553624, -582415387396324, 48979660872, -741591826776, -81632768120, -839551148520], [-6023579453506474, 102125412754, 1475182375164, -306376238262, 862429898640, 510627063770], [6513310979024448, -148996260192, -1066724641528, 446988780576, -172747080376, -744981300960], [-226060526968, -9532413111158941, -678181580904, -2103299033593, 1130302634840, -746935871785], [127495531674, -714098663770443, 382486595022, 1152288035901, -637477658370, 387314845857], [484213572800674, -190454397564, -408400130466, 571363192692, 734326254918, -952271987820], [268415592284, 9849216186371528, 805246776852, -221129775180, -1342077961420, -1831623328884], [215616014608, 6284310977796607, 646848043824, 2015982190771, -1078080073040, 722286103123], [-8900790976896378, -181357624488, -1039570358472, 544072873464, 48575388456, -906788122440], [292621962034, -201140078217608, 877865886102, 158041704540, -1463109810170, -1597690067664], [111185820804, 6761906831737224, 333557462412, -1437476598972, -555929104020, -2104591523796], [-472155685344, 4930185265083792, -1416467056032, -1736996915652, 2360778426720, 1095937196412], [-8262232370219848, -286092628472, -411994804200, 858277885416, 1304560966632, -1430463142360], [-4872454734796982, -284927810560, -1198820266398, 854783431680, 510746596962, -1424639052800], [-605022585705254, 129397858766, -1142167969044, -388193576298, -1918555121640, 646989293830], [83419946520, 37696827741271476, 250259839560, -221328342332, -417099732600, -721848021452], [-33153884780911512, 979520865, 881670757610, -2938562595, 875793632420, 4897604325], [-135745640620, 16864696818619628, -407236921860, -717488420328, 678728203100, 96985423392], [-230065483006, -11500446630233271, -690196449018, 2485380266289, 1150327415030, 3865773164325], [651017901755, 9628181594540834, 1953053705265, 1658923685314, -3255089508775, -2247183725216], [-36711624533560473, 300379686474, 2296446953409, -901139059422, 494168834565, 1501898432370], [397437140602, 22734443920177645, 1192311421806, 4326230255733, -1987185703010, 1941607412121], [-511683051294, 28981953948769192, -1535049153882, -1158899349780, 2558415256470, 1911198957984], [-13814347508007602, -889002438744, -3303815505858, 2667007316232, 2030199126606, -4445012193720], [-752155013432, 2012958168639691, -2256465040296, -4632107132577, 3760775067160, -119177051985]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_30_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_30_12_c_b();".
// 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_30_12_c_b(:prec:=6)
    chi := MakeCharacter_30_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 12));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_30_12_c_b();".
// 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_30_12_c_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_30_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,12,sign)));
    Vf := Kernel([<7,R![29947171023497902154506242304, 0, 32891155395360292368, 0, 10727432952, 0, 1]>],Snew);
    return Vf;
end function;