
// Make newform 297.2.f.a in Magma, downloaded from the LMFDB on 29 May 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_297_f();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_297_f_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_297_2_f_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_297_2_f_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 := [25, 150, 340, -235, 1346, -862, 1150, -609, 552, -161, 152, -24, 62, -22, 8, -2, 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], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [14014700213480197003925, 156571784740572339145310, -811223755533334733368545, 745863591562403613709802, -881501735398477709911869, 610302119431283897343050, -468572841680220993325453, 151715826622193586121139, -122307832148397688583602, 35606336123119748551774, -49088161817925152763278, 22496083946013603242154, -8245415302460234956844, 2316000153175047926031, -927265913791077287464, 94196927105818835782], [1009827731231617689198230, 58424759986371555913530, 374402912250734680542665, 925636992161755950416363, -266910922245850059587996, 702462453259408985077495, -257045400471641159590462, 383249443416029863932771, -6727530633186450393938, 64498337211023997849261, -35429557494056860182537, 30127984334719920185311, -8990748055934298005531, 4038433827576099860764, -985921295623181881546, 294670043105047804508], [-380438069135383444545430, 21729289811249381491655, 145977953156548874541090, 371959030104415551722113, -128357418770703793288076, 241587190137913227793375, -152193070526216399835982, 204639084572100327892371, -50662922792692678220328, 60608812702348112663401, 9745945135211206017718, 23367298950697544934621, -8540182287151271836271, 3193856990714908901509, -713677493666063097081, 510866317497242536483], [-72483583459691157121760, 1001823678436665412621925, -877601773569117465546697, 1636053194892251516603191, -1093528982792081090038384, 1113249051500310055506003, -493113923822571185136752, 431752412862040438430266, -125861005497932217257051, 134297539115884750547142, -35950196150954592365922, 43001871831891123526578, -14648936341037621289485, 5411969982104740328720, -1215372944184234596096, 560588008539207880157], [111812051763537470056675, 363142634249895139670490, 285523275594689143233655, 641558762035305925792471, -118846295954958324946867, 540608789407061984804580, -180653256328551972543904, 320025945957391311119822, -52650182741363349316451, 83729903295281550067872, 6682530998584660458966, 32566435770661276411637, -11310343092173292081912, 4450282928281371245893, -982778987779056988117, 646785790951930730766], [-854766428813265800622840, -36523472931997241933430, -289213418482787565751140, -809476966572808416685778, 357372331356696631106641, -680270245983519192766800, 355387940713874755412302, -417878374933274170384961, 87662733440767130483338, -112091142304245611000276, 4835591794200714990842, -45572688932128542931971, 16074465555509700732126, -6112801299484092896449, 1437680893000137697316, -821658911622047009898], [-255887350795066541677640, -1200451481418179831396790, -2201905380598198599840869, -216053275899106737602895, -1630976079317251002875219, 17434515123161020818236, -737550057085283659563896, -207499586488984450665237, -267266750730732973778570, -206046188936066158176085, -149794282640343060038651, -6236081972261269545298, 1620459007277911001914, -3675184182072006405176, -1260265056029902035403, -1151686047356862276088], [63587436214335162644505, 1442498006603879246449450, 751063467026653613928536, -1316021247429403734565558, 1669086010397851964034657, -1666975923827459590653414, 1275986269479640622947536, -853998351872149996565143, 409331029756593799666903, -146622147169005739750261, 77047275012929430617791, -111058338020221301193819, 40465718539843130119575, -13150446047773140044395, 4456243852570126999828, -1547265545861820285446], [230222408316504534777355, -2548403018550026412847895, 2784770578845165477552656, -5174191122445155420424168, 3596253981623116172499157, -3651756501412849439678279, 1825250846451629244572331, -1454181755415725620172963, 454942139180174204017398, -434479171672017621794861, 124893456010096529979781, -151012352250818397473044, 52253221757244356195780, -18934786644102284952515, 4539192381815735178643, -1989819166946045616356], [120793138012371623299050, 1171680698684643687487340, -2306764237811238439444921, 4263928095361869899231238, -3400344993623304668094627, 3480101220558310005933489, -2094917700353600242436761, 1511388322653647623429893, -554960539404014300914988, 386711574299385579603706, -134332748448728681427956, 172511842616955129043849, -61204492371747896843015, 21258032322354949652510, -5910426517334680172993, 2329288740889844034981], [-427296490539878778608105, -1065263608141442174671710, 263429584370437170426992, -3510932262434197330170202, 2089072323382610374302491, -2957155468393275644723468, 1441963750386135024400416, -1441824375888663503168208, 374699982746380773574922, -420720708540222328429054, 41523453165883158604011, -159094260680682212305195, 56289332449484069342237, -20916573211860838082463, 4896696358884482758403, -2703781338190862647443], [227571575811263049594175, 2186789612628715035829370, -3489461184408530267161942, 7781992599161336184752674, -5919188251848131626277385, 6349900321685336114523928, -3721262559026979491548069, 2871060818685101660738647, -987613246659630913246374, 737816812475651410655638, -219577335079532210092634, 322527601287896654845544, -114163569441035558729186, 40200064491534851378989, -10893587120878283058522, 4564380554673869234180], [711484703427345284583760, 1637839445221986495092805, -1009410943303155817170079, 6294767759406415163166418, -3984905768965156703113455, 5324090565903752669308266, -2750402536355699884801573, 2524579699937936520257134, -711389593226068613573173, 733638270827063119257846, -100065438613960366044653, 283006776759893672384903, -100453143343831932402072, 36827601595865332310688, -8865265942258517279504, 4640752561303581397520], [-1729538095115075930866100, -4087509588040714317241315, 2008040049909166562685740, -14963362071501355382510106, 8987221019684176650756622, -12778754967187045056502020, 6613310264782147350039474, -6235098094590059767834147, 1737080115133728629454201, -1736858663506320678872987, 228743747538602325846599, -695705968704346785308757, 246706857856296286906287, -90435417806821728218298, 22180677608181578675647, -11495672854356971948276]];
    Rf_basisdens := [1, 1, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355, 312843535680611878359355];
    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_297_f();"
