
// Make newform 2240.2.k.g in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_2240_k();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_2240_k_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_2240_2_k_g();".
// 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_2240_2_k_g();".
// 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 := [5956, -22336, 37344, -33776, 16080, -488, -5596, 3992, -179, -1516, 1006, -148, -126, 68, -6, -4, 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, 0, 0, 0], [634026321716742, -55212568945784, 7255442894980, 106762977907130, -109539021238893, -13633178133740, 69829732643649, -17931607412769, -20882203036101, 10812644798656, 2461866146935, -2428092530782, -5782883602, 255451555872, -17029973070, -12758377455], [-348289662532115458336, 735676972740082807394, -612154820371672153200, 240534886957138604770, 8812409656846222588, -102679857907601843147, 71827760037341267022, 2468356936003309764, -31541580432531125900, 16874220098891849632, -505933606394946956, -2758329551827048716, 919541822694668216, 27930788945903613, -62502845947521146, 8765614024466674], [1427468805432647561708, -2957390654429469965602, 2402362524933101244484, -836795779768439795796, -205329180934372231738, 546458846557001737209, -263650896553140225122, -74189346620384657089, 149934458133588569104, -52349917243107468542, -10299818010203611792, 12493927886363852188, -1961008466169258786, -725493091669104857, 211916728286895534, 13090040637728505], [-17489786211320, 32148639488212, -20164201672372, 1659909458620, 5953850442270, -6855726785840, 1497184388698, 1916781072920, -1793479248628, 157695428815, 351660968602, -146738265037, -19050599618, 20403779147, -1110096336, -1210752049], [-42814645170, 73775229484, -37472206390, -5856993922, 16165231231, -14234786412, 1699089560, 4919305197, -3862442118, -23564043, 939062890, -312877523, -74255495, 52258753, -1238164, -3343558], [331964725632513472440, -2117068501808309500776, 3212935115563632993032, -2039725726045424389930, 538294739675650401264, 391831367090758893822, -495008163163051562664, 160017238475171890871, 118832891793713150884, -125744891278723942282, 31494971175260942572, 12390972778503174636, -9006400866078907244, 1001904479712438592, 508409725558160580, -120223170196860373], [-908825391783385858004, 2374127347238370132368, -2720002409034269825638, 1676643046921451745682, -366229213299615695132, -329971656220426141850, 394060154218144271303, -114632157105709674301, -96472901443840712450, 103545419009722591998, -27685781977964858108, -9125291680193799000, 7733154061744690654, -1121956011275831728, -402469074925196481, 126425665182626895], [-394988529315488072880, 1393734925792015031754, -1840543284179116451012, 1201588731759913835968, -310073024820485450084, -220270109894291825885, 294773493670649913012, -91976769270153237685, -68228822294103924196, 73841771752378564118, -19147893177766628976, -6695141944048570864, 5336541030249633080, -713483502120422931, -281075459079638160, 82713379168634325], [-1020322781709869753760, 3426054626530645624092, -4556629515839990044858, 3021381137616653188334, -821736504755162748938, -517634899815047395024, 719125568618894204991, -237649344704454034305, -153337931243226373826, 183385760798826199310, -53007947937536874348, -14492654803433050080, 13842456444243259968, -2223510643919990830, -694839951210633181, 237140810440379735], [-1310279850884661310672, 4533424520138778259396, -5424839780231186441632, 3399968126198016637530, -728970739234563805676, -649630715069165603172, 807831922352873380748, -234485299461395158061, -189152648431021147452, 205855473162409076806, -55549252514026466004, -17498219145135478052, 15278820432296986152, -2305263887028898338, -770370709610531096, 259293226844765315], [958797510564913058372, -4307250443939268057452, 6761685223629213815172, -4785700310140283855202, 1485218623630154093798, 632064008668323899948, -1107409032339395042580, 449419601267458200241, 197696087447360859392, -293551487608489295942, 95284425048363017136, 20193867782511255404, -22929190127933666378, 3999070438841951874, 1118370145453479424, -401514885070314967], [1678744867755471500432, -4644440188818386285000, 5296744972024004608390, -3060392513637979096840, 546154222509972678626, 753019705595276023700, -748686664357395711185, 158314411051918264382, 212344977649881363120, -184898054661417274554, 40117807089961648770, 18772666473353955162, -12971112886976321418, 1605940222342174914, 707031214890825801, -203138371139447396], [3239428024377916922436, -10075478303001224763280, 12701471705105446312128, -8097992310736121571546, 1916936457289342249746, 1497237271104639140046, -1921017645189911857042, 586766801271558866667, 438963481118088233728, -492786652970957868114, 136242982429528198460, 41116165628762327132, -36854430938284936774, 5650730542224720896, 1867679735746360758, -622859702467771945], [4139600485325221870320, -11871046424796416720100, 14421858692828249207256, -8817764898518887072334, 1900518047840479370596, 1862585432143242059608, -2136373410007872469824, 561969906032701808571, 543808656389170520872, -538509129785875372338, 132799764376717123880, 50274671850866341900, -38894072028060292708, 5284503975155719586, 2046731257544845448, -625676353274793981], [-3185578392552200053596, 11281234388048318993104, -15062240195278282876764, 9819322295097294277378, -2510620628878174669634, -1659946859124546953910, 2319785730056291618072, -777850522470759953827, -494725854442072439064, 601569813669377153970, -173776796765668563960, -47961230184040499388, 45269222028181278742, -7170009218278348232, -2257663355263442372, 773830196453774649]];
    Rf_basisdens := [1, 216025654874206, 64532047726642313144, 64532047726642313144, 4256018862188, 3918178202, 129064095453284626288, 129064095453284626288, 64532047726642313144, 129064095453284626288, 129064095453284626288, 129064095453284626288, 64532047726642313144, 129064095453284626288, 129064095453284626288, 129064095453284626288];
    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_2240_k();"
