
// Make newform 45.14.a.c in Magma, downloaded from the LMFDB on 18 January 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_45_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_45_14_a_c();".
// 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_45_14_a_c();".
// 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 := [-402, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-3, 6]];
    Rf_basisdens := [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_45_a();"
function MakeCharacter_45_a()
    N := 45;
    order := 1;
    char_gens := [11, 37];
    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_45_a_Hecke(Kf)
    return MakeCharacter_45_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 := 14;
    raw_aps := [[-7, -1], [0, 0], [15625, 0], [-14916, -896], [-1908664, 57472], [-18150062, -99584], [-28124038, -385280], [34218172, 1164928], [909341688, 92288], [-2952305354, 18031104], [685304136, 31927296], [-5652579406, 48481024], [-22332431546, 164849664], [5811180340, 385691904], [4540641080, 108399232], [29873144918, -2379215872], [218785088312, -1275367552], [-244050577850, -2672183808], [-646020821772, -4433811200], [-432731086112, 8211842560], [-723819345278, -4444331008], [-311846858760, 15735834880], [1551237122604, 17069371392], [7588798268718, 13552852992], [-11593467261022, -36405337600], [810083070846, -124916904448], [-4003321620340, -85584926336], [-1605113295180, -206759456768], [5712456126662, 121538106368], [5315660526194, -217073884928], [34587058997908, -246404211840], [-72644601665640, 64285162368], [87534058744698, 428508717824], [-83844158569492, 690779018112], [-155665120095626, 133559894016], [71812175304952, -1291903146240], [67448180301842, -1822398212864], [-103311758017756, -1747514321920], [-165488298819864, -1269746794624], [71223939908094, -1364303792128], [-212867867943040, -2191925772160], [-340879229286754, 3838185765376], [528353736014776, -1911550009088], [-147353654326774, -6730521075712], [-643636428711786, 5628551533568], [-250091236445624, 9289856891904], [258813257628596, -4610739109504], [-610660562243932, 10349865492096], [-315138637630844, 23606047521536], [13072460571078, -8072502893568], [618859138188210, -11792546416384], [-1572087580099912, -1255601235968], [-3566290238607806, -13854842550272], [-1139461129789872, -1034488368000], [5810552001428850, -3584045538048], [-8653299833441384, 5434447137920], [1671160813588118, -18805524343808], [3266518357804864, 75397400647168], [-874135329562254, 6316058495232], [-3459324513137778, -12633744111104], [-5956677744200052, -16723115811584], [-4624531182903114, 102455344325120], [-140419019010980, 36504903916288], [10492408489464096, -28750227662848], [-19658495393925406, 34506053434880], [8753754320536030, -23851025230848], [15409019431255092, -199170788525440], [-5151707124495014, -103085859071488], [-37671615126379828, -200258934113280], [-12098769515605466, -153560709474304], [27427140497307162, -128642276705536], [3574857825571032, 108862395044608], [22776314556623556, 173075419266432], [-37641925378058870, -193083771727616], [52308506000741740, 318264886404480], [25952889157978056, 335660414122880], [-7524410649870858, 555426665878528], [-18544950583055750, 924647955472128], [23620960934319270, -783278893798912], [47887139982618938, 395084512044032], [-120776800633810232, 428707082781312], [-22219327547692442, 31156692370944], [-929884318907376, 186870952609024], [4441409039559994, -1983235713587200], [99082018454463400, 229172243504640], [-181147117000219908, 79963104626944], [69065435932368134, 830829834791936], [88329285054556474, 1234297353380864], [1148437032858318, 1697340414809600], [-40295307160136100, 2960615574125184], [110161301956200460, -36558729439488], [-295296130387005720, 524194635069440], [-77732397833043532, -2581090399704960], [165484702931162080, -115880235033472], [324225169831343932, 1598193410089088], [365733376033948912, 725459908345984], [184545432094127222, -2707676578970112], [-151760157737001266, -3006349692563456], [628820182853648380, 1732143824452864], [-603353099158296474, -607049945757184], [-518484658750555796, 1488901664593664], [344670187679365182, 4816601406146560], [499971152095585524, 3561301765952512], [-750131791324470162, -813951567185408], [-991345719342672796, -1777355516533632], [629822912165857538, 694692597898240], [-512966466418456620, 10589427018501632], [355126238504409730, -3542538353970944], [-499822586827390376, 324303435000576], [548413305849331274, -5626443350121472], [-800238743040939092, 5440356267120000], [1704501379244820466, 2975252245765888], [-1455749904511892862, -1592867533258496], [13307840162946908, 5382762945195392], [-298866172762679168, -14538460201299200], [-1530321446238753186, 2790075886283264], [901343547147655140, -8973360190063616], [2389315085498084672, 1371907218444160], [-1182812764286345954, -11223768474534400], [761874249146103320, -2169234449898880], [415861032126455422, -9506363082595840], [-476952890289968838, -13365965785509888], [-3041189650606991466, 7563298973219328], [1341571134923174916, 21967717616697600], [790430020411009084, -12755785403157632], [158367315459307030, -7177384018516992], [-459494913023711498, 3161262289696768], [615677166384526464, 30242087984902656], [1013529360010524212, 33863510809259136], [-1296241616939677510, -14138280043466496], [-4234877902234936532, 22912612429267072], [-4719913146867779680, -12643300376113024], [-4901037249553297256, -37624884874732032], [-5558488986771404558, 19198665178342656], [8279665842580523982, 4613876718570496], [-5060692951048511614, -20603712601143296], [-4299805637843563674, -20647559859005440], [4192121142000742900, -8944993402193152], [4521145176049249870, -17892140852510208], [-823851659659627370, -43323155332052480], [-9573113556151319748, 29291775970117760], [1251162665753069022, -23381028462854144], [6342836285168803316, 4707782105150848], [-1274062357061242228, 29319777266603520], [9044420067313202550, -17158653531402240], [260548160798770600, 13223744722417920], [-5635009435364151486, 16688112460015360], [10246901317400327570, 18113004765546752], [230092950183700300, -72049743765809280], [-11957867433982981760, 94211106814531456], [9075520363508027154, -13452952217782016], [6547723953075822422, -125100990611835904], [3665318641008323300, -67493059209593856], [-20243524831975702680, -13820467596835968], [-2061290300220265260, 58489903192286208], [-1524016056749841472, -43843569103000320], [5201335828100323840, -105844062581568000], [16099403733519827398, -62162843961934848], [-21870458487396341094, -86232914773349888], [-13095272165394237026, 123166755253968384], [-16396820968283722092, 124552653693731584], [13965058250912808122, 3895237912744704], [-26068370763459149572, -34070612937870720], [10116070507010547264, 60211639924561024], [18645206876000940842, 90591003323733760], [26705568429720783648, -92071892941199232], [5296820845287346112, -51544498641443840], [20501536817200411722, -81808132663561984], [-11646441589355318590, 40592930069693440], [27306748314349736134, -21526806713829888], [-11013899363945799672, 285815810069337472], [1272327187226708350, 76210523765868032], [8053923984075547512, 336526076113721856], [35240391024041527794, -201107335315046400], [-39027165360089458136, -138276650120680704], [-1752420584637974802, -156782478369200128], [-40493141030888414484, 125846080524052096], [-39612975414281361114, -377924286232345088], [-24396078034227001660, -438925495395378816], [72561374494425783070, 98680389369728000], [-26281192961991301636, -43070342527502976], [40902347988921321736, -238199635039465088], [6234234423633214306, -643118620632547072], [8601711623783745370, -237416424324421888], [30648733886148244680, 457345203268583296], [-18309446260282733290, 94559411954193920], [-10692668618621257902, 43172511109625600], [-39586303464332071532, 555464275038588416], [48817260583875262394, -212119608257941504], [-6477901345487920168, 159111451560875776], [6219005584434478570, 436787977783545344], [27524722627676046044, -818013137135765248], [-41117471778362707260, 621671676077854592], [-58893825047328145234, 832200238462292992], [-126586848586075383828, 277484022913268480], [114106494114905465434, -86049823032604928], [112652205281356120114, -129167689055956992], [148884767368424996706, 318535785069374208], [10542938684375578050, 615547356387916032], [106926171672230817376, 205493705824720000], [-33271177511136440226, -1269729353891177984], [-136642143928681733880, -56887172778715648], [-43009289696397683814, -843154350249075968], [-30107744586321100718, -200727264915141632], [72979797725960718744, -148786320647202944], [94047686535378493806, -449508578640484864], [-56989209168902284888, 1649072450806846208], [-146015963209263260044, 1010884004261980160], [166384868055823673694, 520871581118606336], [-6310411089126767692, -1401669265631314816], [123741264222358246922, 990395397681842176], [25864532848206875398, 2183282965154503680], [176335254897458832732, 360760247049310592], [-21560696243570979748, 1859834559865420800], [-85241781790447887168, -918688171203171072], [-38279498052335874310, 2797281285551224832], [44111011606742716852, -1202635879731342464], [-10328178740755590810, -3550964275003018752], [-140156598558398642336, 761747510552032128], [-48798700475411293650, -2161877421887071744], [52017778135769136358, -1918452233286754816], [268633300523128298744, 437539032191727616], [417278454666669665790, -1175560922851153920], [248397682696663137196, 80337614806717568], [-307793183048013136580, -1909255565567271168], [-134835184659623416330, 3824825822491294720], [-100239320079697234854, -691974030300765440], [29484128671840192768, 3524926625025628672], [54565905777353792740, -329532681422494592], [90302118727242604632, -3369074044516037504], [176291441465745927762, 1070016541710798592], [138077969116186923172, 2113279055721339008], [293237295953190153824, 2625147759772141568], [-131205723757106325490, 4009559425192913408], [432203916658796683916, -3080727942759924992], [-490391658741315535008, 667914742825147520], [-75505192156814212686, -739815227638191104], [-512074937099400320954, 698411631741288960], [697496102627898954888, -946580427849518208], [-25142411504382205680, -5212677112089603072], [-95416449383950976796, 2947017700962911232], [-648253544457658321212, -2169002314413218176], [-68650723648855569596, -1727460465769754240], [-41007178418897912874, -1298153957303289856], [702320343635901314586, -2147778947324064000], [-391068840053145015808, -3331838743082994432], [442590815397337151396, 2767155431294225792], [393117310284621414224, 2504404604662070144], [-252228857298726067132, 1835124509426792832], [549553302379841105936, 412286810810943360], [-536094166820020386566, -888578447645842176], [-275459052484928886082, 1784308200679879680], [222311325714075520056, -2319621291307726464], [-255273398398591084422, -6349201366427977728], [182460856910475288526, 4447835162739596800], [-193600180706140048104, 6061922226486137984], [300170113555983368302, -4750803706486530560], [121885790126371782908, -1742114044834956800], [-687184535723777428986, -322488300913096192], [-1309363583917843106014, 2727785900108426752], [-28206984081758596220, 8094301985318757504], [-558005645511719815484, 6865458852929193216], [-1256083030156239385066, 3243475764784577536], [-131379886577902816854, 4436482382290422528], [181935227306470948242, -7377718142795365120], [607610296235603938156, 3603693946555342464], [-472227315412156175602, 5073711528345846272], [-103779586198210942250, -12115467016892790272], [837682064892841069532, -5225715620138527488], [1170398265488451668534, 6182979875919562752], [761943907164288161678, 1086988240738343424], [379754587841330575420, 9989553395343225088], [-1282225088849749188526, -6336588091016371200], [742945453334468880744, -2171177714238714624], [-480668838408534880230, 601265485663298048], [687324652656422012444, 1232716905173797760], [-597957671642627972676, -14085980878242432512], [403218007590841555350, 6584394823407298560], [-1449794116437308755446, 469894593678711808], [1726335757060748488824, -10016948535259540096], [877842153549213132208, -7311304709181136512], [-805304148133774115672, -16061868628727262976], [718357880485575897376, 2440756156711680896], [1858019266175609563974, -4139005702139633152], [1006674752103861095940, -9562523761348662272], [2114467872648400735464, 7727229097182635264], [1046835368707926249394, 981140117984529920], [1929938998398141606438, 3801054185058773504], [-5213838887484917176, 16296581239748645376], [-1747132722691860933090, -3739722773023505920], [-1029792581988203692754, -1610240697467609088], [280358559214419076780, 7474228456021866752], [1188438979401148083426, -13285008788678327040], [626753971031200537992, -10251365863183954304], [-1971660584999019204886, -14392677175493105920], [-725855965323966005250, -17676648209672320000], [1848162911771629752152, -13945690401459187200], [79126859742402215622, -5325436334327287296], [-3880302770961339508200, -5868991173636754560], [2323359928503481259852, -4134909719497999104], [921259296823197930066, -3298965246688072192], [1054865373668921578718, -31740492962360861696], [-882804049649461396016, -8890132220363105024], [-644714695227315937716, 9669156105498007552], [-227375017075897025900, 19448208206001660032], [-1264747669567555954702, 17486956329118261760], [1177671895518357326100, -6925286548344286208], [-3434342767474503337858, -17484281999497772032], [1864632558593415280608, -4301710954989875968], [1085009482129760922810, 7496057860079500544], [413820834814864250160, 32987558454322663296], [-2597741529477570018162, 16821700137095096832], [-2870554738516284573546, 18154779581066397184], [1585649064218107394684, 21193430835616099840], [-1481509575547436733920, 8158619239795437952], [1154189321678654983162, -29326015990707740672], [2306232081951532186176, 30545629466701533824], [552901049823178988808, 32283089322435682560], [-2462068738185739565958, -30678140566649947648], [-4328579449118792327874, 14601303719512477184], [-2537980642555210686724, 23524447310239061376], [53152080003544589474, 59442006194577089024], [895460364414196964486, 21964482694152189952], [-543238213908790217540, -19117606482735102336], [2053658330239520083650, 9923603943005455616], [5009177195045657196994, -23955925104081170432], [-1405054082289850502140, -60110306542447794560], [2661122712314986375684, 54637459536607596800], [1367670586141686476808, -72145357933588191616], [-4251641874811599655786, 8117691198218307072], [-2900895474522362497458, -36528762138736391680], [6426672835277688172622, -5791004953090913280], [-7439818591624441063240, -18918124367823256320], [-4007135250008818940228, -52769696447799248896], [-235663122761795250580, 9930926033662431872], [6047602590698658905668, -6643288313038852096], [-8127017940241918531474, 23396695170892089344], [184412205694147971274, -24871156871869745408], [310153455101474387690, 65057554539126607872], [-3305856357610241934252, 35974266947606289280], [-61181180374818697670, -28636236320597808896], [-5902035391072394606414, -6475011737224949504], [-716598987211050985218, 64520404111725831168], [-6902711018534600496888, -31511438340484829440], [-4255979318103881351746, 36127696875607767552], [-4933880041729279674240, -36939692805673450880], [2300208088994042415830, 74900682119236383232], [-3720491161487773260764, 55486959518363082752], [-8253947539024184527416, 64305928083208329984], [7231763571562431538534, -28970671557068511232], [-3822540490382212935276, -24155515635925036672], [-827459750473036650534, -60651199699494345728], [-488275408647771317786, -59938945021338474496], [8514510467228476161748, -32275246354955965824], [-1098305139831151903458, 31758030382252433408], [1786894466789844003234, -21668648444703089408], [11756708975554176994288, 20568782913201751552], [-2813401092874949159688, 9196997264908500096], [3874078121822328407874, -12300475933492978432], [684817082404650859304, -61546833788340099968], [360469243254839297578, -69457052797455619840], [-12529293677367777972778, -39700465675804931584], [-16480339196377589318376, 7978602898084928128], [-2825117898562033343368, 13080641394158040448], [-4411583469766426024780, -57180305515065015552], [19059937686102337732522, 10194928233871007232], [4775254524966573635982, -2954431988317015040], [-8176699630420822277604, 84586324019265081728], [6060311493915362270714, -28106381327199593472], [7826962899966386870592, 121508517854586399616], [935416632390866267292, 121790432641635301248], [3775552047414262126328, -62972793538055770752], [3089807693267671274238, 33037466116805824512], [-1558748356903945166232, 104484390933445304064], [1005716764638449049274, 197138077056246351104], [-12300513929210238272032, 12266296974609670272], [10533468940338822723840, -63632196762099071232], [1913333105444404386578, 75052169791047233536], [-7743409170987477312426, -50295128133528976384], [19648251512093730284410, 88587084709036397568], [4471669852831030282078, 122657392541031503360], [-2910008478033335309190, 239279165589567480576], [-12778462931175530351684, 84744294118093423232], [14592321474845892272842, -156518983086068512000], [-24686771318090989676076, 9852503206305684096], [-7406077194089865677080, 18920073968495894656], [1152958728631604899208, -13077116039718209536], [32850697815164106583250, 13239912427928046848], [-6097637541427330051500, -34988778305007319296], [27517978544884756023360, -45373012543742393728], [13853226369813386482818, 1366371607441841152], [-212071439355548366986, -76345373076568444928], [-12038861832579382322584, -107122295355879218816], [-15799937014281698629276, -63857924807042928896], [-9227355810233568936520, 173997048261066009088], [4102236096215212320074, 177630275841956551680], [13108743413892602140640, 92802661488865465600], [-12095485120854876212298, 127461978151988694528], [-12263037069611962174364, -51656584284790728064], [12095593177903937195622, -243080485338986906624], [9768250619449840890526, -200580773381409212416], [554398463780840244642, 21396671437145177344], [3341371709524145886724, 126694345895770898304], [-5015334558866498838134, 187733758855828774656], [-21193219606781969701682, -113257663569964346368], [12747475346962323168976, -219488332032842828544], [-8137067955023481101542, 135867994534402033920], [4929241411338570016486, 186152901126864676352], [-19172963876564253321756, 1376340150133637120], [3520337640868947567192, -185247436339520074112], [5174175752040513407298, 160851319187733231616], [4861878781552203613350, -71770121079358553088], [-25093639584443480988172, 66259087441293486848], [19828923846141804957564, -123982026666510511232], [-20854940091636444444670, -77364847211762291712], [15855964619750427315062, -113027674874446559744], [27276565520767620194848, 251252218623388280832], [8801446337985960940540, 236196826582267164288], [-33887654261789875515534, -232485687661221498624], [18371266935062313784312, 154211787726774811264], [-17364929011130994526946, -198342837672949028864], [-5799784787839548384374, -209946241474195093248], [-29665025311438589664696, -121132000057462614912], [-11261252964809510733328, 211334009652900796288], [5845784375352186146978, -390151649851448948224], [17631468173094017183390, 233888236934234097152], [-14924349250359572664212, 153316525682011836928], [-12414932157622161373530, 345322189594688583680], [-55539690949034039621596, -25728553728055047552], [24134415158234713191032, -256363948960881015552]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_45_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_45_14_a_c();".
// 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_45_14_a_c(:prec:=2)
    chi := MakeCharacter_45_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 14));
    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_45_14_a_c();".
// 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_45_14_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_45_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([<2,R![-14432, 14, 1]>],Snew);
    return Vf;
end function;