function MakeCharacter_297_f()
    N := 297;
    order := 5;
    char_gens := [56, 244];
    v := [5, 2];
    // 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_297_f_Hecke();"
function MakeCharacter_297_f_Hecke(Kf)
    N := 297;
    order := 5;
    char_gens := [56, 244];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 1, -1, 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, -1, 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], [1, 1, 0, 1, 0, 1, -1, 1, -1, 0, 0, 0, 1, 0, 0, 0], [-1, -1, 1, -1, 0, -1, 1, -1, 1, 0, -1, 0, -1, 0, 0, -1], [-1, -1, 1, 0, 1, -1, 1, -1, 0, 1, -1, 1, 0, 0, -1, 0], [0, -1, 1, 0, 0, 0, -1, 0, 1, 0, 0, 0, 0, 0, 0, -1], [1, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, -1, 0, 0, 0, 0], [-1, -1, 0, 0, 0, -1, 0, -1, 1, 1, 0, 0, 0, -1, -1, 0], [-1, 1, 0, 0, -3, 3, -1, 1, 0, -1, 1, -1, 1, -1, 1, -1], [-4, -3, 1, -2, 2, -5, 2, -3, 1, -1, -2, 4, -6, 0, 0, -1], [0, 2, -2, 0, 0, -1, -3, 0, -2, 0, -1, 0, 2, -1, -1, 0], [0, -3, 2, -2, 2, -1, 3, 0, 1, -1, 1, 2, -4, 0, 0, -1], [0, 2, 0, 1, 0, 2, 0, 1, -1, -1, 1, -3, -1, -1, 1, 1], [3, 2, 0, 0, -1, 4, -2, 3, 0, 1, 2, 1, 3, 1, 2, 1], [1, -1, 2, 0, 0, -1, 0, -2, 1, 1, 0, 1, 3, -1, -2, 0], [0, 2, -2, 0, 0, 1, -2, 0, -2, 0, 0, -1, 2, 0, 0, -1], [-1, -1, 3, 0, 0, -2, 2, 2, 1, 1, 1, 0, 0, 2, 2, -1], [1, 2, -3, 2, -3, 5, -2, 2, -2, 0, 4, -2, 2, 0, 0, 0], [-1, 1, 0, 2, 0, 1, -1, 3, 0, 2, 3, 2, 0, 2, 3, 2], [2, 1, -1, 0, -1, 6, 0, 2, 0, -1, 1, -1, 0, 2, 0, 0], [-4, 4, 1, -1, -4, 1, 2, 1, 0, -1, 2, 2, -3, 0, 0, 0], [0, 1, -1, 0, 0, 1, -4, 0, 0, 0, 2, 1, 2, 2, 1, 2], [4, -3, 4, -1, 4, 3, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0], [-7, -2, 0, -2, 0, -4, 2, 0, 0, 1, -1, 1, -2, 1, -1, 1], [0, 1, -1, 0, 0, 0, 0, 0, 1, 0, -1, -1, -1, -1, -4, -1], [0, -1, 1, 0, 0, -3, 3, 0, 3, 0, -1, 2, 0, -1, -1, -3], [3, -1, 2, 1, 1, 1, 1, 2, 0, 1, 1, -2, 3, 3, 3, 0], [0, 0, -2, 1, -2, 0, -2, 1, 1, 1, 1, -8, 1, -1, 1, 1], [-6, -2, 0, -4, 3, -8, 2, -8, 0, -2, -3, -2, -7, -2, -3, -2], [5, 0, -2, 0, 3, 0, 3, -1, 0, 0, 0, -4, 3, 1, -1, 0], [-3, -5, -1, -2, -1, -4, 2, -4, 2, 0, -4, -2, -2, -2, 0, 0], [-2, -5, 0, -4, 4, -6, 5, -6, 0, -2, 0, -2, -8, -2, 0, -2], [-2, -2, -4, 1, -4, 0, -1, -3, -1, -1, -1, -5, 1, -4, 0, 0], [4, -2, 1, 0, 0, 2, -1, -2, 2, 2, -4, 1, -1, -1, -1, -2], [-4, -2, -1, -3, -1, 0, 3, -4, 3, 2, -5, -1, -3, -1, 0, 0], [4, 2, -1, 3, -3, 2, -3, 5, 1, 1, 3, 4, 2, 6, 5, 3], [6, 2, 6, 4, 3, 2, 3, 2, 2, 2, 4, 0, 1, 3, 2, 4], [0, -5, 5, 0, 0, 2, -1, 0, 0, 0, -5, -7, 3, -5, -2, -3], [0, 4, -4, 0, 0, -2, -1, 0, 0, 0, 4, 6, 0, 4, -3, 3], [-3, 3, 3, 2, -1, 3, -1, 0, -1, -1, 2, -5, -2, -2, 0, 2], [0, 5, -4, -1, 0, 5, 0, -5, -6, -6, -1, -8, 5, -5, -5, -1], [8, 2, -2, 2, -2, 7, -2, 1, -2, -3, 4, -9, 2, -1, 0, 0], [-3, 7, -5, 2, -6, 2, -6, 1, -1, 1, 0, -6, 8, -1, -1, 1], [4, 6, -5, 2, -5, 3, -2, 2, -2, -1, 1, -7, 2, 0, 0, 0], [15, 4, 0, 1, 0, 5, -4, 7, 0, 3, 5, 3, 3, 3, 5, 3], [8, -5, 0, 2, 6, -2, 5, 0, 0, 5, 0, 5, 3, 5, 0, 5], [0, 3, -3, 0, 0, 0, -6, 0, -3, 0, -4, -4, 3, -4, 3, 1], [-3, 8, -1, 2, -3, 8, -3, -1, -6, -6, 2, -2, 1, -4, -1, 2], [7, -7, 5, 3, 6, -3, 1, 5, 1, 4, 1, 8, -5, 3, 3, -1], [0, -5, 5, 0, 0, -11, 7, 0, 0, 0, 4, 15, -10, 4, 2, 0], [0, 1, -1, 0, 0, 0, -3, 0, -1, 0, -1, -1, 10, -1, -3, -4], [-2, -7, 7, -5, 5, -7, 5, -1, 2, 2, -5, 0, -6, 1, -1, -5], [0, -2, 0, 2, 0, 4, 2, 4, 0, 1, 3, 1, 2, 1, 3, 1], [0, 4, -4, 0, 0, 6, 0, 0, -1, 0, 2, -4, 4, 2, 3, 5], [4, 6, -1, 3, -2, 7, 0, 0, -4, -1, 1, 0, 3, 0, 0, 4], [4, 4, 0, -2, -4, 3, -4, -3, 0, -4, -1, -4, 0, -4, -1, -4], [-2, 1, 1, -1, 1, 9, 1, -2, 1, -3, 4, 1, -1, -1, 0, 0], [-6, 5, -7, 1, -2, -2, -5, 2, -3, -2, 4, -8, 9, 0, 0, 3], [0, 2, -2, 0, 0, 5, 0, 0, -2, 0, -1, -6, -1, -1, -4, 0], [-11, -1, 3, 0, 3, -3, 0, -5, 0, -1, -4, 9, 0, -5, 0, 0], [-1, 3, 0, 4, -4, 3, -4, 7, 1, 1, 4, 7, -4, 1, 7, 4], [-5, 6, -2, 7, -2, -6, -5, 3, -4, 3, 0, 9, -2, 3, 3, 4], [7, 10, 0, 5, -3, 7, -10, 5, 0, 0, 6, 0, 1, 0, 6, 0], [-3, 1, 1, 2, 3, 1, 3, 3, 1, 1, 2, 11, -9, -2, 3, 2], [5, 5, -4, 5, -4, 2, -5, 5, -5, -5, 2, -4, 5, 0, 0, 0], [0, -1, 1, 0, 0, -1, 4, 0, -2, 0, -1, 0, -3, -1, -6, -3], [6, -5, 0, 3, 4, -4, 5, 5, 0, 3, 7, 3, -8, 3, 7, 3], [5, -3, 3, 5, 8, -3, 3, 0, -5, 0, 0, 16, -11, 1, 1, 5], [-2, 10, -7, 4, -7, 18, -4, 3, -4, -1, 8, -2, 4, -1, 0, 0], [1, -8, 8, -4, 5, -8, 5, -4, 4, 4, -4, 8, 0, 1, -4, -4], [2, -2, 0, -2, 8, -9, 2, 1, 0, 4, -1, 4, -4, 4, -1, 4], [1, 4, -2, -1, 1, 6, 4, -8, -5, -6, -2, -2, 1, -1, -1, 5], [5, 11, -9, 3, -9, 13, -10, -1, -2, 1, -2, -12, 15, -3, -3, 2], [2, -1, 0, -2, -4, 6, 1, 1, 0, -5, -3, -5, 4, -5, -3, -5], [-3, -12, 8, -4, 8, -21, 4, -7, 4, 4, -12, 4, -4, -3, 0, 0], [0, -2, 2, 0, 0, 12, -3, 0, 2, 0, -1, -13, 7, -1, -3, -7], [10, 2, -7, -1, -2, 13, -6, -4, 0, -1, -3, -13, 12, -5, -5, 0], [7, -5, 0, -4, 12, -2, 5, -7, 0, -6, -9, -6, 1, -6, -9, -6], [13, 12, -6, 3, -6, 12, -3, 3, -3, -3, 1, -16, 3, 0, 0, 0], [0, 3, -3, 0, 0, 0, -4, 0, 3, 0, 4, 4, -12, 4, 4, 2], [8, 11, 0, 9, -3, -3, -11, 15, 0, 6, 8, 6, -5, 6, 8, 6], [0, -2, 3, 3, -4, -2, -4, 5, 5, 5, 3, 7, -1, 1, 5, 3], [0, -8, 8, 0, 0, -19, 0, 0, 3, 0, -5, 14, -5, -5, -4, 0], [-6, -10, 5, -8, 1, -8, 4, -4, 9, 1, -5, -2, -6, 0, 0, -9], [-2, -8, 0, -1, 12, -2, 8, -10, 0, -3, -6, -3, 1, -3, -6, -3], [-10, -6, 2, -4, -6, -6, -6, 2, 2, 2, -4, 10, -6, 5, 2, -4], [0, 5, -5, 0, 0, 5, -10, 0, -2, 0, 3, -2, 15, 3, -4, -1], [-2, -1, 3, 1, 3, -14, -1, -3, -1, -2, -2, 2, 1, -4, 0, 0], [5, -13, 0, -4, 10, -9, 13, -6, 0, 1, -5, 1, -3, 1, -5, 1], [-19, -1, 0, -1, -2, -6, 1, -2, 0, 0, 1, 0, -7, 0, 1, 0], [-2, -1, 3, -3, 3, -6, 3, -8, 3, -1, -10, -3, -3, -5, 0, 0], [-6, 3, 1, -3, 1, 0, 3, 3, 3, 5, 6, 10, -3, 6, 0, 0], [-5, -3, 2, -2, 0, -3, 0, 0, 1, 1, -2, 10, -5, 11, 0, -2], [10, -6, 4, -6, 2, 10, 6, 0, 4, -2, 2, -12, 6, -5, -5, -4], [-1, -7, 8, 4, 6, -12, 3, 2, 1, 5, -3, 9, -5, -3, -3, -1], [16, 0, 0, 0, -1, 0, -1, 3, 0, 0, 0, -2, 14, 8, 3, 0], [-5, 0, -3, 3, -5, 0, -5, 4, 3, 3, 3, -7, -4, -1, 4, 3], [10, -1, 1, 0, 4, 9, 4, -4, -3, -3, -1, 2, -2, -5, -5, 3], [3, 6, -2, -2, -2, 13, 2, -4, 2, -2, 5, -9, -2, -2, 0, 0], [0, 10, -10, 0, 0, 6, -3, 0, -6, 0, 4, -2, 10, 4, 0, 0], [-5, 2, 6, 2, -2, 2, -2, 4, 0, 0, 2, 17, -7, -2, 4, 2], [-22, -13, 14, -8, 3, -27, 12, -7, 10, 2, -9, 15, -23, -7, -7, -10], [0, 4, -4, 0, 0, -12, 0, 0, 4, 0, -2, 10, -9, -2, 1, 0], [-10, -3, -6, 1, -2, -3, -2, 4, 4, 4, 1, 8, -12, 9, 4, 1], [-4, -1, 0, -5, 2, -3, 1, 4, 0, -2, -3, -2, -2, -2, -3, -2], [2, -3, 1, 5, 1, 1, -5, 0, -5, 4, 0, -1, 5, -5, 0, 0], [-4, -4, -3, -10, -2, 2, 1, -10, 6, -4, -6, -21, 11, -3, -3, -6], [14, 2, 0, 6, 7, 5, -2, 2, 0, 3, 5, 3, 3, 3, 5, 3], [2, -3, 2, 1, 2, 4, -1, -1, -1, 3, 5, -1, 1, -2, 0, 0], [15, 10, -1, 11, -4, 14, -6, 19, -6, 5, 14, 0, 11, 14, 14, 6], [0, -5, 5, 0, 0, 4, 7, 0, -1, 0, 9, 5, -8, 9, 3, 1], [-2, 12, -10, 7, -3, 12, -3, 3, -5, -5, 7, -5, -2, -1, 3, 7], [-14, -9, 0, -9, 4, -13, 9, -18, 0, -10, -12, -10, -11, -10, -12, -10], [-16, -6, 6, -5, 8, -6, 8, -2, 1, 1, -5, 10, -22, -5, -2, -5], [0, 7, -9, 1, -1, 6, -4, 4, -6, -5, 9, 6, -5, 2, 2, 6], [-3, 6, -9, 5, -11, 6, -11, 7, -1, -1, 5, 2, 1, -2, 7, 5], [6, 10, 5, 7, 5, 8, -7, 11, -7, 6, 5, 10, 7, 4, 0, 0], [0, -5, 5, 0, 0, 6, 2, 0, 3, 0, -7, -13, 2, -7, 3, -4], [19, 1, -6, 4, 0, 16, -9, 1, -1, 3, -2, -11, 15, 4, 4, 1], [9, -1, 0, 5, -5, 9, 1, 13, 0, 3, 4, 3, 8, 3, 4, 3], [0, 6, 0, -1, -4, 8, -6, 12, 0, 3, 5, 3, 6, 3, 5, 3], [0, -1, 1, 0, 0, 0, -3, 0, 0, 0, 3, 3, -4, 3, 9, 8], [-10, 14, -5, 2, -5, 22, -2, 7, -2, -3, 8, 12, 2, 5, 0, 0], [6, -2, 0, 3, 0, -9, 2, -4, 0, 1, -2, 1, -6, 1, -2, 1], [0, 3, -3, 0, 0, 6, -5, 0, -2, 0, -2, -8, 7, -2, -2, -4], [-7, -12, 1, -6, 12, -12, 12, -7, 6, 6, -6, -1, -12, -5, -7, -6], [-8, 6, 5, -4, 5, -14, 4, -3, 4, 0, -4, 10, -4, 1, 0, 0], [11, -13, 8, 2, 17, -4, 10, -7, -4, -2, -5, -12, 14, -5, -5, 4], [-8, -7, 0, -5, 6, -22, 7, -10, 0, -4, -9, -4, -17, -4, -9, -4], [19, 6, 0, 2, -5, 23, -1, 6, -1, 1, 5, 3, -1, 7, 7, 1], [0, -4, 4, 0, 0, -9, 0, 0, -3, 0, 0, 9, -7, 0, -6, 2], [-2, -21, 14, -7, 14, -20, 7, 0, 7, 9, 0, 16, -7, 7, 0, 0], [8, 5, -11, -4, -1, 5, -1, -9, -9, -9, -4, -33, 18, -6, -9, -4], [0, 11, -11, 0, 0, 10, -1, 0, -1, 0, -3, -13, -1, -3, -1, 8], [0, -8, 8, 0, 0, 2, 12, 0, -4, 0, 3, 1, 0, 3, -6, 1], [-2, -1, 0, 7, 2, 3, 1, -3, 0, 2, 6, 2, -1, 2, 6, 2], [-17, 11, -9, 2, -1, 11, -1, -4, -9, -9, 2, 1, -12, -3, -4, 2], [9, -12, 13, -5, 13, -5, 5, -7, 5, -2, -1, -3, -5, -2, 0, 0], [-10, -16, 5, -2, 5, -23, 2, -12, 2, -4, -6, 3, -2, -10, 0, 0], [-18, -1, 1, 0, 1, -12, 0, 4, 0, 4, 4, 23, 0, 4, 0, 0], [15, -9, 11, -6, 6, -9, 6, 0, 3, 3, -6, 4, 9, -5, 0, -6], [-22, 8, -10, -10, -10, -4, -2, -4, 2, -8, 4, -6, -4, -5, -5, -2], [0, 8, -8, 0, 0, 7, -4, 0, 5, 0, 9, 2, -1, 9, -4, 2], [0, 0, 0, 0, 0, -17, -4, 0, -2, 0, -6, 11, -12, -6, 2, -3], [4, -11, 9, -2, 6, -5, 6, -5, 5, 3, -8, 7, -9, 5, 5, -5], [-12, 4, -8, -4, -5, 4, -5, -4, -8, -8, -4, -11, -3, -11, -4, -4], [4, -5, -1, 4, -1, -18, -4, 3, -4, 5, -2, -2, 4, -1, 0, 0], [8, -7, 0, -4, -4, 5, 7, 5, 0, 1, 10, 1, -4, 1, 10, 1], [-12, 11, 0, 6, -13, 10, -11, -3, 0, -5, -4, -5, 9, -5, -4, -5], [8, 7, 6, 9, 6, 13, -9, 0, -9, -6, -4, -2, 9, -9, 0, 0], [-4, -6, 9, 4, -2, -6, -2, 5, 10, 10, 4, 2, -7, 10, 5, 4], [5, 0, 0, 1, -1, 6, 0, -4, 0, 0, 7, 0, -1, 0, 7, 0], [2, 1, 1, 1, 8, 1, 8, -1, 0, 0, 1, 0, -5, -5, -1, 1], [-4, -13, 13, -15, 8, -2, 23, -13, 5, -10, -3, 0, -15, -2, -2, -5], [11, 0, -2, -3, -2, 14, 3, -10, 3, -9, 3, -23, -3, -7, 0, 0], [0, -17, 17, 0, 0, 1, 8, 0, 6, 0, 7, 6, -9, 7, 12, 6], [4, 7, -9, 3, -9, 6, -3, -1, -3, -11, 5, -14, 3, -4, 0, 0], [6, -10, 5, 1, 5, -25, -1, 1, -1, 10, -7, 0, 1, 0, 0, 0], [0, -9, 9, 0, 0, -9, 18, 0, 10, 0, -3, 6, -5, -3, 2, 3], [-18, -12, 5, 1, 5, -13, -1, -6, -1, 2, -8, 17, 1, -7, 0, 0], [-2, -1, 0, -10, -2, -6, 1, -1, 0, -4, -5, -4, -5, -4, -5, -4], [-13, 0, 2, -7, -3, -6, 6, -3, 3, -4, 1, 4, -11, -5, -5, -3], [7, 8, 0, 1, -17, 1, -8, 1, 0, 2, -3, 2, 6, 2, -3, 2], [-1, 1, 11, 0, 0, 1, 0, 6, -1, -1, 0, 22, -7, -2, 6, 0], [0, 10, -10, 0, 0, 4, 17, 0, -1, 0, 6, 2, 5, 6, -2, 7], [17, 6, -3, 16, -3, 7, -16, 27, -3, 13, 14, 1, 15, 13, 13, 3], [-4, -6, 0, -6, -1, 4, 6, -8, 0, 0, -6, 0, 10, 0, -6, 0], [13, -4, 2, 4, 5, 5, -1, -4, -1, 3, -7, -22, 26, -6, -6, 1]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_297_f_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_297_2_f_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_297_2_f_a(:prec:=16)
    chi := MakeCharacter_297_f();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    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_297_2_f_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_297_2_f_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_297_f();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![16, -24, 168, -624, 1345, 776, 758, 137, 524, -22, 202, 16, 56, 16, 8, 2, 1]>],Snew);
    return Vf;
end function;