
// Make newform 23.12.a.a in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_23_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_23_12_a_a();".
// 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_23_12_a_a();".
// 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 := [23305583840, -1204011928, -543567396, 2386582, 2202967, -1234, -2672, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [-116935204579150832, -31593273667574868, 2318475966587292, 127008950486609, -8309753879862, -87447461660, 5556513046, -10909], [-169435264817698192, 15955968300383772, 1480573037724540, -91423325240435, -3874884628830, 155618608148, 2418025262, -77166089], [-35358998056245136, 16056324787480668, 1279860063530748, -91423325240435, -3874884628830, 155618608148, 2418025262, -77166089], [1113343050126616400, -54140358665376972, -9341424506012448, 794767707999049, 7982075029386, -1278748655404, -524855422, 537325315], [-195298459925605840, -4754243314417644, 1683555355300092, 168914805034723, -1154094613170, -372484370980, -216622390, 197139097], [-428246190349665940, 14559363121389606, 6599335960894155, -218240615982026, -19817912564628, 701437623848, 12628127309, -455908112]];
    Rf_basisdens := [1, 1, 351247704839136, 50178243548448, 50178243548448, 175623852419568, 50178243548448, 43905963104892];
    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_23_a();"
function MakeCharacter_23_a()
    N := 23;
    order := 1;
    char_gens := [5];
    v := [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_23_a_Hecke(Kf)
    return MakeCharacter_23_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 := 12;
    raw_aps := [[-4, -1, 0, 0, 0, 0, 0, 0], [-124, -1, 1, 0, 0, 0, 0, 0], [-1433, -22, -2, -2, 2, 0, 0, -1], [-6768, 43, -33, -1, 32, -6, 4, -1], [-36440, 3785, -235, 141, -162, 16, 14, 17], [-276518, 6480, 1212, 135, -238, 42, 176, 109], [-721659, 4592, 3462, -1500, 1206, 798, -254, 277], [-2626048, -27410, -11952, 2338, 3716, 1114, -1550, 612], [6436343, 0, 0, 0, 0, 0, 0, 0], [-40288485, 431493, -86083, 27972, -34186, -21226, -3122, -3757], [-51896853, -79414, 79135, -39934, -4946, 1293, 5168, -14051], [22052005, -539336, -67174, -93048, -280148, 12604, 50660, 24273], [44671763, -3765475, -423446, 57391, -314606, -98869, 88732, 17724], [312623078, -4861714, -599040, -382666, 101682, -20336, -106426, -69108], [32659009, -13606424, -178195, -11488, -1017054, 81321, 32280, 278325], [442848782, -33632, 1397162, 1298630, 1832460, -74178, -129938, 258100], [116620910, 35896996, 2127852, 104420, -860508, -367656, -249456, -899686], [-3166997796, -29365170, -353966, -855100, 3197406, 981150, -372922, 390654], [-389599414, 27828043, 4979827, -2895871, -4008664, 1133042, -1386838, 570633], [-6576378964, -6545573, 10178058, 3173469, -6433332, -407523, -142562, -738161], [-8377480018, -41026492, 10089619, 5352432, -2458850, -4773035, 413478, -2768056], [-3458170974, -30795256, -24489082, -1853426, -15234910, 2805152, -2943920, -301914], [-1533485026, 294363179, -19700149, -9463865, 23948024, -3778206, 1002738, 1174291], [1331274432, 421838206, 21063102, 6677994, 22944434, 2342318, 4139080, 375310], [-15561352337, -33161100, 105788148, 11165148, -33541396, 7312750, -1206754, -4591659], [2422199685, 869634485, -4297853, -27579171, 32309360, 14262614, -20018270, 7930488], [22874591474, 297909659, -72738265, 20888211, -34314700, -8403294, 21492, 3371997], [-57470657104, 297079338, -29194872, -46498968, -22910670, -6927016, 4635174, -8140940], [-76983058570, -1253964340, 41832592, 64655060, -20669758, -13519542, 878882, -20199292], [-58721317131, -140069848, 29666406, 29950920, -17279198, 27322026, 12866598, 35996689], [-59300501373, 178166398, -57171355, 73103998, 120310770, 37738227, -12005128, 4545385], [-133134767679, 1666234534, -10079006, 7593853, -81454622, -21457816, 30870094, -11253264], [90683840074, 939760452, 564768214, 26791112, 63994120, -54234726, -23645856, -64619920], [-46526489363, -2996769880, -716012106, 163418531, -153615238, -50701386, 8897010, -4966730], [672400840398, -309206224, -1315637724, 438491346, 65948206, -3004058, -7974570, -35581902], [88333301458, -8620879263, 153063844, 17510503, -346744180, 101435969, 121594158, -5948745], [-290814328362, -1047756264, 1619148162, -306711072, -419845112, -200080174, -72976642, -52615886], [-39150509700, 2512883485, 983621481, -242926486, 260656112, 48402318, -80955684, 151695478], [-57828202078, 10901997888, 30676690, -690790030, -102927408, 122318518, 9544612, 252031024], [212059529983, 13741560885, -573454995, -516070717, -1025099588, -85619616, 181693078, -185073836], [176590477083, 1748914772, -1541219020, 957044057, 859905758, 114323200, 66175566, -53343962], [161476459811, 25782853292, -2201156508, 1030097028, 957450702, 190981252, -305482060, -27947927], [149970017630, 4642576909, 4401252079, 422732595, 42744930, -356266906, -148252512, -245719317], [-2273728897143, -23306131759, 1254961810, 674551665, 112406098, -38788485, 96391464, 64944984], [964971380843, -14289779473, 4158900175, 137882050, 181910034, 40362582, -190440978, 712263693], [-16338650050, 40210727509, 3826094467, 309535747, -1735985230, 12178242, 16505664, 92411195], [1000085768004, 45829557714, -1174338096, 561606396, -1204428992, -665243854, 778430392, -594567504], [-1188688548339, 66214241143, 464603879, 1462348315, -2061493762, -127323430, 535339198, 1424638722], [-199639272526, -44753281017, 6712382675, -4700826763, -1756797702, -437527932, 1417284138, 109547031], [671043307360, -15747689214, -6802178554, -1198136946, 3285965478, 452459638, -1569352850, -397751204], [959763356984, -215941379246, -8610840969, 3058672550, 1257418490, -1214119937, 1057136462, 64877348], [3336652872716, -67409299547, 484235704, 421371695, 2931277516, 2482313661, -1873618654, 336240337], [-3872477459049, -50463047416, -18587023978, -2501496964, 3941716636, 674108124, -1112159174, -505167031], [-55755945888, -81488052943, -10535516343, -2084546671, 787792192, 796633746, -1109751578, 2654656279], [-7048661510104, -53581020838, -9874422605, 5551335058, 5802519754, 1342804747, -1015797314, -1897915892], [1277149008984, -61530047938, -3401136820, 1186826872, 781033286, -1501447596, -1337516528, -2438848906], [-11943348753218, 181900766848, -12909909820, -4545426415, 5811319906, 968913290, 2575252316, -178325417], [-833911361220, 395357727636, 11776815688, -5387870412, 2983521896, 1758023604, -1605303700, -456657792], [-18114701228527, -7747023027, -2685412019, 1067259500, 11514638422, -2324329014, 1594254298, 1962959097], [-338277822667, 603092712160, -5647371696, -2171863380, 4351108216, -32029130, 1339726630, -865346645], [-7278970847640, -22391539353, -4351936409, 1962799557, 2898408204, 2402219850, 863320058, 4524965923], [8160824332398, -386652294296, -3940479070, -6722903920, -20280822800, 2988879546, -5486139922, 2360514810], [5593207350092, 206858084818, 7520572452, 3943009004, -11233849120, -8347349018, -379784276, 766571020], [1544192807807, 784329924256, 14575443539, -5425579546, -8116107818, 2186716495, 931345100, -1728598423], [-2632335062162, -452125930960, 42784903508, -11102232540, -23348128090, 7627664254, -635350312, -2778649130], [-29433288235297, 210575095039, 10136018153, -2762105225, 533994152, 4562012786, 3682218882, -807020584], [9305949313879, 175065940266, 25394145090, 10896485543, 1211025146, 10808106432, 3910361546, 2028814080], [-25144107060628, 472888631350, -16235462150, 14568423610, -15447408538, -3912506186, 8764057480, -14450446498], [28439544101473, -491309626429, -127128320635, -12197996471, -7597021526, 2371886024, 11196637402, 6114702236], [3693169268856, 394429233160, 162905657942, -12046667537, 194895434, 3792948040, -14577380220, 4066165587], [-37863204134400, -1402915569674, 93353289107, -27651073560, 40373971218, 21854713511, -14232989514, 15602055062], [-19311472280260, -1196546021254, -70540717916, 13324881208, 20448638462, -15577142568, -6791786764, -13351042106], [70765762854850, -764495652631, -29279278815, -9365473617, 32567430306, -3375546780, 13241232452, 4994748191], [66414320427937, 418805606966, -8893139038, -4418119498, 37133322146, 1157805988, -12547657116, 6226150993], [115613785470784, -714465270852, 152725335854, -2976011462, 30663500640, 15562912026, 3971261578, -12226103448], [60317314950610, -1168592325586, 159278626950, 2391049278, 37560997896, 6142849424, -492756988, -8908572912], [17066493848098, -1400069982996, 292042725194, -15345813448, -84798674368, 5331577454, 15444236634, -2737749414], [28966289136150, 1677759259386, 90636255914, -101984587791, -25447438146, -7586336290, 16012989440, 14752089751], [-46419499898157, 963433781270, 160263679542, 21695768962, -127718689398, -16652827292, -20338689766, -5672527039], [-12198640629342, 854771443428, 116280786021, 9509765614, 157787200998, -26777559145, 661140258, -35519103646], [-7979360177990, -2897937494122, 117501624536, 99374671364, -115250627060, 6200292166, 38876372046, -1473241416], [-88843446693651, 1020554653828, -244892935110, 23598038998, 3936721216, -4167855212, 1525207284, -20406922013], [-20384989349718, -2270967001162, 50052694306, 36017411040, 31855828246, 19679169870, 15973808820, 11181840912], [-100762503199643, 707556204056, 173075324508, -53681121852, -55399733542, -38463496640, 44078562142, -2585171419], [45354536830378, 2302427768081, 387793387448, 4020118073, 43094843916, -23186748243, 1731846314, -33657999319], [78635959870972, -4119437570311, -176129567323, -101489955316, 101685201320, -10401031810, -29631840036, -24518545080], [-248594638173190, -1160218186152, -444387052418, 32602845730, -118534347692, 21090926866, -20108850164, -10172234882], [-119705106756459, 1268079329846, -344485061890, -47027970622, -253415614052, -59652388074, 8475466994, -14609335887], [-231224756592982, 1391593045738, -13437184654, -47283549333, -39003812602, -32762344634, 25155409292, 25100285113], [147644319857937, 5531750454303, -19180464645, -116683104729, -46036108902, 29392017818, 23625657426, -12040145426], [-124253081982656, 1809471393754, 318726121124, -94938222738, -56486625628, 51346971290, -45478878846, -10538505872], [97164854979752, 2116289103633, 25811663385, 117216083977, 303664113028, 8029740806, -65618219048, 14868615985], [173623141438000, -732486257221, -133626975048, 113408014769, 110049654228, -114949680685, -33880004366, -139067328029], [365121618753771, 154226940162, -755660015672, 207408032053, 185172019222, -39396217294, 39138367714, 58576142334], [-67293642632537, -10533523753630, 85508615014, -62060156323, -19850346162, -38336629640, 29968909638, -53623491426], [30508747078438, -5095954817384, 631950604130, -226906165114, 365777358566, 95385981248, -36036141752, 91518720670], [269479888989121, 8679357762369, -524484372193, -45378410674, -284629693818, 59522341992, -71961881594, -94764580337], [440912579739122, -9686578776676, -528986217388, 107749549772, 163418880890, -67179144450, -38653789872, 21896085494], [-256939266528206, 13260348963405, 228385531977, -137047235661, -414637396830, -20371595960, 75425195230, 33719042289], [-359939191850694, -9350491556882, -1603734161302, 72036299791, -101431006554, -6419124782, -103540795780, -11260630899], [-417758151587125, -3407924765858, -1192279505648, 75076617913, 332750255238, 74764741766, -114480248594, 61728006566], [155229782743276, -12481973146986, 1173438771320, 11002390218, -510608132436, 104990460526, -71485443658, 48279313874], [785741831575434, 3785704139090, -966547422356, -33301495926, 556368844310, -144407597356, 159181104222, -84055013032], [-491131952230075, 2214729780592, -1291073254664, -86391405672, 767366972042, -53663545036, 101796378430, 127088545689], [336472605352076, 231602697507, 331659052915, -379647656205, -176831428876, -40048814750, 37755746006, -191301612535], [-78762358947411, -2736420358323, 556081234332, -162505147093, -365418103482, 113773774773, -93660779836, 226526200402], [-203174035019138, 2459729988015, -1706508585197, 285129967002, -1090103858988, -147812259158, -22469809564, -127748713536], [685974547674135, 5762842979577, 450492496403, -323344565003, 395477499048, 18700132054, -55270700362, -133571371134], [-331321774292468, -4718946639116, -183874222376, 572527788560, 579480768808, -135315703252, -134409858816, -290122235844], [166344525137826, -10328219639738, -354375117061, 543899103336, 938199266702, -383166081, 342511189370, 21973055312], [-1075117672796622, 24640639445564, -1283191158422, 158905773802, -482161898496, -6391660494, -10641921000, 94243991640], [813351752696947, -6331735320258, -1531766330664, -119560922088, 50346136520, -11556139616, 80581107892, 150222379007], [815359142155704, 11880232007990, 1418700877140, 204051728298, 94525993254, -35978840880, 225578205596, 85694966822], [-420171070416040, -6697174466988, -3898559606074, 8762862906, -282803476328, 88695844338, 197379459606, 36878445788], [-5839147019962, 22385089538982, 1625420129458, -6239839940, -12599483314, 484777497390, -578860463016, 166259673404], [1909046093181928, -16340063792890, 1317169735718, 181650114394, -120868833750, -51406639754, -319951140004, -122646619614], [-521215090480310, 39921613015917, 168510709325, 1049790965857, -1230605812106, -606662952232, 198495832066, -84135560521], [-770734087796706, -9903539188369, 780010847838, -690302380951, -2460222563272, 84273363973, -234190854018, 169660105161], [-1136935310010951, -20007013401295, -947081413695, 539044541938, 286496046594, 214028151174, 79898579798, 203146994871], [494247937724234, -5835293573739, -871477510435, -968418435305, 887704321298, -144447889196, 288233772230, 341812479221], [717644444106268, 13586993544130, -1476737242378, 935664981660, -1904721164470, -584227006534, 60431228142, -398897999654], [53174315225234, 5885567455998, 2075152970423, -1192482126426, 948049349282, 53905194319, -283998454238, -401070927870], [-1841392809824632, -72021879466, 19066763962, -474640079476, 1183594195226, 93197851146, -422514639830, -419145653870], [-255209420927697, -19997354388200, -3210357151260, 664221832133, 3146164803162, 25904451472, -15271908878, -204588360010], [-2619312550059146, -15837624079798, -1950078896210, 87611093506, -1305716585596, 70670069760, 506748063848, -196866772880], [2366861385050401, -23049840660950, 2562129696456, -1601380046464, 698049388804, -187732112276, 223535228480, -294199545719], [278086216611547, -25679813969508, -1045579279436, -376787075698, 887859139490, 468149018496, -23027570552, 419759246443], [-1521938358161022, 30526444043422, 2727717232784, 875665697256, 1077492107708, -167927556226, 593075550952, -176614772086], [-3233463931357038, -36867945260131, -3170764466057, -516396906895, 2589408486100, 845923889004, 11714256636, 203894413307], [-78960636129273, 7321346034466, 3029355640552, 1489560614592, 1287677449288, 33496514748, -101861807968, -160598783209], [-310907272346870, -83907367747883, 7245408237431, -1159035430768, 1002879572056, -167575345024, -548494717716, -76313964586], [-1334466859633322, 61257063495451, 5754066170535, -156830901011, -1130373608582, -234617315988, -332898363120, -295254986947], [32828338953280, 36380983613048, -7029758127880, -431532668982, 1280660015982, 299446940378, 267672754172, 1070075791876], [-704182085203633, -60147815930614, -3214802119912, -616155728090, 3056747117828, -1016562720536, 1011243320404, -567135771875], [2822979719178889, 22305393104019, -7539108349832, 934324972507, -884556176350, -578088029741, 607241278752, 581293971802], [-1786940251215735, 6837142244682, 1139459134412, 396030910878, 347656330532, -64049805088, -261074008386, -81118866803], [-643132546905834, -45179587546248, 6768212377054, 3072574075564, -5770469012, -391037702726, 514887940466, 419782029854], [-7586205958499210, 43540368844198, 6426726288716, 1310558378608, 2276335156240, -621751646354, 635405454794, -97412333264], [1607879811521150, 163793622020800, -599735475682, -1120369022650, -1933369101668, 531473487746, 154557829418, 60386400088], [-1307794779866055, 76211908702615, -4959878318731, -247513915977, 4414003373940, -1273098613674, 146561472106, 681264306326], [-399648807297506, 45491356146909, 7734240971485, -2239616525660, 2310774556844, 454474662986, 479174179332, -223451466750], [4398627170462801, 144017167233927, -14074498965157, 3215710880605, 4294554592680, 328032092808, 166714575230, -38864997152], [845252830006948, -383778749257, 7199403215460, -1872550853725, -168870850012, -46635385141, 567868509286, 1601451559209], [248045239426836, 86133316130292, 9734984388906, -769619599714, 3330985189056, 984203140070, -1059515405206, 677428022648], [-694357006981031, -158462130806039, -3553381183271, -1189811056853, -8289543859480, 84285809656, -348380868126, 131697445114], [-62938758483940, -21325571986577, -9092663152625, -1899565388915, 2588265501462, -1895964052008, 1003417365140, -1050784539385], [5637429338433993, -141584102826371, -1956755058673, -5985284235515, -109781534456, -771794624806, -877084858814, 358920461804], [1672404750764400, 160475604639338, 4511628770107, 2252744680410, -5960090813758, -704751500269, 1424244631558, 478614022656], [1671437139710152, -22652965774327, 9218401980197, 4243329966188, -6441366129408, 1427690237134, 619309166884, 648349335564], [-391441477030226, 11784548514873, -2755192431976, 1427805342705, 10875597140596, -492247911379, 841113666886, 77283490981], [3674489993886745, -43026023060283, -3479672948983, 2605405760191, 1531601543144, -355321459692, 1997432456826, -397663617770], [5218621461127253, 169548118367964, 17403889057832, -3638884237868, -4140700826664, -941955448470, -191882578002, -1485806033149], [6678408074737726, -186922211628678, -6927293112194, 1436296547526, 4692228006600, -207908162580, -788744762152, -147642669704], [2912349261528602, 69390584448297, -11803392840818, -4684506399343, 5684729345732, -685339624101, -548274188602, 107309565557], [1640747833243552, 90441127340650, 11295162177480, -2212464601964, 4531437859078, -3508646787324, 2914779983618, -2752313557016], [11537885029115526, 79349696299676, -2301962248230, 5074173304212, -4008550884960, 572921428218, -563288250644, 1107092398618], [-7537634985613938, -35469549676633, -12882945757325, -3579187133191, 6430218029090, 1166335304188, 1224031507284, 678776831477], [6074036032518689, 63250857334541, 596626091964, -1303448822987, -10896076700918, -330028987415, -1076064597796, -2094178761036], [-13940125780474759, -67918428619164, 7217042931590, 4012894424036, -1556013159300, -2434568554708, 1117482939834, 430402739431], [-10295383481976781, 58077509410404, 1064176220984, -2627710675354, -1989347625850, 202597525704, 2321650290096, 1350184259135], [324737609683691, 146349127827166, 25934659231942, -3939862372363, -7374150285514, 1319511525380, 772780428534, -845790238934], [-2812706925862436, -229431312161682, -13685459908144, 3243597082042, 11204328250398, 1914849034356, 2203275384656, 2105419858198], [14639652127422753, 194650372942916, -8400409371731, -7191492160054, 11569309211690, 39336814357, -3645164186556, 1293446714207], [-7092467843261052, -296615768533490, 19071924296104, 11322644640944, -2648180204790, -3188468086132, -556538540358, -2012665343284], [-8909943068256279, 56281966678206, -13217700657264, -2137183134166, 15921457355880, 1437200358020, -1674854187402, -2060019132363], [3857132275797076, 199808000932334, 379341147020, -787527062054, -27058109386180, 636181666990, 1176725841488, -135073960102], [-13204107463165254, -226070855018054, -24329066297632, -2420652069464, 1106182393036, 1294527560906, 300399716832, -3140522833166], [-8082108400667295, 370868206881755, -570376630615, -887666294221, 9830390179172, -2306916104074, 1011100881430, 1167733636450]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_23_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_23_12_a_a();".
// 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_23_12_a_a(:prec:=8)
    chi := MakeCharacter_23_a();
    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_23_12_a_a();".
// 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_23_12_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_23_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,12,sign)));
    Vf := Kernel([<2,R![6030172585984, -118888316928, -32355612672, 475545152, 32897712, -243056, -10240, 32, 1]>],Snew);
    return Vf;
end function;