function MakeCharacter_2240_k()
    N := 2240;
    order := 2;
    char_gens := [1471, 1541, 897, 1921];
    v := [1, 2, 2, 1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_2240_k_Hecke();"
function MakeCharacter_2240_k_Hecke(Kf)
    N := 2240;
    order := 2;
    char_gens := [1471, 1541, 897, 1921];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 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 := 2;
    raw_aps := [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 1, -1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, -1, 0, 0, 1, 1, 0, 0, 0, -1, 0, -1, 1, 0], [0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 1, 0, 0, 0, 0, 0], [0, 0, -1, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0], [-2, 1, 0, 0, 1, 0, 1, 0, 1, -1, 0, 1, 1, 0, 1, -1], [0, 2, 0, 0, 0, 0, 0, 0, 1, -2, -1, 1, 0, -1, 1, 0], [-2, 1, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 0, 1, 1, 0], [0, 0, -1, -1, -2, 1, 0, -2, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, -1, 2, -1, -2, 0, 0, 0, 0, 1, 2, 0, 1], [2, -2, 0, 0, -1, 0, 1, 0, 0, 1, -2, 1, -1, 0, 1, 1], [0, 0, 0, 0, -1, 0, 2, 0, 2, 0, -2, 2, -1, 1, 2, 1], [0, 0, 0, 0, 0, 0, -1, 0, 2, 0, 2, -1, 0, 1, -1, 0], [0, 0, 1, -1, 1, 1, -1, 2, 0, 0, 0, -3, 1, 2, 3, 1], [0, 0, 0, 0, 1, 0, 0, -2, 0, 0, 0, 1, -1, -1, -1, -1], [0, 0, -2, 2, 5, -4, 1, 0, 0, 0, 0, 1, -1, -2, -1, -1], [0, 0, 0, 0, -2, 2, -1, -2, 0, 0, 0, -1, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0], [-6, 0, 0, 0, 1, 0, 1, 0, 2, 2, 2, 0, 1, 2, 0, -1], [0, 0, -1, -1, 1, -3, 1, 0, 0, 0, 0, -1, -1, -2, 1, -1], [0, 0, -2, 1, 4, -2, 1, 1, 0, 0, 0, -1, 0, -1, 1, 0], [0, 0, 3, 1, 0, -1, -2, 0, 0, 0, 0, -2, 0, 2, 2, 0], [-2, -2, 0, 0, 1, 0, 1, 0, -2, -1, 0, -1, 1, 0, -1, -1], [0, 0, 0, 0, -7, 0, -2, -2, 0, 0, 0, 1, -1, 1, -1, -1], [2, -1, 0, 0, 0, 0, -2, 0, -1, 3, 4, 0, 0, 2, 0, 0], [0, -1, 0, 0, -1, 0, -2, 0, -1, -2, 3, -1, -1, 2, -1, 1], [0, 0, 0, 0, 2, 0, -2, 2, 0, 0, 0, 1, -2, 0, -1, -2], [0, 0, 0, 0, 0, 0, 1, 0, -1, 2, 1, -2, 0, 2, -2, 0], [0, 1, 0, 0, 1, 0, 2, 0, -3, -2, -3, 1, 1, -2, 1, -1], [-4, 0, 0, 0, 2, 0, 1, 0, -2, -2, -2, -1, 2, -3, -1, -2], [-2, 0, 0, 0, -1, 0, 1, 0, 0, 4, -2, 1, -1, 0, 1, 1], [0, 0, 3, 3, 0, 4, -2, -1, 0, 0, 0, 1, 0, 2, -1, 0], [0, 0, 0, 0, -2, -4, 2, 0, 0, 0, 0, -2, 0, -2, 2, 0], [0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 3, -1, -1, -3, -1], [-10, 2, 0, 0, 1, 0, 3, 0, 0, 1, -2, 1, 1, 0, 1, -1], [0, 0, -4, 1, 4, 0, 2, 3, 0, 0, 0, 2, 0, -2, -2, 0], [0, 0, 2, 2, 1, 0, 1, 0, 0, 0, 0, -1, -1, -2, 1, -1], [0, 0, 0, -2, -3, 0, -3, 0, 0, 0, 0, -1, -1, 2, 1, -1], [0, 0, -1, 3, 0, 0, -4, -1, 0, 0, 0, 3, 0, 4, -3, 0], [-4, 1, 0, 0, 1, 0, -2, 0, 1, 2, 5, 1, 1, 2, 1, -1], [-2, 3, 0, 0, 2, 0, 2, 0, -1, -4, 1, -1, 2, 1, -1, -2], [4, 4, 0, 0, 2, 0, 0, 0, 0, 2, 4, -2, 2, 2, -2, -2], [0, 0, -5, -3, 0, 0, 2, 5, 0, 0, 0, 1, 0, -2, -1, 0], [-6, -2, 0, 0, -1, 0, -5, 0, -2, 3, 4, -3, -1, 0, -3, 1], [8, -4, 0, 0, 0, 0, 2, 0, -2, 1, -2, -2, 0, 0, -2, 0], [0, 0, 1, -1, -6, 5, 2, -4, 0, 0, 0, -2, 2, 0, 2, 2], [-6, 0, 0, 0, 0, 0, 0, 0, 0, 6, 2, -2, 0, 2, -2, 0], [0, 0, -1, -1, 0, 0, 0, 5, 0, 0, 0, -1, 0, 0, 1, 0], [0, 0, -3, 3, 6, 3, -2, -4, 0, 0, 0, 2, 0, 2, -2, 0], [-8, -4, 0, 0, 0, 0, -3, 0, -4, 2, 0, -1, 0, -3, -1, 0], [0, 0, -2, 2, -4, 0, 3, -2, 0, 0, 0, 3, 2, -1, -3, 2], [0, 0, -2, -2, 0, -4, 4, 6, 0, 0, 0, -3, 0, -4, 3, 0], [0, 0, 2, 0, -6, -2, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0], [-8, -2, 0, 0, 0, 0, 2, 0, 3, 0, 1, -1, 0, 3, -1, 0], [0, -4, 0, 0, -1, 0, 2, 0, -6, -2, -4, 0, -1, -1, 0, 1], [6, 3, 0, 0, 0, 0, -2, 0, -1, -5, -2, 0, 0, -4, 0, 0], [8, -4, 0, 0, 0, 0, 2, 0, 4, 3, 0, 2, 0, 2, 2, 0], [0, 0, -2, -1, 8, -6, 4, 3, 0, 0, 0, 0, 0, -4, 0, 0], [-4, -4, 0, 0, -2, 0, 2, 0, 0, 5, 0, 0, -2, 4, 0, 2], [8, 2, 0, 0, 0, 0, 2, 0, 1, 2, -1, 3, 0, 1, 3, 0], [0, 0, 0, 5, 2, -4, -3, 3, 0, 0, 0, 3, -2, 1, -3, -2], [4, -2, 0, 0, -1, 0, 0, 0, 0, 8, 4, -2, -1, 5, -2, 1], [0, 0, -4, 0, 1, 0, 1, -4, 0, 0, 0, 1, -1, -2, -1, -1], [-6, -2, 0, 0, 2, 0, 4, 0, 2, -2, 0, 0, 2, 2, 0, -2], [0, 0, 1, -3, -9, 6, -1, 0, 0, 0, 0, -2, 1, 2, 2, 1], [0, 0, 3, -3, -2, -1, 2, 4, 0, 0, 0, -2, -2, -4, 2, -2], [0, 0, 4, -3, 4, 4, 1, -5, 0, 0, 0, -1, 0, -1, 1, 0], [0, 0, 0, 0, 11, 0, 3, 0, 0, 0, 0, 1, 1, -2, -1, 1], [10, 2, 0, 0, -1, 0, -3, 0, -4, 1, 2, -1, -1, 0, -1, 1], [2, -3, 0, 0, -2, 0, 0, 0, -3, 2, -3, 1, -2, -1, 1, 2], [0, 0, 0, 0, -7, -4, -1, -4, 0, 0, 0, 1, -1, 0, -1, -1], [0, 0, 0, 0, 0, 0, -2, 0, 0, -4, -4, -1, 0, -6, -1, 0], [-2, 1, 0, 0, 2, 0, 2, 0, 5, -1, 2, -2, 2, 2, -2, -2], [0, 0, -4, -1, 14, -4, 4, 5, 0, 0, 0, 0, -2, -6, 0, -2], [6, 1, 0, 0, 1, 0, -3, 0, -3, 3, -2, -3, 1, -6, -3, -1], [0, 0, -4, 0, -5, 0, 3, 10, 0, 0, 0, 1, -1, -4, -1, -1], [-24, 0, 0, 0, 0, 0, 1, 0, 2, 0, 2, 1, 0, 3, 1, 0], [2, -5, 0, 0, 0, 0, -2, 0, 3, 1, 2, -2, 0, 0, -2, 0], [0, 0, -1, -1, 0, 4, 2, -5, 0, 0, 0, 1, 0, -2, -1, 0], [0, 0, 2, -2, -4, 4, -1, -6, 0, 0, 0, -1, 2, 3, 1, 2], [-12, 0, 0, 0, 2, 0, 2, 0, 2, 0, -2, 0, 2, -2, 0, -2], [0, 0, 7, -1, 7, 2, -3, 2, 0, 0, 0, -6, 1, 4, 6, 1], [-2, -3, 0, 0, 0, 0, -2, 0, -3, 1, 2, -4, 0, 0, -4, 0], [-8, 3, 0, 0, 1, 0, 0, 0, 3, 4, 5, -1, 1, 4, -1, -1], [0, 0, 4, 4, -1, 0, -5, -6, 0, 0, 0, 1, 1, 6, -1, 1], [0, 0, 1, 1, -8, 4, 1, 0, 0, 0, 0, 4, 0, -1, -4, 0], [-8, 4, 0, 0, 4, 0, -2, 0, -4, -3, 4, -2, 4, -2, -2, -4], [12, 2, 0, 0, -2, 0, -2, 0, 1, 0, -5, 3, -2, -5, 3, 2], [0, 0, -2, -2, -6, -4, 4, 4, 0, 0, 0, 1, -2, -6, -1, -2], [0, 0, 1, -1, 0, 4, -4, -3, 0, 0, 0, -5, 0, 4, 5, 0], [0, 0, 1, -1, 10, 0, 2, -1, 0, 0, 0, -3, -2, -4, 3, -2], [-10, 2, 0, 0, 1, 0, 1, 0, -4, -1, -2, 3, 1, -2, 3, -1], [0, 0, -4, 4, 9, 4, -3, -10, 0, 0, 0, 7, 3, 6, -7, 3], [0, 0, 3, -7, -9, 1, -1, 2, 0, 0, 0, -3, 1, 2, 3, 1], [-10, 0, 0, 0, -1, 0, -1, 0, 0, 2, 4, 0, -1, 4, 0, 1], [2, -1, 0, 0, -3, 0, -5, 0, 3, 1, 0, 3, -3, -2, 3, 3], [0, 0, 1, 5, 9, -6, -1, 4, 0, 0, 0, 2, -1, 0, -2, -1], [-8, 2, 0, 0, 1, 0, 4, 0, 4, -10, -2, 0, 1, 1, 0, -1], [6, 0, 0, 0, -1, 0, 1, 0, 2, -2, 2, -2, -1, 4, -2, 1], [-2, -4, 0, 0, 1, 0, 1, 0, -4, 0, -2, -3, 1, -2, -3, -1], [0, 0, 4, 4, -7, -4, -3, 0, 0, 0, 0, 1, -1, 2, -1, -1], [0, 0, 4, -1, 6, 8, 1, -3, 0, 0, 0, -1, 2, 1, 1, 2], [-10, -8, 0, 0, -1, 0, -1, 0, -4, -2, 0, -2, -1, 0, -2, 1], [0, 0, 0, -7, -4, 0, 5, 7, 0, 0, 0, -1, 0, -5, 1, 0], [0, 0, -1, -1, -4, -4, 2, 5, 0, 0, 0, 5, -4, -6, -5, -4], [0, 0, 2, 2, 3, 2, -1, -6, 0, 0, 0, -3, 3, 4, 3, 3], [-2, -6, 0, 0, -3, 0, -3, 0, 0, 5, 2, -3, -3, 2, -3, 3], [0, 4, 0, 0, 1, 0, -4, 0, 2, -4, 6, 0, 1, 1, 0, -1], [10, -8, 0, 0, 0, 0, 2, 0, -4, 2, -2, -4, 0, 0, -4, 0], [12, -4, 0, 0, -2, 0, -1, 0, -3, -2, -5, -4, -2, -4, -4, 2], [0, 0, -3, 1, -8, -8, -2, -5, 0, 0, 0, 1, 0, 2, -1, 0], [6, -8, 0, 0, -1, 0, -1, 0, 0, 4, 2, -5, -1, 2, -5, 1], [-4, -4, 0, 0, 2, 0, 0, 0, -6, 7, 2, -6, 2, 0, -6, -2], [12, 0, 0, 0, 2, 0, 8, 0, 4, -4, -4, 1, 2, 2, 1, -2], [2, 1, 0, 0, 0, 0, 6, 0, 5, 0, -1, -3, 0, 5, -3, 0], [0, 0, -1, 1, -6, -4, 0, 7, 0, 0, 0, -1, -2, -2, 1, -2], [0, 0, 2, 4, 8, -2, -4, -6, 0, 0, 0, 0, -2, 2, 0, -2], [4, 1, 0, 0, -1, 0, 2, 0, 1, -2, -7, 5, -1, -4, 5, 1], [0, 0, 4, 3, -2, -4, 2, 5, 0, 0, 0, -2, -2, -4, 2, -2], [0, 0, 3, -1, -15, 2, -3, 8, 0, 0, 0, -4, -1, 2, 4, -1], [-4, -4, 0, 0, -2, 0, 3, 0, 0, 10, -4, 1, -2, 1, 1, 2], [-2, -11, 0, 0, -2, 0, 2, 0, 1, 1, -4, 0, -2, 0, 0, 2], [2, -5, 0, 0, 1, 0, -1, 0, -5, 3, 6, -3, 1, 4, -3, -1], [-4, 2, 0, 0, 2, 0, 2, 0, -3, 4, -1, 3, 2, -1, 3, -2], [-12, 0, 0, 0, 2, 0, -4, 0, 0, 4, 4, -3, 2, -2, -3, -2], [0, 0, 8, -3, -2, 4, -2, 11, 0, 0, 0, -6, -2, 0, 6, -2], [0, 0, -3, -5, -2, 4, -2, -13, 0, 0, 0, -3, 2, 4, 3, 2], [0, 0, 0, 0, 0, 0, 2, -6, 0, 0, 0, -3, 0, -2, 3, 0], [0, 0, -3, 5, 8, -4, 4, -1, 0, 0, 0, 3, 0, -4, -3, 0], [12, 6, 0, 0, 1, 0, 2, 0, 0, 6, -2, 6, 1, -1, 6, -1], [0, 0, 1, 1, -3, 3, -3, -4, 0, 0, 0, 3, -1, 2, -3, -1], [0, 0, -6, 4, 8, -6, 4, 6, 0, 0, 0, 0, 0, -4, 0, 0], [0, 0, 6, -1, 12, 6, 0, -9, 0, 0, 0, -4, 4, 4, 4, 4], [-4, 8, 0, 0, 2, 0, 2, 0, 12, -7, 0, 4, 2, 0, 4, -2], [0, 0, -2, 1, -2, -2, 0, 1, 0, 0, 0, 4, 2, 2, -4, 2], [-2, 7, 0, 0, -1, 0, -9, 0, -1, -11, 2, 3, -1, -6, 3, 1], [-12, 4, 0, 0, -2, 0, 1, 0, 4, 6, 0, 3, -2, 3, 3, 2], [-2, 1, 0, 0, -2, 0, 2, 0, 1, -11, -8, 4, -2, -4, 4, 2], [0, 0, -3, 5, 6, 4, -5, -2, 0, 0, 0, 2, 2, 7, -2, 2], [0, 0, 2, -2, 15, -4, 0, -4, 0, 0, 0, -3, 1, 1, 3, 1], [0, 0, -3, 1, -15, 1, 1, 8, 0, 0, 0, -1, 1, 0, 1, 1], [-8, -2, 0, 0, -4, 0, 0, 0, -3, 8, -1, -3, -4, 3, -3, 4], [0, 0, 2, -6, 0, 6, 0, -4, 0, 0, 0, -8, 2, 2, 8, 2], [0, 0, -2, -2, -10, -4, 3, -2, 0, 0, 0, -5, 4, 1, 5, 4], [-4, -4, 0, 0, -2, 0, 1, 0, -8, -2, -4, -3, -2, -1, -3, 2], [0, 0, 7, -1, 8, 4, -7, 6, 0, 0, 0, 0, 0, 7, 0, 0], [14, -3, 0, 0, 0, 0, 4, 0, -7, -4, -5, 3, 0, -1, 3, 0], [0, 0, 8, 2, -7, 12, -5, -8, 0, 0, 0, 1, 1, 6, -1, 1], [0, 0, 3, -9, -17, 2, 1, 12, 0, 0, 0, -4, 1, 0, 4, 1], [16, -4, 0, 0, 0, 0, -4, 0, -6, 4, 6, -3, 0, 2, -3, 0], [0, 0, -7, 5, 9, -2, 5, 8, 0, 0, 0, 6, -1, -6, -6, -1], [0, 0, 2, -2, 1, -12, 3, 4, 0, 0, 0, 3, -5, -8, -3, -5], [0, 0, 3, -1, 16, 4, -6, -3, 0, 0, 0, 5, 0, 6, -5, 0], [0, 0, -2, 2, -9, -2, -7, -6, 0, 0, 0, -1, -1, 6, 1, -1], [0, 0, 2, 1, -6, -6, -3, 9, 0, 0, 0, -5, -2, 1, 5, -2], [0, 0, -5, -9, -4, -1, 4, 6, 0, 0, 0, -4, 0, -4, 4, 0], [0, 0, -3, -3, -17, -6, 3, 2, 0, 0, 0, -4, 1, -2, 4, 1], [-4, -3, 0, 0, -1, 0, 10, 0, 5, 8, -5, 3, -1, 6, 3, 1], [0, 0, 6, -10, 8, 8, 4, 2, 0, 0, 0, -9, 0, -4, 9, 0], [-4, 0, 0, 0, -2, 0, 5, 0, 9, -8, -1, 10, -2, 6, 10, 2], [-8, 13, 0, 0, 3, 0, 4, 0, 9, -8, 3, 1, 3, 4, 1, -3], [-2, 2, 0, 0, 1, 0, -3, 0, 6, -5, 4, 3, 1, 0, 3, -1], [0, 0, -4, -4, -3, 8, -1, -8, 0, 0, 0, 3, -1, 0, -3, -1], [0, 0, -10, -7, 16, -2, 6, -3, 0, 0, 0, -2, 0, -6, 2, 0], [6, -9, 0, 0, -3, 0, 5, 0, -1, 1, -6, 5, -3, 2, 5, 3], [0, 0, -6, 2, -6, -6, 0, 4, 0, 0, 0, 4, 0, 0, -4, 0], [0, 0, -8, 0, 17, -4, 3, 0, 0, 0, 0, 5, -1, -4, -5, -1], [0, 0, -6, 0, 3, -2, 5, -4, 0, 0, 0, -5, 1, -4, 5, 1], [0, 0, 5, -7, -8, 0, 2, -5, 0, 0, 0, -7, 0, -2, 7, 0], [-2, 6, 0, 0, 0, 0, 6, 0, 10, -6, -8, 10, 0, -2, 10, 0], [-8, 2, 0, 0, 0, 0, 8, 0, 7, -2, 1, 5, 0, 9, 5, 0], [0, 0, 8, 4, -4, 8, -8, 4, 0, 0, 0, 0, 0, 8, 0, 0], [0, 0, 1, -5, 4, 12, 4, -3, 0, 0, 0, -1, 4, 0, 1, 4], [10, 3, 0, 0, -1, 0, -3, 0, -5, -3, 0, 1, -1, -2, 1, 1], [-8, 0, 0, 0, 0, 0, 4, 0, 12, 4, 4, 3, 0, 8, 3, 0], [0, 0, 9, -1, -1, 5, -1, -14, 0, 0, 0, -7, 3, 4, 7, 3], [0, 0, 1, -7, -36, 4, 1, 4, 0, 0, 0, -6, 4, 3, 6, 4], [-4, -8, 0, 0, -2, 0, 5, 0, -1, -2, -7, 2, -2, 0, 2, 2], [-22, -1, 0, 0, 0, 0, -6, 0, -9, -4, 1, 3, 0, -5, 3, 0], [0, 0, 2, 10, 20, 4, -1, -2, 0, 0, 0, 7, -2, -1, -7, -2], [0, 0, 1, 1, 4, 0, 5, -4, 0, 0, 0, 2, 4, -1, -2, 4], [0, 0, -1, -5, 2, 11, -4, 6, 0, 0, 0, 0, -2, 2, 0, -2], [8, 0, 0, 0, -1, 0, 2, 0, 10, -8, -2, 6, -1, 1, 6, 1], [20, -4, 0, 0, -2, 0, -8, 0, -10, -1, -2, -4, -2, -8, -4, 2], [-2, 1, 0, 0, -4, 0, 2, 0, 1, -3, -2, 8, -4, 4, 8, 4], [12, -10, 0, 0, -2, 0, -10, 0, -3, 4, 7, -7, -2, -1, -7, 2], [0, 0, -10, 2, -8, -4, 5, 10, 0, 0, 0, -3, 2, -3, 3, 2], [0, 0, -9, -1, 3, -6, 5, -2, 0, 0, 0, -2, 5, 0, 2, 5], [0, 0, 7, 1, 8, 4, -6, -3, 0, 0, 0, 1, 0, 6, -1, 0], [0, 0, -3, -3, 15, -7, 9, 4, 0, 0, 0, -5, 3, -6, 5, 3], [0, 0, -2, 2, -1, 4, -2, -16, 0, 0, 0, 1, 1, 3, -1, 1], [0, 0, -2, 3, -6, -10, 3, -13, 0, 0, 0, 5, -2, -5, -5, -2], [-2, -3, 0, 0, 4, 0, 4, 0, 1, -9, -4, 4, 4, -4, 4, -4], [-2, 3, 0, 0, 2, 0, -6, 0, -1, -4, 9, -1, 2, 1, -1, -2], [0, 0, 0, -1, 16, 4, -1, 5, 0, 0, 0, -7, 4, 5, 7, 4], [-6, 6, 0, 0, -1, 0, -3, 0, 8, 3, 10, 5, -1, 8, 5, 1], [18, -10, 0, 0, 0, 0, 4, 0, -6, -4, -10, -2, 0, -6, -2, 0], [8, -8, 0, 0, 0, 0, 2, 0, -12, 2, 0, -6, 0, 2, -6, 0], [0, 0, -12, 0, -10, -4, 0, -4, 0, 0, 0, 4, 0, 0, -4, 0], [0, 0, 3, 9, 13, 1, -1, 2, 0, 0, 0, 1, -1, 0, -1, -1], [0, -4, 0, 0, 0, 0, -3, 0, -1, 0, 1, -6, 0, -2, -6, 0], [0, 0, -2, 1, -8, 2, 4, 5, 0, 0, 0, -4, 0, -4, 4, 0], [-12, 4, 0, 0, -2, 0, 4, 0, 0, -4, -8, 8, -2, -2, 8, 2], [0, 0, -5, -1, 17, -2, 7, 12, 0, 0, 0, 4, -1, -8, -4, -1], [2, -2, 0, 0, -6, 0, -4, 0, 2, -8, -6, 6, -6, -4, 6, 6], [-12, 8, 0, 0, 2, 0, 7, 0, -3, -10, -5, 6, 2, 0, 6, -2], [-4, -5, 0, 0, 3, 0, -8, 0, -13, 0, 9, -5, 3, -2, -5, -3], [0, 0, 2, 4, 10, -2, 0, -6, 0, 0, 0, 8, -4, -4, -8, -4], [0, 0, 1, 1, 8, -8, -7, 6, 0, 0, 0, -8, 0, 7, 8, 0], [4, -8, 0, 0, -2, 0, 0, 0, 2, 13, 2, 2, -2, 4, 2, 2], [16, -16, 0, 0, 0, 0, 4, 0, -6, -2, -6, -4, 0, -2, -4, 0], [0, 0, 7, 1, 26, 5, 0, 0, 0, 0, 0, -4, 0, 0, 4, 0], [0, 0, -5, -5, -6, -8, 9, -4, 0, 0, 0, 2, -2, -11, -2, -2], [0, 0, 1, 7, 21, -9, 3, -2, 0, 0, 0, -3, 3, 0, 3, 3], [0, 0, -3, -3, -26, 0, -1, 2, 0, 0, 0, -2, 2, 3, 2, 2], [4, 10, 0, 0, 5, 0, -2, 0, 0, -2, 6, -2, 5, -1, -2, -5], [10, -8, 0, 0, -1, 0, 11, 0, 4, 8, -6, 7, -1, 6, 7, 1], [8, -4, 0, 0, 0, 0, -8, 0, 2, 2, 2, 0, 0, -6, 0, 0], [2, -1, 0, 0, 3, 0, -1, 0, 7, -3, 2, -5, 3, -2, -5, -3], [0, 0, 2, 2, 18, -4, 8, 14, 0, 0, 0, 3, -2, -10, -3, -2], [-4, -12, 0, 0, -2, 0, 2, 0, 0, 17, 0, -2, -2, 4, -2, 2], [-2, 12, 0, 0, 3, 0, 1, 0, 4, 4, 2, 5, 3, 0, 5, -3], [0, 0, -2, -1, -12, 10, 1, -1, 0, 0, 0, 3, 0, -1, -3, 0], [0, 0, 1, 1, 0, 0, -6, -3, 0, 0, 0, -3, 0, 6, 3, 0], [-14, 2, 0, 0, -1, 0, -5, 0, -10, -15, -4, -1, -1, -8, -1, 1], [0, 0, -4, 4, -3, 4, 1, -12, 0, 0, 0, -7, 3, 2, 7, 3], [-2, -7, 0, 0, -2, 0, 2, 0, 5, 6, 5, -1, -2, 9, -1, 2], [-4, 0, 0, 0, 2, 0, -11, 0, -4, 8, 16, -5, 2, 3, -5, -2], [0, 0, 6, -6, -7, -12, 5, 8, 0, 0, 0, -3, -5, -10, 3, -5], [-14, -7, 0, 0, -2, 0, 2, 0, 1, -5, 4, -2, -2, 8, -2, 2], [20, 0, 0, 0, 2, 0, 6, 0, -4, 3, 4, -4, 2, 8, -4, -2], [-10, -10, 0, 0, -3, 0, 9, 0, 4, 1, -2, 1, -3, 10, 1, 3], [0, 0, -9, 3, -4, -3, 6, -10, 0, 0, 0, 2, 2, -4, -2, 2], [4, -12, 0, 0, -1, 0, 4, 0, -6, 10, 4, -2, -1, 9, -2, 1], [0, 0, 5, 7, -6, 0, -2, -1, 0, 0, 0, 1, 6, 8, -1, 6], [-4, 6, 0, 0, -2, 0, 0, 0, -1, -12, -3, 5, -2, -1, 5, 2], [0, 0, 0, -4, -7, 4, 0, 8, 0, 0, 0, 7, -1, -1, -7, -1], [-20, -4, 0, 0, 2, 0, 5, 0, 2, -10, 2, -3, 2, 5, -3, -2], [-10, 2, 0, 0, 5, 0, 1, 0, -2, -5, -4, 9, 5, -8, 9, -5], [-18, 0, 0, 0, -2, 0, 4, 0, 12, 0, 4, 4, -2, 10, 4, 2], [0, 0, 8, 5, 4, 4, 5, -5, 0, 0, 0, -1, 0, -5, 1, 0], [12, 6, 0, 0, 2, 0, -2, 0, 3, -6, 5, -9, 2, 1, -9, -2], [28, -12, 0, 0, -2, 0, 6, 0, -10, -8, -14, -1, -2, -6, -1, 2], [-4, 12, 0, 0, 2, 0, -7, 0, 0, 8, 4, 1, 2, -5, 1, -2], [0, 0, 9, -1, 2, 8, -2, 7, 0, 0, 0, 5, -2, 0, -5, -2], [0, 0, -9, 7, 8, -8, 5, 10, 0, 0, 0, 4, 0, -5, -4, 0], [2, 11, 0, 0, 8, 0, 6, 0, 3, -4, -3, 3, 8, -5, 3, -8], [0, 0, -10, 0, -6, -2, 6, 10, 0, 0, 0, -2, 2, -4, 2, 2], [0, 0, -6, 10, 0, -4, -4, -10, 0, 0, 0, 9, 0, 4, -9, 0], [0, 0, -8, -10, -5, -12, 5, 8, 0, 0, 0, -1, -1, -6, 1, -1], [0, 0, -4, 0, -22, 16, 2, -16, 0, 0, 0, 2, 4, 2, -2, 4], [0, 0, 1, -1, 22, 4, -2, -9, 0, 0, 0, -3, 2, 4, 3, 2], [-18, 10, 0, 0, 2, 0, 8, 0, 2, -8, -6, 2, 2, 0, 2, -2], [-10, 0, 0, 0, -1, 0, 7, 0, 2, 14, 2, 8, -1, 10, 8, 1], [0, 0, 2, -3, 8, -2, -6, -3, 0, 0, 0, -2, 0, 6, 2, 0], [0, 0, 4, -9, -14, 8, -5, -11, 0, 0, 0, -3, -2, 3, 3, -2], [0, 0, 9, 1, 14, 4, 1, 2, 0, 0, 0, 0, 2, 1, 0, 2], [0, 0, 2, -2, 23, -4, 2, -8, 0, 0, 0, 1, 1, -1, -1, 1], [0, 0, 12, 2, 21, 4, -1, 12, 0, 0, 0, 1, -5, -4, -1, -5], [0, 0, 2, 11, 12, 6, -6, 3, 0, 0, 0, 2, 4, 10, -2, 4], [0, 0, 2, -6, 14, -8, 3, -6, 0, 0, 0, 3, 0, -3, -3, 0], [-16, -4, 0, 0, 4, 0, 1, 0, 3, -6, -3, 4, 4, -6, 4, -4], [6, -3, 0, 0, -1, 0, -5, 0, -3, -1, -4, -1, -1, -8, -1, 1], [0, 0, 0, 6, 8, 4, 2, -6, 0, 0, 0, 6, -4, -6, -6, -4], [0, 0, -6, 2, -11, -4, 6, 2, 0, 0, 0, -9, 3, -3, 9, 3], [18, 3, 0, 0, -2, 0, 4, 0, 3, -16, -11, 1, -2, -5, 1, 2], [0, 0, -3, 11, 22, 5, -2, -12, 0, 0, 0, 10, 2, 4, -10, 2], [0, 0, -1, -1, -5, 6, -11, 14, 0, 0, 0, 2, -3, 8, -2, -3], [0, 0, -2, 3, -22, -6, -1, -5, 0, 0, 0, 1, -2, -1, -1, -2], [0, 0, -2, 10, 35, -4, 1, 4, 0, 0, 0, 3, 1, 0, -3, 1], [0, 0, 6, 6, -20, 8, -5, -14, 0, 0, 0, 3, 2, 7, -3, 2], [-6, 6, 0, 0, -1, 0, -3, 0, 6, -9, -8, 7, -1, -10, 7, 1], [0, 0, -8, -4, -37, -4, 2, 0, 0, 0, 0, 3, -3, -5, -3, -3], [-6, -10, 0, 0, 2, 0, -10, 0, -14, -4, 10, -8, 2, -2, -8, -2], [22, -3, 0, 0, 0, 0, 0, 0, -7, -1, -8, 0, 0, -8, 0, 0], [12, -4, 0, 0, -6, 0, 1, 0, 0, 4, -12, -3, -6, -5, -3, 6], [-2, -14, 0, 0, 1, 0, -5, 0, -8, -1, 2, -7, 1, -4, -7, -1], [0, 0, -7, -7, 8, 0, 2, 11, 0, 0, 0, -3, 0, -2, 3, 0], [4, 4, 0, 0, -6, 0, 0, 0, 6, 8, -6, 3, -6, 0, 3, 6], [0, 0, 0, -8, -7, 4, 5, -2, 0, 0, 0, -1, -1, -6, 1, -1], [-12, -4, 0, 0, -6, 0, 8, 0, 2, 9, -2, 0, -6, 12, 0, 6], [0, 0, 1, -3, -16, 4, 4, 3, 0, 0, 0, 7, 0, -4, -7, 0], [16, -15, 0, 0, -3, 0, -14, 0, -11, 12, 7, -9, -3, -4, -9, 3], [26, -3, 0, 0, -4, 0, -6, 0, -11, -4, 3, -11, -4, 1, -11, 4], [-12, -4, 0, 0, -6, 0, -8, 0, 4, 6, 0, -6, -6, -2, -6, 6], [0, 0, -4, 8, 13, 4, -7, -2, 0, 0, 0, 11, -3, 4, -11, -3], [2, 7, 0, 0, 0, 0, 6, 0, 3, 1, 6, -2, 0, 12, -2, 0], [12, 8, 0, 0, -2, 0, 2, 0, -8, -3, -8, 2, -2, -4, 2, 2], [-8, -1, 0, 0, -5, 0, 6, 0, 3, 8, -3, -3, -5, 8, -3, 5], [-8, 4, 0, 0, 4, 0, 1, 0, -1, 0, 1, 12, 4, -2, 12, -4], [30, -9, 0, 0, -6, 0, -6, 0, -9, -4, -7, -5, -6, -7, -5, 6], [0, 0, -5, -5, -17, 3, 1, 8, 0, 0, 0, 3, -1, -2, -3, -1], [-24, 12, 0, 0, 4, 0, 0, 0, 10, -8, 14, 0, 4, 10, 0, -4], [0, 0, -2, 7, -6, -6, 4, -9, 0, 0, 0, 8, -2, -6, -8, -2], [4, 4, 0, 0, 2, 0, 1, 0, 10, 10, 2, -1, 2, 1, -1, -2], [8, 16, 0, 0, 0, 0, -2, 0, 8, 5, -4, 4, 0, -6, 4, 0], [0, 0, 2, -1, 38, 10, 1, -5, 0, 0, 0, 3, 6, 5, -3, 6], [0, -2, 0, 0, -1, 0, -2, 0, -8, 6, -2, -2, -1, -3, -2, 1], [0, 0, -9, -5, 28, -8, 14, 9, 0, 0, 0, -7, 4, -10, 7, 4]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2240_k_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2240_2_k_g();".
// 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_2240_2_k_g(:prec:=16)
    chi := MakeCharacter_2240_k();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(1999) - 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_2240_2_k_g();".
// 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_2240_2_k_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2240_k();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-8, 56, -50, -64, 69, 8, -16, 0, 1]>,<19,R![2048, 3072, -1152, -1792, 384, 256, -60, -4, 1]>],Snew);
    return Vf;
end function;