
// Make newform 63.7.m.d in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_63_m();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_63_m_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_63_7_m_d();".
// 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_63_7_m_d();".
// 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 := [21068100, -601290, 985651, 36821, 39800, 473, 212, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [-1017283529220570, -423382833624317, -529666993003657, -20860832470090, -2673339327091, -65484675874, -12595814413, -405518177], [-5583985297290, 8366760637851, 15479370553, 336428371378, 3085757533, 1621914529, -13389005, 8497603], [-887386378854226320, 177824901485458486, -4649039539643404, 2374626244486355, -45647117796292, 12542253415247, -17272473736, 30359760961], [-1022366367515487780, -171328578806357686, 4771038672935884, 594392649047605, 69967211645572, 240706081393, 484838322556, 36613259519], [-12764692598290560, -9572214805242754, -4885911718111139, 569010508767670, -21226630078907, 3951590320162, -201659710511, 20960695316], [66916687643934480, 14428518294215396, 2960686065927031, 580595236989325, 21592891249843, 3013487903677, 40700920519, 14593340681]];
    Rf_basisdens := [1, 1, 11540026222043130, 7542500798721, 23080052444086260, 23080052444086260, 3297150349155180, 1357650143769780];
    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_63_m();"
function MakeCharacter_63_m()
    N := 63;
    order := 6;
    char_gens := [29, 10];
    v := [6, 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_63_m_Hecke();"
function MakeCharacter_63_m_Hecke(Kf)
    N := 63;
    order := 6;
    char_gens := [29, 10];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0], [1, 0, -1, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+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 := 7;
    raw_aps := [[1, 1, -1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [26, -2, 25, 5, -1, 0, -2, -1], [-75, -19, -12, 6, 6, -1, 5, 4], [12, 1, 44, -105, -3, -11, 9, -13], [303, 3, -567, 2, 18, -19, 39, -40], [896, 182, -436, -82, -30, -42, -42, 6], [-1425, 166, -1594, -251, -125, -88, -118, -125], [-944, 344, 1008, 64, 144, -128, -48, -16], [1040, 1537, -145, -1392, 48, -97, -435, -290], [-14670, -1086, 7313, 530, 62, 70, 70, -18], [16431, -1368, -16544, -113, -79, 226, 260, -147], [8866, 1052, -16648, 1272, 872, -652, 1084, -864], [6845, -1459, -221, 1680, -620, -841, -663, -442], [-41226, -1220, -39896, 1302, 1234, 192, 2180, 1234], [-864, -511, 137478, 7879, 1533, 353, 669, 1375], [27852, -2709, -13548, 571, -3079, 811, 811, 2323], [36236, -17232, 39700, 32440, 2744, 1440, 3328, 2744], [-2148, -1045, -289965, -4267, 3135, 1103, 987, 3193], [-188446, 20866, 758, -21624, 3408, 4166, 2274, 1516], [-71634, 27083, 34855, -14317, 2297, 3475, 3475, -373], [160501, -5248, -157751, 2750, 7518, -5500, -732, -2018], [97070, 15973, -192851, 15078, -698, -197, 1289, -2184], [81340, 2428, 81682, -5582, 534, -384, 1644, 534], [-118308, -33555, 232593, -37586, -8058, 4027, -4023, -8], [-260924, -6182, 127174, 6714, 20398, -670, -670, -13822], [411025, 3614, 416580, -10151, 4239, 2632, 4530, 4239], [1014904, 8160, -1011635, 3269, 99, -6538, -9708, 6439], [-2516, -5123, 236041, 87659, 15369, -2607, 12853, 7639], [730490, 174556, -1444, -173112, -11112, -12556, -4332, -2888], [-380113, -91632, -10032, 101664, 10908, 876, -30096, -20064], [649826, -43682, 675889, 63389, 25019, 2088, 46906, 25019], [-29160, -19412, -283156, -154188, 58236, 9748, 29076, 48572], [-231143, -56545, 461177, -55502, 1010, 33, -1109, 2152], [2634052, -257536, -2636418, -2366, -32802, 4732, -25704, 28070], [23200, -7357, -248776, -250563, 22071, -30557, 45271, -15843], [-2905720, -37400, 1446324, -5208, -21672, 60888, 60888, 34744], [-1257062, 326496, 1289276, 32214, 36786, -64428, -59856, 27642], [-440270, 180722, 926606, 185076, 29564, -25210, 46066, -41712], [-262224, -69680, -409244, 199980, -103820, -86400, -78040, -103820], [50040, 27968, 1471722, 4456, -83904, -22072, -33864, -78008], [2064885, 93639, -4043103, 141354, 114906, -67191, 86667, -38952], [5185270, -68936, -5179156, 6114, -16362, -12228, -34704, 28590], [3232, 29310, -2820321, -131150, -87930, 26078, -84698, -32542], [-936364, -407222, -13810, 421032, 9360, -4450, -41430, -27620], [-4052080, 111888, 2039708, 144, 57504, -139512, -139512, -84840], [673250, -599602, 20242, 579360, 110728, 130970, 60726, 40484], [-44324, 796259, 30383, 787098, -42874, 33713, -58265, 49104], [-3927416, -210851, 2008330, 156741, -75857, -191875, -191875, -13387], [3453777, -87294, 3333202, 180803, -63395, -114360, 44750, -63395], [3093838, 762888, -3142910, -49072, -177312, 98144, -30096, 79168], [572018, -252014, -12322, 264336, 174288, 161966, -36966, -24644], [-12359356, -766675, 6146788, 366549, 97983, 99357, 99357, -32203], [-2072904, -527919, 4103061, -420978, 139038, -32097, -42747, 149688], [-6698314, -699896, -6588338, 1317080, 96344, 27264, 151792, 96344], [19488, -76862, 12879284, -282834, 230586, -96350, 250074, 57374], [11512772, -568039, -5837794, 185321, 128235, 360213, 360213, 34581], [2873180, -124894, 2938641, 250247, 32501, 65920, -33878, 32501], [-144564, 100819, 7753571, -1190699, -302457, 245383, -447021, 43745], [-9386428, -1109192, 58736, 1050456, -201168, -142432, 176208, 117472], [14944102, -1237207, -7466693, 538729, -181181, 149033, 149033, 170465], [1866148, 523631, -3994789, 317826, -439954, 234149, -262493, 56688], [8235649, 595649, -16353805, 678830, 183518, -100337, 117493, -34312], [-492756, 292812, 260214, -19508, 198452, -281468, -281468, -226124], [13610941, -752960, 13998533, 1439048, 227232, 320720, -26616, 227232], [-5145788, -169328, 5028917, -116871, -163029, 233742, 187584, -70713], [-5132817, 2354864, 5151042, 18225, 339287, -36450, 284612, -302837], [-21866359, 2855474, -24002, -2831472, -38480, -62482, -72006, -48004], [-155664, -38322, 6364648, -3878470, 114966, 117342, -40698, 193986], [7821548, -832556, -15127364, -867592, 205312, -240348, 515732, -550768], [-15369188, -2182250, 7758010, 968670, -538574, 98078, 98078, 391742], [8082844, 4800912, -7988348, 94496, 282552, -188992, -936, -93560], [28612690, -4846992, -14295259, 2547808, 204280, -270796, -270796, -226452], [4858609, 1963048, -4957956, -99347, -120309, 198694, 177732, -78385], [-19593931, -856783, 255631, 601152, 120964, 376595, 766893, 511262], [8138564, -545756, 9505978, 474338, 992294, 750240, 859228, 992294], [523128, 88588, -39294370, -152724, -265764, -434540, 257364, -611716], [-13172545, -1065646, -12728544, 2003315, 285989, 316024, 97942, 285989], [-33180272, 2055656, 33110628, -69644, -28044, 139288, 180888, -111244], [-21206090, -3145708, 10536085, 1474420, 70972, 330788, 330788, 62948], [14184094, 2723114, -28499914, 3195372, 642524, -170266, -131726, 603984], [13201067, -6909591, 18735, 6890856, -69828, -51093, 56205, 37470], [-744624, -793516, -7074570, -4529996, 2380548, -48892, 1635924, 1538140], [22605155, 1180795, -45547943, 369922, -1385126, 574253, -337633, -473240], [-2701628, -1217846, -4322851, 3466451, -1325991, -590464, -1766286, -1325991], [-92342936, -4728608, 92531159, 188223, 514401, -376446, -50268, -137955], [-10142698, 1513030, 63794, -1576824, 1150728, 1214522, 191382, 127588], [20707755, 1311200, -20679243, 28512, 486704, -57024, 401168, -429680], [-4880104, 2002048, 10195024, 2678064, 1231432, -555416, 434816, 241200], [23757563, -4465281, -435999, 4901280, -334068, -770067, -1307997, -871998], [42691054, 5810740, 41280796, -10138358, -1446690, 72864, -3002676, -1446690], [66939928, -466502, -33406448, 410130, 99694, -480790, -480790, -226726], [414508, 155038, 23622619, -12659230, -465114, -259470, -50606, -569546], [-19366060, 3867661, -419749, -3447912, -649716, -1069465, -1259247, -839498], [57064887, 11539600, -56779672, 285215, -180751, -570430, -1036396, 751181], [76261494, 4066284, -153252336, 3936840, -558840, 429396, -729348, 599904], [42734330, -2581022, 42327595, 5903387, -574039, 334608, -1649990, -574039], [46599080, -6858886, -23258080, 3448106, -128514, -120246, -120246, 45594], [21667723, 2782098, 23638048, -5351073, 878601, 2183448, -1517970, 878601], [54243565, -2942280, -54763228, -519663, -946281, 1039326, 612708, -93045], [-70678690, 10023204, 18684, -10041888, -865992, -847308, 56052, 37368], [-574200, 961553, -2376960, -60593, -2884659, 1535753, -3458859, -387353], [-172054320, 3552573, 85928946, -1860371, 224687, 364597, 364597, -28259], [91972402, -9723344, -92039158, -66756, -248484, 133512, -48216, 114972], [-746556, -1248685, 47161287, 11620349, 3746055, -502129, 2999499, 1995241], [-39210850, -976728, 19813469, -490920, -2790744, 1542480, 1542480, 2374656], [54586580, -10774577, -108676565, -12385878, -2168654, 557353, 496595, -2107896], [71823646, 7132804, 69262432, -13903370, -1461726, -2198976, 375012, -1461726], [-281448, 5448, -31987940, -4555672, -16344, 286896, -297792, 276000], [48127769, 4572448, -96401234, 3757328, -1295528, 480408, -145696, -669424], [-10218607, -6443504, -12546991, 13854504, -1647940, -1360888, -1254548, -1647940], [2471568, 574746, 121136014, 9514806, -1724238, -1896822, 747330, -3046314], [-107666446, -20092034, -735454, 20827488, 371208, -364246, -2206362, -1470908], [187491902, -6214045, -93931853, 3347091, 1223745, -108333, -108333, -851941], [-200575546, 6234381, -753069, -5481312, 186024, -567045, -2259207, -1506138], [-408168, -1208972, -74464156, 2126868, 3626916, -800804, 3218748, 1617140], [21363583, -572977, -39397555, -1405790, 415586, -1248399, 3329611, -4162424], [-23045932, 3286598, 10552538, -2202586, 2763138, 3059430, 3059430, -822282], [300104230, -11013184, -301208025, -1103795, -1113153, 2207590, 2198232, -1094437], [832676, 1938034, -1403002, -535032, -2370240, -3773242, -4209006, -2806004], [22916666, 9512203, -12005787, -5232813, 1236393, 2048331, 2048331, -141485], [123876509, 13064288, -2536976, -10527312, -1842368, -4379344, -7610928, -5073952], [131912508, 3994330, 128081389, -7389621, -2215079, -3232080, 417962, -2215079], [1947372, 738923, 75888198, 14150101, -2216769, -1208449, -269397, -2686295], [109323147, -8439370, 110286402, 15786357, 1027819, -129128, 2249330, 1027819], [-379422472, 5993803, 94445, -6088248, 1919256, 2013701, 283335, 188890], [-251391666, 1393664, 252063666, 672000, 699104, -1344000, -1316896, 644896], [42113218, 9158656, 38107930, -16567544, -2877528, -2255520, -2371776, -2877528], [-194373969, -4131666, 387571680, -5783852, -3066408, 1414222, -1176258, -475928], [34142563, 12693758, 42723330, -30315107, 6754179, 3653176, 8028594, 6754179], [1128804, -1439679, -281183597, 16760895, 4319037, -2568483, 5447841, 310875], [-272673994, 29318518, 1435994, -30754512, 2387664, 3823658, 4307982, 2871988], [226340739, 17221936, -229170487, -2829748, -7805848, 5659496, 683396, 2146352], [187314710, 32513810, -1500866, -31012944, -2908856, -4409722, -4502598, -3001732], [170644988, -22166888, 178827940, 40415624, 6050552, 4264800, 5703904, 6050552], [264872927, -8492114, -530787512, -9736140, -2386868, 1142842, -1041658, -202368], [322624772, 5226146, -162016354, -5340574, -2639130, 6862938, 6862938, 4047066], [-109453136, 19417304, 53327152, -13030712, -1046456, 9442952, 9442952, 3845288], [-175742936, 6536183, 350480963, 7870410, 1498886, -164659, -1004909, 2339136], [3154416, 1143194, -46179270, -25122434, -3429582, -2011222, -275166, -4297610], [25073112, 8806116, -54642252, 10505304, 300768, 1398420, -4496028, 6195216], [509014042, -3639416, -506481535, 2532507, 7772937, -5065014, 175416, -2707923], [-3092160, -332944, 72316482, 38195552, 998832, 2759216, -2093328, 3425104], [295160630, -40185191, 1049159, 39136032, 1653876, 2703035, 3147477, 2098318], [-157398558, 83679227, 79075525, -39988813, 2196617, -4454093, -4454093, -2949109], [153337736, 34435222, -314633282, 30189876, -10346924, 6101578, -7957810, 3712464], [78458713, -31593475, -155210569, -29036850, 4688366, -2131741, 1706857, 849768], [494126512, 17220628, -246967760, -4515612, 7807420, -8380396, -8380396, -7998412], [157009912, -6731644, 160499346, 12450766, 2250978, 2476912, 786588, 2250978], [-212991554, 20685120, 212840926, -150628, 10002372, 301256, 10454256, -10303628], [-644762222, 10855936, 641813772, -2948450, -5132862, 5896900, 3712488, -764038], [-66036600, -31631676, 136194876, -24523920, 12722472, -5614716, 4121676, 2986080], [-510853423, -37268875, -2118869, 39387744, -1957196, -4076065, -6356607, -4237738], [-91405594, 19660372, -102548864, -38273602, -6095206, -10096128, 2953780, -6095206], [7242100, 4327325, -273437203, -17295885, -12981975, -2914775, -5739875, -11569425], [469142636, -1604960, 303320, 1301640, 6357288, 6660608, 909960, 606640], [-45467409, 38617536, 46547920, 1080511, 12723545, -2161022, 9482012, -10562523], [-238799538, 45791920, -235636598, -89939820, 759460, 4806960, -5691520, 759460], [167027549, -7960802, -336631700, -1473260, 8443012, -1955470, -2576602, 9064144], [88726272, 55098885, -43738116, -25114211, 2370383, -6120503, -6120503, -3620423], [-40398914, -6642560, 37700150, -2698764, -6819780, 5397528, 1276512, 1422252], [-96709180, -18417026, -5923990, 24341016, -7190352, -13114342, -17771970, -11847980], [-770212429, -13857774, 4441086, 9416688, 2061108, 6502194, 13323258, 8882172], [-377311064, 33069322, -393073535, -60519989, -10690563, -10143816, -6165402, -10690563], [-6815616, -878808, 85189558, -47091688, 2636424, 5936808, -4179192, 7694424], [-41701640, -27284294, 19372336, 10109010, -1152338, 10023242, 10023242, 4109306], [8688772, 126202, -38955701, 60296918, -378606, -8562570, 8310166, -8814974], [464815974, -103566125, -230832321, 49989851, -9889087, 435091, 435091, 6737755]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_63_m_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_63_7_m_d();".
// 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_63_7_m_d(:prec:=8)
    chi := MakeCharacter_63_m();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 7));
    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_63_7_m_d();".
// 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_63_7_m_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_63_m();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,7,sign)));
    Vf := Kernel([<2,R![20358144, 1281408, 992080, -12248, 37712, 442, 227, -5, 1]>],Snew);
    return Vf;
end function;