
// Make newform 13.7.d.a in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_13_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_13_d_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_13_7_d_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_13_7_d_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 := [56070144, -242221824, 523196552, -541321656, 275595012, 9502784, 399962, -155430, 36205, 488, 18, -6, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-84271945543930352398314518784, 181983402678115217418930098200, -188190316198958158128876499272, 98035211725237854012633477804, 3408416628369323032624656352, 140832422401403167276894318, -54942822772347566670635754, 12925952551033055488927871, 174860636719079419952536, 6345490399526750340438, -2128261731755613609450, 357114067457877400091], [-395539390258771826127888936576, 1299516318703631221526793457400, -1337326456492378754493918632808, 907491573934919722127792205756, 31218989329148360235860700128, 1120793045650815378413957702, -450359340256545622236943506, 118081786138293446450576419, 1601071496665980448309304, 50993985296434053794382, -17992588404576068826450, 3241403613457336365199], [2904568872219137156875798874112, -9544084396769930498809171568000, 1943965170319355491379614921596, -6672498646502570675933302792572, -224937926601773064178639285136, -5762775984044183221026812924, 2230473399748094133745196847, -847855458750438196463051953, -11528098898159150707367048, -256306667489467113090084, 101527098802980281143875, -22912445860669066253413], [26428359035169628420344790358016, -57157125302550536238255245617600, 59300502400341256538607672406728, -25169942396198623513457361024396, -865648917115961028856086597448, -40805763389300746844112120832, 15527333843268327969982514046, -3322262130728207350541254379, -44447331103509094213158064, -1823874315754389341950512, 585294363815167122063150, -92073754120669108051559], [-1325333929538630898153683679504384, 2880417746017754970252043077313600, -3020283937772783448085994684638872, 272725350192007604776556851298004, 9974969093535582133925928569752, 1493613446546286664243328987968, -498435274698423750267666347754, 42255335220777824890377513821, 520679752698828203132183536, 64140261566921047002107088, -15841998837522733266745050, 1280371007734425507571841], [-519024354207783574933614920192, -10940434783497474177671455075200, 23822003024067271348959931592564, -25079013543394492511478818033248, -863418945334969351238539131624, -23433632862012524401290141516, 10580426150111151354121985873, -3228526341860911283090556402, -44209257227011221123982232, -1114382541663357479277956, 442999245001071970552725, -88005002947366457599642], [-7735872675020737540437472892928, 10945387839612531410160577891200, -23832797348704030556843055121524, 25090398570457238614441836191968, 862566403154558956660818090984, 23466607933025157737019703756, -10584869781771561117273768593, 3229778379044534211147241682, 44201785535279230498722712, 1115691367884769143073796, -443182717922660954688725, 88037053331792348246522], [783763789746483243998432451072, -2574841647580113523311974255072, 3594756045422440548635250133644, -1797190261476222261974023861020, -62372791415195418092622157136, -2513817665804821796544677540, 1020587240325504485325671955, -236264736620067253323865393, -3199736340743872899054344, -115090599091069741302540, 39294880871740546305399, -6528610652683580397349], [-69974418310187098813340655034368, 378237620862801487477085843595200, -497807711938793955881411855894544, 337771952224323265068968287674108, 11673245849259161340248963845304, 396565556869553713880142802136, -167134087416288733042825165608, 43942846036790063072591724667, 598492614910151512229725472, 18300524098582539654248376, -6674359625525494178037600, 1206107845578338721073207], [-1091811988682700188423951481643008, 5060507631507659690918549648507200, -7767270297607681075250087377547664, 5270192220960805727664242174976948, 182211381749628968703296147441224, 6160360793754360550118500469416, -2606835122282705077212062708448, 685623199938251875643472304577, 9338203466932758402662828032, 286035933925434023882990856, -104120432833520459028858600, 18818270548927347405555317]];
    Rf_basisdens := [1, 1, 41513260965910624743365635200, 207566304829553123716828176000, 55351014621214166324487513600, 166053043863642498973462540800, 1660530438636424989734625408000, 92251691035356943874145856000, 92251691035356943874145856000, 6642121754545699958938501632, 830265219318212494867312704000, 1660530438636424989734625408000];
    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_13_d();"
function MakeCharacter_13_d()
    N := 13;
    order := 4;
    char_gens := [2];
    v := [3];
    // 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_13_d_Hecke();"
function MakeCharacter_13_d_Hecke(Kf)
    N := 13;
    order := 4;
    char_gens := [2];
    char_values := [[0, 0, 0, -1, 0, 0, 0, 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 := [[0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, -1, 0, 0, 0, -1, 0, 0, 0, 0], [7, 0, -4, -7, 0, 0, -1, 1, 0, -1, 0, 0], [36, -4, 0, 36, 0, 0, 0, -1, 0, -1, 1, 1], [145, -26, 0, 145, 8, 0, 0, 9, 8, 9, -1, -8], [-336, 61, 33, -110, -8, 3, 8, -10, -12, -37, 2, -1], [297, -297, 297, -1386, -52, 0, -7, 0, 0, 59, 0, -7], [50, 0, -284, -50, 0, 9, -8, -122, 0, 122, 0, 0], [8, -8, 8, 1652, 56, -28, 7, 0, 0, 190, 28, 7], [-7444, 956, 956, -956, 0, 27, -41, -110, 24, 0, 27, 41], [4668, 0, -784, -4668, 72, 5, 156, -8, -72, 8, 0, 0], [-1533, -3292, 0, -1533, -312, 0, 0, -159, -312, -159, -40, 65], [-15910, 0, -74, 15910, -356, -220, -100, -351, 356, 351, 0, 0], [2553, -2553, 2553, 4400, 600, -33, -92, 0, 0, -1447, 33, -92], [43968, 6564, 0, 43968, -496, 0, 0, -831, -496, -831, -239, -69], [42806, -1980, -1980, 1980, 0, 238, -399, -842, 744, 0, 238, 399], [-82546, -492, 0, -82546, -704, 0, 0, 76, -704, 76, -287, -246], [85006, 7284, 7284, -7284, 0, -290, -622, 456, -1096, 0, -290, 622], [-115019, 0, 7578, 115019, 512, 479, -406, -3015, -512, 3015, 0, 0], [-45872, 0, 17388, 45872, -1144, 229, 721, -2019, 1144, 2019, 0, 0], [229338, -22074, 0, 229338, -2524, 0, 0, -6153, -2524, -6153, 182, -922], [-10124, -26970, -26970, 26970, 0, 115, 1371, 9428, -512, 0, 115, -1371], [91459, 0, 32038, -91459, 4208, 335, 1280, 517, -4208, -517, 0, 0], [-74302, -16574, 0, -74302, -4660, 0, 0, 6811, -4660, 6811, -688, -928], [66213, 0, -38064, -66213, -376, 48, -3766, -6474, 376, 6474, 0, 0], [14164, -14164, 14164, -262208, -6672, -380, 1786, 0, 0, -10424, 380, 1786], [7010, -7010, 7010, 227524, -32, -1822, 3229, 0, 0, 16796, 1822, 3229], [-119356, 62134, 62134, -62134, 0, -559, 1394, 19534, -72, 0, -559, -1394], [191287, 0, -29308, -191287, -4856, 2104, -7753, 11889, 4856, -11889, 0, 0], [-472996, -20504, -20504, 20504, 0, -1369, 6102, -7452, 3200, 0, -1369, -6102], [50784, -50784, 50784, 343052, 11464, -484, -7659, 0, 0, -18190, 484, -7659], [302768, 2829, 2829, -2829, 0, 1456, 1226, 4991, 24760, 0, 1456, -1226], [37539, -117276, 0, 37539, -12176, 0, 0, 7442, -12176, 7442, 4324, -5288], [-1329928, -19991, -19991, 19991, 0, 1516, -8034, -10861, 5216, 0, 1516, 8034], [1688618, 0, -129206, -1688618, 340, 1454, 2198, -29715, -340, 29715, 0, 0], [-1427296, 1548, 0, -1427296, 3256, 0, 0, -31741, 3256, -31741, -3975, -13407], [-637044, -34692, -34692, 34692, 0, 3611, 7226, 37184, -13608, 0, 3611, -7226], [-398265, 154970, 0, -398265, 5184, 0, 0, -2907, 5184, -2907, -5281, 14222], [-945130, 28548, 0, -945130, -37088, 0, 0, -20306, -37088, -20306, 1213, -11436], [-151248, 151248, -151248, 1532392, 63248, -6336, -8759, 0, 0, 143814, 6336, -8759], [11571, -11571, 11571, -1438632, -38608, -8679, -6694, 0, 0, -49849, 8679, -6694], [-278246, 278246, -278246, 2026122, -51880, 9535, 12661, 0, 0, -89872, -9535, 12661], [-2399740, 245562, 245562, -245562, 0, 1675, -20775, -146828, 5064, 0, 1675, 20775], [951151, 132788, 0, 951151, 9096, 0, 0, 39036, 9096, 39036, -9692, -7438], [-2017123, 0, 128396, 2017123, 37920, -4554, -33119, 82367, -37920, -82367, 0, 0], [-246920, 246920, -246920, -574084, -27072, -3468, -10901, 0, 0, 32686, 3468, -10901], [-3499736, -406783, -406783, 406783, 0, -17472, 12538, 73259, 35320, 0, -17472, -12538], [-4434192, 0, -906412, 4434192, 26104, -10499, 27477, 100121, -26104, -100121, 0, 0], [4331650, 0, 28924, -4331650, -16992, -4111, 8260, 63546, 16992, -63546, 0, 0], [6052711, -661960, 0, 6052711, -59552, 0, 0, 100501, -59552, 100501, 7666, 47119], [114353, -114353, 114353, 2164992, 83284, -13543, -19, 0, 0, -228629, 13543, -19], [2484522, 0, 247272, -2484522, 48576, -4871, 14755, -306971, -48576, 306971, 0, 0], [-7628102, 1044578, 0, -7628102, 10988, 0, 0, 41103, 10988, 41103, 9296, -27692], [740310, -740310, 740310, -4795500, 38408, 12840, -4426, 0, 0, 30506, -12840, -4426], [-790729, 790729, -790729, -5914120, 167572, -10537, 15795, 0, 0, 173493, 10537, 15795], [-4987288, 4810, 4810, -4810, 0, 48407, 55424, 187846, 57096, 0, 48407, -55424], [-9307612, -347170, -347170, 347170, 0, -21579, 30126, -153034, -225824, 0, -21579, -30126], [3780736, -295308, 0, 3780736, -25000, 0, 0, 134345, -25000, 134345, 42417, -88829], [1203518, -1203518, 1203518, 4078136, 156304, -322, -34950, 0, 0, 98658, 322, -34950], [8340592, 990466, 0, 8340592, -62396, 0, 0, 262919, -62396, 262919, 13154, 35756], [303808, -303808, 303808, -14062468, -145144, 51218, -59486, 0, 0, -129028, -51218, -59486], [319253, 629220, 0, 319253, 41904, 0, 0, -416811, 41904, -416811, 7390, -7955], [8526456, -926656, 0, 8526456, 49768, 0, 0, -519842, 49768, -519842, -5899, 85954], [1295770, -1295770, 1295770, 6083216, 70720, 46294, -91430, 0, 0, 984726, -46294, -91430], [6082156, 578479, 578479, -578479, 0, -202, 80579, 251051, 155476, 0, -202, -80579], [-845926, 0, -1332678, 845926, -302604, -55058, 36626, 762777, 302604, -762777, 0, 0], [10780453, 0, 657346, -10780453, -80248, 55095, 179568, 682495, 80248, -682495, 0, 0], [-1238939, 1238939, -1238939, 23722742, 28804, 5180, 19509, 0, 0, -874673, -5180, 19509], [-16757272, 466581, 466581, -466581, 0, -97184, 42924, 359395, 212112, 0, -97184, -42924], [8960977, 2023536, 0, 8960977, 189328, 0, 0, 27885, 189328, 27885, -35500, -169421], [5186979, 0, 2398340, -5186979, -93648, -15900, -36234, -722844, 93648, 722844, 0, 0], [-12090040, 945352, 0, -12090040, -136416, 0, 0, -946168, -136416, -946168, 7589, 53368], [6076212, -3730544, -3730544, 3730544, 0, -3099, 12739, 1268882, -323712, 0, -3099, -12739], [-27514340, -780604, -780604, 780604, 0, 41427, -69306, 975792, 6512, 0, 41427, 69306], [15018003, 0, -2046578, -15018003, -212888, -26117, -212498, 263159, 212888, -263159, 0, 0], [24763794, 0, 988440, -24763794, 353192, -40439, 3473, -17965, -353192, 17965, 0, 0], [-1362642, 1362642, -1362642, 6382198, -469248, -15159, 97358, 0, 0, -1160486, 15159, 97358], [464888, 1087406, 0, 464888, 217476, 0, 0, 368731, 217476, 368731, 189208, -62718], [1128775, -1691872, 0, 1128775, 93560, 0, 0, 486944, 93560, 486944, -40146, 2236], [-12229241, 0, -89052, 12229241, 332976, -1228, -7124, -1318714, -332976, 1318714, 0, 0], [28061288, 1294471, 1294471, -1294471, 0, -46402, -140358, 222381, -387664, 0, -46402, 140358], [-8292859, 0, -1041228, 8292859, 162160, -30658, 273941, 902195, -162160, -902195, 0, 0], [-16879678, 0, -1836640, 16879678, 84824, 8133, -133621, 317889, -84824, -317889, 0, 0], [1430861, -1430861, 1430861, 4274032, -686764, 40845, 222853, 0, 0, 796567, -40845, 222853], [507164, -507164, 507164, -30832, -690312, 76280, -77242, 0, 0, 1316984, -76280, -77242], [-37278952, -438319, -438319, 438319, 0, -55092, 195394, 449827, 652248, 0, -55092, -195394], [44373019, -3830280, 0, 44373019, -226112, 0, 0, -480222, -226112, -480222, -67466, 112886], [9675024, 0, -3717618, -9675024, 529084, 266526, -50268, 110017, -529084, -110017, 0, 0], [-4898721, 0, -6213424, 4898721, 139072, -125958, 356477, 1305377, -139072, -1305377, 0, 0], [11809010, 3725732, 0, 11809010, -220296, 0, 0, -848050, -220296, -848050, 130673, -150572], [-775342, 775342, -775342, -31680732, 688392, 23240, 182074, 0, 0, -6042, -23240, 182074], [-9779842, -3551080, 0, -9779842, 903504, 0, 0, -839915, 903504, -839915, 140049, -72959], [-27109542, 0, -1998020, 27109542, -484448, -20327, -379796, -70294, 484448, 70294, 0, 0], [4465175, -4465175, 4465175, 12897584, -472760, 29165, 468210, 0, 0, -700269, -29165, 468210], [38377932, 0, -621040, -38377932, 534600, -293803, -557868, -625928, -534600, 625928, 0, 0], [90696344, -947550, -947550, 947550, 0, 120619, 425390, -724318, -241808, 0, 120619, -425390], [-15663722, 0, 8222354, 15663722, -807444, -363786, 335330, 352237, 807444, -352237, 0, 0], [-11323612, -3277965, -3277965, 3277965, 0, -88550, -25147, -1000957, 1760020, 0, -88550, 25147], [-80660748, 4063966, 4063966, -4063966, 0, -76731, -631894, 675166, -506392, 0, -76731, 631894], [-26407735, -3811192, 0, -26407735, -849568, 0, 0, 738135, -849568, 738135, -302468, -385703], [-25682872, -149591, -149591, 149591, 0, 3712, 512334, -3621157, -2015056, 0, 3712, -512334], [-35176879, 2438536, 0, -35176879, -1273576, 0, 0, -1103957, -1273576, -1103957, -62356, 595853], [-5866043, 5866043, -5866043, -1082536, 2591184, -106553, -81420, 0, 0, 4095605, 106553, -81420], [6176279, -6176279, 6176279, -55996376, -435116, -185473, -658139, 0, 0, 2436401, 185473, -658139], [6666717, -6666717, 6666717, -72593040, -345328, 186491, -177744, 0, 0, 2371621, -186491, -177744], [71562032, 0, 1732754, -71562032, -1310636, 459392, -139578, 1363589, 1310636, -1363589, 0, 0], [-67261945, 0, -10430154, 67261945, 730120, 265219, -260306, 841619, -730120, -841619, 0, 0], [-2374839, 7493132, 0, -2374839, 60872, 0, 0, -2648660, 60872, -2648660, 362826, 63858], [-97195936, 1148544, 1148544, -1148544, 0, 67909, -624378, 1850284, 1419384, 0, 67909, 624378], [43081300, 7152091, 7152091, -7152091, 0, 314882, -473747, 1660443, 1772540, 0, 314882, 473747], [106999272, -8913740, -8913740, 8913740, 0, -307467, 532062, 1995528, 481144, 0, -307467, -532062], [55541890, 0, -4484010, -55541890, 1137788, -237072, 249472, -486719, -1137788, 486719, 0, 0], [20517072, 0, -6326706, -20517072, -230492, 142414, -1525494, -4160577, 230492, 4160577, 0, 0], [-65334404, 1546824, 0, -65334404, -287352, 0, 0, 165596, -287352, 165596, -54967, 703868], [38108316, -1242276, 0, 38108316, 1278520, 0, 0, -3481591, 1278520, -3481591, -83743, 75303], [4608214, -4608214, 4608214, -101189942, 723112, -334649, -37522, 0, 0, -3093934, 334649, -37522], [-17525399, 0, 12108474, 17525399, -371256, 256331, 1430110, -2719603, 371256, 2719603, 0, 0], [4411256, -4411256, 4411256, 118910856, -922440, 327464, 1087612, 0, 0, 860472, -327464, 1087612], [97098932, 4868900, 4868900, -4868900, 0, -628221, -51736, -2317716, -3657040, 0, -628221, 51736], [119598188, 7452902, 7452902, -7452902, 0, 327753, -775714, 5062782, 613352, 0, 327753, 775714], [80061056, -7642546, 0, 80061056, -61756, 0, 0, 3145117, -61756, 3145117, -332008, -592768], [-10344689, 10344689, -10344689, -41144338, -628044, -285242, 1094571, 0, 0, 1899917, 285242, 1094571], [-23672146, 2904166, 2904166, -2904166, 0, 137360, 175551, -1807872, 2159432, 0, 137360, -175551], [172927639, 20735106, 0, 172927639, 655344, 0, 0, 3686267, 655344, 3686267, 74251, -1094268], [58858322, 0, 8243980, -58858322, -722336, 401113, -411262, -3825320, 722336, 3825320, 0, 0], [6308752, -6308752, 6308752, -92949498, -998152, -211517, -1363505, 0, 0, 7682474, 211517, -1363505], [-32506204, -29148078, 0, -32506204, -2034924, 0, 0, -562451, -2034924, -562451, -798570, -1335722], [17041204, -17041204, 17041204, 42116748, 2263840, -154964, 988923, 0, 0, -6530846, 154964, 988923], [18698578, -18698578, 18698578, 194789700, 972008, -643162, -365481, 0, 0, -6529344, 643162, -365481], [-139257789, 0, 21419984, 139257789, -552912, -86086, 85119, 1330207, 552912, -1330207, 0, 0], [-161487680, -3041888, 0, -161487680, -1555816, 0, 0, 4024992, -1555816, 4024992, 253665, 43692], [-134521124, 0, 3870164, 134521124, 974184, 191013, 1621067, -4058693, -974184, 4058693, 0, 0], [-19820422, 19820422, -19820422, 269320024, -267336, -41386, 50196, 0, 0, -4007030, 41386, 50196], [55070302, -9924784, -9924784, 9924784, 0, -425862, 1107029, 8655082, 3350424, 0, -425862, -1107029], [124190128, 33906842, 0, 124190128, -1831196, 0, 0, -443519, -1831196, -443519, -7254, -1302454], [92960496, 0, 1398362, -92960496, 1999580, 644168, -558002, 3792917, -1999580, -3792917, 0, 0], [-27266211, 0, 17209960, 27266211, 3255000, 241676, -2196961, 606371, -3255000, -606371, 0, 0], [-93454188, -9665040, 0, -93454188, -2932520, 0, 0, -4311240, -2932520, -4311240, 1129845, 2566780], [-8604492, 8604492, -8604492, -378246874, -4452816, 249759, 1015396, 0, 0, 3409868, -249759, 1015396], [-13795756, -31572321, -31572321, 31572321, 0, 92230, -1439297, -29925, 412580, 0, 92230, 1439297], [250228216, 0, 15234224, -250228216, 3287752, 60001, -1239466, -268182, -3287752, 268182, 0, 0], [99984765, 0, -4910440, -99984765, -1659592, -78996, 1123207, 7189195, 1659592, -7189195, 0, 0], [-36499692, 36499692, -36499692, 176441296, -2237752, -177192, 1515748, 0, 0, -7587852, 177192, 1515748], [90381484, 9207144, 0, 90381484, -4285880, 0, 0, 1239600, -4285880, 1239600, -512987, 1894340], [-29745414, 29745414, -29745414, -178305200, 3604168, -100310, 1173989, 0, 0, 2775288, 100310, 1173989], [83808486, -35811108, 0, 83808486, 1567400, 0, 0, -1527102, 1567400, -1527102, -573479, 1738932], [307025305, -15865264, 0, 307025305, 2503856, 0, 0, 2127237, 2503856, 2127237, -601708, -1085885], [3267596, -3267596, 3267596, -197032976, 3028272, -874540, -1622838, 0, 0, -5838776, 874540, -1622838], [-187425284, 33249286, 33249286, -33249286, 0, 410969, 2057090, -11707162, 60520, 0, 410969, -2057090], [70150678, 0, -2202168, -70150678, -3780720, 127981, -878373, 11356973, 3780720, -11356973, 0, 0], [-186580315, 0, -31904904, 186580315, 1119656, 800460, -1678185, 7937363, -1119656, -7937363, 0, 0], [2975139, -2975139, 2975139, -92638224, 3887988, -1120581, 2185119, 0, 0, 7194465, 1120581, 2185119], [-51781, 51781, -51781, -99216208, -4925400, 592717, -535290, 0, 0, -18974633, -592717, -535290], [-301525432, 12009390, 12009390, -12009390, 0, -304325, -949050, -9868082, -1947048, 0, -304325, 949050], [-16644637, 16644637, -16644637, 25547056, -7736360, -699755, -1693300, 0, 0, 579955, 699755, -1693300], [-466941484, -35651626, -35651626, 35651626, 0, 628587, -3877297, 37596, -2789560, 0, 628587, 3877297], [486558664, 18175028, 18175028, -18175028, 0, -44295, 1019740, 10559084, 7873456, 0, -44295, -1019740], [-20269962, 0, -47352154, 20269962, -835764, 527028, 2052570, -3282045, 835764, 3282045, 0, 0], [173687758, 61217298, 61217298, -61217298, 0, 641776, -284186, 6619834, 5072520, 0, 641776, 284186], [175580797, 0, 59382164, -175580797, -2152952, -1944066, -2249921, -8671011, 2152952, 8671011, 0, 0], [-146498387, 9218878, 0, -146498387, 6071856, 0, 0, 2743189, 6071856, 2743189, -1126633, -2529096], [-13942369, 13942369, -13942369, -68017584, -6888172, -369457, -1258011, 0, 0, -6190159, 369457, -1258011], [175587960, 0, 13771156, -175587960, 4231352, 751701, -1392389, -5948553, -4231352, 5948553, 0, 0], [219770072, -27588165, -27588165, 27588165, 0, 804274, 48796, 9461085, 3693944, 0, 804274, -48796], [420246925, 0, -23988424, -420246925, -255232, 1566216, -2048136, 8070188, 255232, -8070188, 0, 0], [383524318, 15341080, 0, 383524318, -84736, 0, 0, 4940823, -84736, 4940823, -185479, -5299457], [-24915424, 38719142, 38719142, -38719142, 0, -645037, 2317814, -18603106, 4317824, 0, -645037, -2317814], [-978973830, 23138754, 23138754, -23138754, 0, 1205510, -3644747, -24504480, -10869680, 0, 1205510, 3644747]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_13_d_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_13_7_d_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_13_7_d_a(:prec:=12)
    chi := MakeCharacter_13_d();
    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_13_7_d_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_13_7_d_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_13_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,7,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;