
// Make newform 495.2.n.g in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_495_n();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_495_n_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_495_2_n_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_495_2_n_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 := [1, 4, 17, 70, 383, -430, 471, -172, 360, 26, 171, 32, 47, -8, 5, -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], [4684863033388304, -568591142787875238, 93570035844837543, -90506767183986926, -231641863194072003, -319729317918190560, -446597103764880540, -331573544358140394, -264117958519829524, -145336767693588186, -61146526572552240, -8519106391972926, -2005995543669531, 143020561508636, -784278699533661, -274909709246406], [-301927752492954565, -3822684831751662, 27555273511115606, 140885354640541754, -394772810552973845, 55312393060713098, -245911872417401744, 104166886954478224, -46186287420472496, 69986082534625206, 10614112411878989, 25734959323311664, -4724034435676990, 2678375186769114, -1294038871869219, 553668747953762], [413981182405604135, 1967072679306622413, -337614021434331534, 596242561123071756, 508765947296826397, 1350563990196551169, 1425871732223573700, 1386230620986522104, 967946523561484984, 616925067838708542, 228500108198224671, 53528410268329273, 2360640185706480, 2324766414796124, 1851897765207855, 1439074005313563], [274909709246406, 5784501870373928, -563917677730686336, 112813715492085963, 14783651457386572, -349853038170026583, -190246844863133334, -493881573755262372, -232606049029434234, -256970306079422968, -98327207412452760, -52349415876667248, 4401649942608156, -4205273217640779, 1517569107740666, -1334098118026473], [-55763223898352207, 1483100099170413112, 7194317225999645966, -6598860258546821788, 6219461329136756829, -1446990931651661606, 5482691994217503452, 1992929875410893800, 3191521592275583908, 1391133956348731186, 1030149467982352343, 80585581972894742, 53906232696629134, -13364241040070848, 8565337944679831, 4950341416425938], [-376917382847082123, -1796302457038402649, 484965482191497092, -4507955070755752244, 3295679700257036373, -5007977547533482581, 791986271093937708, -3509882114878012604, -519517240851217752, -1538010628569371690, -261321357649369131, -373412049536210877, 64673902756106082, -40719039631172776, 14417915972893703, -7689574809486539], [-244926581437456, 90224891838242869, -5185130631661255590, 1857024347168333810, -1186243882333216876, -1355347926840362115, -1751713015381200100, -2679309963838852172, -1641929205864583504, -1533967646866839956, -692989384122531926, -292468610266020577, 14633853633104868, -19707199958346938, 7113165089580568, -7996357615436185], [-624001392880083455, 31677413386224412, -864449632553452018, -4192774164604126624, 3784296383430534165, -5361647578042256546, 1194357667186697532, -4005504188033716152, -488100125702895684, -1794502293098529654, -327483559332676297, -470124075549151302, 79967884092907126, -51095562919719476, 19483671586929623, -9923394814730370], [-22324765494603340, -104622610840257705, -437058555324799526, -2129436406478004480, 2277211903121095982, -2634535670125058247, 892265473943206304, -2005341392896135220, -156009803880583268, -938989218743731712, -176315398520139426, -258034906429298419, 43719731554509720, -27534589269448528, 11007843731223050, -5497038814695493], [18253448300139254, -1801341363730993457, -8606178666465003832, 3137595733462195724, -3257452744531745816, -3133211800080577119, -4703855168870146888, -5546470109830386496, -3779964285440740540, -3074760077481916412, -1409219186344899196, -507211526823956967, 12727897036830450, -30137086783330880, 8144045718544856, -14237456455843353], [-383695910164439023, -1454572150144297626, -8008865683061113730, 2651503125175466950, -2781796675359935187, -3686314678933949826, -4443385422641245576, -5787816772121294744, -3672993166187436608, -3089476577515634734, -1349027752041544833, -524154385298967080, 20685781237821498, -34539788766771066, 9723085162322699, -14347599686866674], [-11257512017065858, 241366565868854323, 3253089239364610664, 5195494791680033913, -6140010126413766874, 7619595794373178122, -2125661015087147782, 6447269279178828544, 942372174626117730, 3185365486979204256, 752962612570292994, 837482018154361001, -129058061625899722, 84524592027254251, -33938549156435524, 18531899779261006], [15323548861844345, 57537541916542746, 566702821855770680, -10827597087554175202, 12234184832804494447, -11407230021901379444, 5845201057967909700, -7880905774176619132, 358545315884044872, -3641219501057031714, -456357589398008461, -1092983709800866700, 206132713226275248, -122631671204239750, 50146569803902173, -22324765494603340], [-49589969014520525, -356067839358896986, 7009973887022542852, 34255519869345816022, -40367508360363927983, 41897475129387418778, -17289921029964539848, 31927969909310058828, 1556631325320829296, 15289009782018226266, 2790485160591147685, 4303795152282388204, -740928671285460332, 459651261004779450, -186572448315471337, 91442776575316422]];
    Rf_basisdens := [1, 1, 124366022234909444, 248732044469818888, 248732044469818888, 124366022234909444, 248732044469818888, 248732044469818888, 248732044469818888, 248732044469818888, 124366022234909444, 248732044469818888, 248732044469818888, 124366022234909444, 124366022234909444, 248732044469818888];
    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_495_n();"
function MakeCharacter_495_n()
    N := 495;
    order := 5;
    char_gens := [56, 397, 46];
    v := [5, 5, 4];
    // 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_495_n_Hecke();"
function MakeCharacter_495_n_Hecke(Kf)
    N := 495;
    order := 5;
    char_gens := [56, 397, 46];
    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], [0, 0, -1, 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 := [[1, -1, 0, 1, 0, 1, 0, 0, 0, 0, -1, 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, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0], [0, 0, -1, 1, 0, 1, 0, -1, 0, 1, 0, 1, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1, -1, 0, -1, 0, -1, 1, 1], [-1, 0, 0, 0, 2, 0, -1, -2, 0, 1, 0, 1, -1, 0, -1, 1], [2, 0, 0, 2, 0, 1, 0, -1, -2, 0, -2, 0, 1, -1, 0, 0], [1, -2, -1, 0, -1, 2, 0, 0, -1, 0, -1, 2, 0, 0, -1, -1], [2, -1, -2, 0, 0, 0, -1, 2, 0, -2, -1, 0, -1, 2, -2, 0], [1, 0, -2, 0, -2, 0, 2, 0, 1, -2, 0, 0, 1, 0, 0, 0], [1, -1, 3, 1, -1, 1, 3, -2, 0, -1, -1, -1, 1, -2, 0, -1], [1, 3, 0, -2, 0, -2, 1, 0, -2, -1, 0, -1, 0, 0, 0, 0], [-1, 2, 3, 0, -1, -2, 2, 0, 1, 0, 2, 2, 2, -2, 3, -1], [3, -2, 2, 4, 0, 0, 1, -2, -3, 3, -2, 0, 1, -2, -1, -2], [-1, 0, 3, 0, -2, 0, 3, 0, 0, 0, 0, -2, 3, -3, 4, -2], [-1, 3, -2, -3, 0, -1, 0, 1, 0, -2, 1, -2, 2, 2, 2, -2], [-5, 4, -2, -2, 1, -2, -2, 0, 1, 2, 0, 1, -2, 0, 0, 0], [3, 0, -7, 2, -1, 1, 1, 2, 0, -1, -2, -1, -1, 2, -7, 0], [-4, 2, 0, -2, 0, 0, -1, 0, 2, 1, 2, 0, -1, 0, 2, -3], [-1, 0, -3, -2, -1, 2, 1, -1, -2, -1, 2, 1, 2, -3, -3, -2], [0, 2, -3, 1, 2, 1, -1, 1, 1, 0, 0, -2, -1, 0, 0, 0], [-3, 6, 1, -6, -2, -4, 4, 4, 0, -2, 4, -2, 2, -2, 4, -2], [5, 0, -3, 1, -4, 1, 4, 2, -6, -4, -1, -2, 2, 4, -3, -2], [9, -2, 1, 2, 0, 0, 1, -1, -4, -2, -2, 0, 1, -1, -3, -1], [-2, -1, 1, 1, 4, -2, -2, 3, 0, 1, 2, 1, -1, 1, -1, 1], [-2, -2, 9, 2, -2, 0, 5, -2, 0, -1, 0, -1, 1, -4, 1, -1], [-1, 1, -3, -4, -1, -4, 0, 2, -1, -2, 0, -1, -3, 0, 0, 0], [-5, 2, 11, 0, 0, -2, 3, 0, 9, 0, 2, 0, 2, -2, 7, 0], [6, -5, -4, 6, 0, 0, -3, 4, -2, -3, -5, 0, -3, 4, -6, 1], [-3, -3, -4, 0, 4, 3, -6, 0, 0, 0, -5, 0, -4, 4, -1, 4], [0, 0, -2, 2, 2, -1, -2, 0, -6, 2, -2, 2, -2, -3, -2, 0], [10, 2, 2, 4, 0, 0, 0, -2, 0, 1, 2, 0, 0, -2, 2, 5], [-7, 0, 0, -3, 4, -4, -4, 2, 4, 4, 3, -2, -6, 1, 0, 6], [-9, 2, -4, -1, 3, -1, -6, -2, 0, 8, 0, 5, -8, 0, 0, 0], [3, 0, 2, -2, -5, 6, 5, 1, -4, -5, 2, -2, 4, -2, 2, -3], [7, -4, 0, 0, 2, 4, 0, 0, 0, 0, -2, -2, 0, 0, -7, 2], [2, 1, -9, 0, -3, -1, -3, 0, -6, 0, -1, 4, -3, 3, -5, -3], [4, -1, -4, 1, -3, -2, -1, 1, 0, 2, 2, 2, -2, -1, 3, 2], [-2, 2, -2, -2, -2, -2, -2, 2, 0, 2, 2, 2, -2, 0, -4, 2], [3, 0, 1, 0, 0, 0, -4, 0, 5, 0, -5, 0, -4, 4, -7, 0], [-4, 2, -1, 0, -4, -2, 0, 0, -1, 0, 0, -3, 0, 0, 4, -4], [1, 0, 4, -4, -5, -1, 5, 2, 10, -5, 4, -3, 3, 0, 4, -2], [-3, -6, 0, -2, -2, -2, -4, 2, -1, 2, 0, 4, -3, 0, 0, 0], [9, 0, 3, 2, -7, 5, 7, 2, 3, -7, -2, -3, 5, 3, 3, -4], [3, 1, 3, -4, 0, 0, 4, -3, -6, 2, 1, 0, 4, -3, -3, -2], [8, 2, 6, 5, 0, 0, 5, -6, -4, -1, 2, 0, 5, -6, 2, 2], [2, -4, 3, 4, -2, 7, 1, -4, 0, 1, -7, 1, -1, -2, 3, 1], [5, -3, 9, 0, -1, 3, 3, 0, 6, 0, 1, 3, 3, -3, -2, -1], [-9, -4, -1, 4, 6, 4, -7, 1, 7, 6, 0, 0, -2, 0, 0, 0], [-7, 4, -2, -4, 4, -1, -5, -6, 0, 1, 1, 1, -1, 4, -1, 1], [-8, 8, 5, -8, -10, -7, 5, 4, 0, -4, 7, -4, 4, -1, 5, -4], [-9, 0, 17, 0, -5, 0, 4, 0, 17, 0, 6, 0, 0, 0, 9, -5], [-3, -2, 2, 0, 0, 0, 4, -2, -8, 2, -2, 0, 4, -2, -6, -2], [6, 2, 2, -2, -7, 0, 10, 0, 0, -5, 0, -5, 5, -5, 10, -5], [-4, 4, 5, 2, 4, 2, 0, -2, 4, 2, 0, -2, 5, 0, 0, 0], [5, 7, 1, -2, 0, 0, 6, -1, 2, -4, 7, 0, 6, -1, 3, -2], [2, 0, -9, 0, -2, -10, 2, 6, -6, -2, 0, -1, -4, 1, -9, -1], [-9, 5, 1, -1, -4, -1, 1, 0, 9, -1, 0, 3, 1, 0, 0, 0], [-5, 3, -1, -3, 4, 0, -3, -3, 0, -2, 0, -2, 2, 5, 0, -2], [-1, 0, 1, 0, 1, 0, -1, -3, -8, 1, 0, -1, 2, 2, 1, 2], [-9, -1, 9, 0, -3, 1, 0, 0, 6, 0, -4, 4, 3, -3, 12, -3], [-9, -11, 1, 6, 0, 6, -7, 1, 9, 6, 0, 6, -9, 0, 0, 0], [4, -1, 5, -3, 0, 0, -3, -5, -4, 7, -1, 0, -3, -5, 1, 7], [0, -2, -6, 0, 0, 2, -1, 0, -3, 0, 0, 0, -3, 3, -3, 0], [-12, 0, -2, -3, 9, 0, -9, -3, 1, 9, 3, 2, -6, 7, -2, 7], [-6, 0, 2, 0, 6, 2, -4, 6, 0, 0, -2, 0, 0, 4, 2, 0], [8, -3, 0, 8, 0, 0, 1, 0, 5, 3, -3, 0, 1, 0, 5, 3], [9, 7, -5, -6, -5, -6, 4, 4, -7, -8, 0, -3, 9, 0, 0, 0], [-5, 0, 2, 1, 6, 3, -6, -1, -8, 6, -1, 0, -5, 2, 2, 6], [-2, 6, -7, 0, -1, -6, 2, 0, -7, 0, 5, 2, 0, 0, 2, -1], [0, 5, 6, 1, 0, 0, 1, -6, 4, 4, 5, 0, 1, -6, 10, 0], [-1, 8, -9, -12, -5, -12, 5, 6, 0, -11, 0, -6, 1, 0, 0, 0], [2, 0, 5, 7, -2, 7, -2, 1, 4, 1, 0, 3, 2, 0, 0, 0], [4, -5, -5, 3, 0, 0, -2, 5, 8, -6, -5, 0, -2, 5, 3, 0], [3, 0, 0, 5, 2, 5, -2, -4, 6, 2, -5, -1, 2, -4, 0, 3], [-13, 7, 16, -7, 0, -5, 10, -5, 0, -2, 5, -2, 2, -8, 20, -2], [-1, 8, -5, 4, 2, 4, 3, -7, 1, 4, 0, 2, -5, 0, 0, 0], [7, -3, -9, 9, 0, 0, -7, 9, 5, -5, -3, 0, -7, 9, -4, 2], [-5, 0, -4, -2, 3, 8, -3, 2, 7, 3, 2, 3, -5, 9, -4, 0], [-6, 0, 0, 0, 2, -2, -6, 4, 0, 4, 2, 4, -4, 2, 2, 4], [0, 0, -4, -8, 0, 0, 3, 4, 0, -9, 0, 0, 3, 4, -4, -4], [-4, -5, -3, 0, 7, 5, -8, 0, 1, 0, -5, -3, -4, 4, 0, 7], [8, -10, 0, 10, -5, 10, -2, -1, 0, -2, -10, -2, 2, 4, -13, -2], [-11, -9, 5, 5, 4, 5, -5, 3, 14, 2, 0, -2, 2, 0, 0, 0], [-1, -3, -2, -7, 0, 0, 2, 2, -6, -2, -3, 0, 2, 2, -8, -5], [15, -3, -10, 0, -4, 3, 3, 0, -13, 0, -2, 10, 3, -3, -12, -4], [11, -16, 7, 16, -10, 10, 2, 2, 0, -3, -10, -3, 3, 1, 0, -3], [-13, 0, -13, 1, 14, 2, -14, -1, 3, 14, -1, 4, -13, 7, -13, 10], [7, 0, -5, -6, 0, 0, 3, 5, -5, -7, 0, 0, 3, 5, -10, -9], [-15, -1, 5, 9, 0, 0, -4, -5, -3, 10, -1, 0, -4, -5, 2, 3], [-10, 0, -8, 0, 10, 1, -10, -6, -3, 10, 0, 8, -4, 4, -8, 2], [1, 0, 3, 2, 1, 8, -1, -8, -3, 1, -2, 4, 7, -2, 3, -3], [-2, -3, -16, 0, 4, 3, -10, 0, -13, 0, -14, 1, -3, 3, -1, 4], [14, 2, -18, -2, -10, -2, 2, 11, -3, -13, 0, -3, 5, 0, 0, 0], [2, -13, 6, 4, -3, 4, -3, 6, 5, -3, 0, 0, 3, 0, 0, 0], [1, 6, 5, 0, 2, -6, 4, 0, 2, 0, -3, 0, 3, -3, 2, 2], [-8, 8, -9, 0, -5, -8, 3, 0, -11, 0, 10, -2, 2, -2, 10, -5], [9, 2, -2, -8, 2, -8, 6, 1, -10, -7, 0, -9, 6, 0, 0, 0], [12, 0, 12, 3, -9, 7, 9, 1, -2, -9, -3, -5, 8, -2, 12, -4], [1, 1, -4, -1, -3, 0, -2, 2, 0, -2, 0, -2, 2, 4, 5, -2], [-1, 7, 5, 0, -5, -7, 11, 0, 0, 0, 9, -5, 5, -5, 6, -5], [-21, 2, 10, 0, 2, 0, 3, -9, 15, 6, 0, 4, 3, 0, 0, 0], [9, -1, -2, 1, 2, -3, 6, -5, 0, -2, 3, -2, 2, -4, -16, -2], [2, -6, -11, 0, -2, 6, -10, 0, -7, 0, -2, 15, -4, 4, -6, -2], [7, 0, -4, 1, 0, 0, 1, 4, -12, -5, 0, 0, 1, 4, -16, 2], [0, 0, 8, 8, 8, 9, -8, -4, 11, 8, -8, -1, -4, 1, 8, 9], [-1, 2, -12, -8, 0, -8, -11, 11, -7, 0, 0, 0, -7, 0, 0, 0], [-18, 1, 7, -2, 0, 0, -7, -7, 13, 8, 1, 0, -7, -7, 20, 6], [16, 0, 2, 12, -4, 6, 4, -3, -7, -4, -12, -5, 7, -1, 2, 1], [-21, 7, 16, 1, 8, 1, -3, -10, 9, 13, 0, 5, -1, 0, 0, 0], [19, -7, -12, 7, -9, 2, 0, 5, 0, -1, -2, -1, 1, 1, -10, -1], [-8, -2, 4, 0, -4, 2, -5, 0, 14, 0, -5, -3, -10, 10, -2, -4], [9, -7, -2, 4, 0, 0, 0, 2, -1, 8, -7, 0, 0, 2, -3, -2], [3, -10, -3, 0, -4, 10, 2, 0, -1, 0, -4, 8, -2, 2, -5, -4], [1, -5, -1, 7, 2, 7, -9, -8, -11, 17, 0, 15, -5, 0, 0, 0], [12, -2, -30, 0, 7, 2, -7, 0, -22, 0, -14, 7, -8, 8, -20, 7], [-3, 0, -15, -1, 2, 13, -2, -3, -2, 2, 1, 1, 1, -2, -15, 1], [8, -7, 2, 7, -10, 7, 3, -2, 0, -2, -7, -2, 2, -1, 1, -2], [16, 0, -5, 1, -14, 1, 2, 10, -3, -12, 0, 2, 1, 0, 0, 0], [10, -8, 4, 6, 0, 0, 0, -4, 5, 1, -8, 0, 0, -4, 9, -2], [15, 2, 10, 14, 0, 0, 10, -10, 2, -4, 2, 0, 10, -10, 12, -2], [-1, 4, 3, -4, 1, -10, 6, 0, 0, 0, 10, 0, 0, -6, 7, 0], [5, 0, -17, 7, 2, -5, -2, 3, -3, 2, -7, -2, -5, 5, -17, 4], [-2, 1, 3, 6, 0, 0, 5, -3, -15, 4, 1, 0, 5, -3, -12, -8], [-9, -7, 4, 7, 9, 4, -12, -10, 0, 8, -4, 8, -8, 4, 1, 8], [21, -6, -8, 0, 1, 6, 10, 0, -6, 0, -4, -3, -2, 2, -23, 1], [2, 0, -5, 0, -2, 6, 2, -4, -7, -2, 0, 8, 6, 4, -5, -10], [6, 10, -30, -6, -1, -6, -4, 10, -6, -6, 0, -5, -3, 0, 0, 0], [12, -8, 8, 6, 0, 0, 8, -8, 2, -2, -8, 0, 8, -8, 10, -4], [32, 0, -22, 3, -9, 3, 14, -1, -16, -13, 0, -4, 6, 0, 0, 0], [-6, -2, 7, 2, 0, 5, -1, -6, 0, 1, -5, 1, -1, 0, 14, 1], [-6, 0, -1, 2, 8, -5, -8, 1, -5, 8, -2, 4, -9, 8, -1, 4], [0, 7, -13, 0, -2, -7, 6, 0, -19, 0, -6, -7, 6, -6, 6, -2], [-2, -6, 18, 6, -12, -2, 10, -6, 0, -4, 2, -4, 4, -6, 4, -4], [9, -6, -3, 6, 7, -2, 0, 1, 0, -1, 2, -1, 1, 1, -11, -1], [-7, 0, 10, 8, 0, 0, 2, -10, 0, 14, 0, 0, 2, -10, 10, 8], [8, -6, -4, 0, 4, 6, -5, 0, -5, 0, 3, 0, 1, -1, -7, 4], [3, 0, -7, -4, -7, 8, 7, 2, 6, -7, 4, -2, 5, -6, -7, -5], [0, 0, 25, -2, -2, -7, 2, -5, -11, -2, 2, 2, 7, -8, 25, -4], [-15, 0, -1, -8, 7, -4, -7, 4, 17, 7, 8, 10, -11, 4, -1, -3], [23, 5, -16, 0, 8, -5, -6, 0, -16, 0, 4, 7, 0, 0, -23, 8], [2, -6, 3, 6, -1, 6, 5, -6, 3, 1, 0, 2, 8, 0, 0, 0], [9, 4, -24, -4, 10, 5, -11, 4, 0, 0, -5, 0, 0, 11, -9, 0], [4, -1, -6, 1, 4, 5, -3, -10, 0, 2, -5, 2, -2, 1, -17, 2], [14, -5, -9, 0, -13, 0, 9, 6, 1, -15, 0, -2, -7, 0, 0, 0], [15, -4, -3, 0, -5, 4, 7, 0, 4, 0, 8, 4, -7, 7, -22, -5], [15, 0, 11, 15, 0, 7, 0, -7, 1, 0, -15, 2, 7, 0, 11, -2], [5, -6, -10, 6, 0, 0, -11, 10, 5, 6, -6, 0, -11, 10, -5, 0], [-4, 9, -8, -3, 0, 0, -2, 8, -3, 2, 9, 0, -2, 8, -11, -9], [-9, 0, -2, -5, 4, -3, -4, -1, 6, 4, 5, 4, -3, 6, -2, 0], [12, -5, -21, 0, 1, 5, -5, 0, -24, 0, -7, 6, 3, -3, -9, 1], [13, 10, 1, -2, 0, 0, 5, -1, -14, -7, 10, 0, 5, -1, -13, 0], [-4, 11, 10, 0, 2, -11, -2, 0, 13, 0, 8, 9, -3, 3, 1, 2], [5, 4, -1, 2, 2, 2, -1, 1, -3, 0, 0, -2, 6, 0, 0, 0], [-3, 0, -15, -4, -1, -7, 1, 6, -5, -1, 4, 1, -5, 15, -15, -2], [-18, 20, 6, -20, -6, -18, 8, 1, 0, -1, 18, -1, 1, -7, 7, -1], [-3, 0, -4, 6, 9, -1, -9, 0, 11, 9, -6, 3, -9, 6, -4, 6], [-8, 0, 14, 4, 12, -2, -12, -15, 5, 12, -4, 9, 3, 2, 14, 3], [13, 7, 10, -7, -17, -4, 30, 9, 0, -15, 4, -15, 15, -15, 10, -15], [-21, 0, -3, -8, 13, -8, -13, -5, 2, 13, 8, 5, -8, 2, -3, 8], [-27, 5, -3, -12, 0, 0, -6, 3, -4, 12, 5, 0, -6, 3, -7, -4], [-2, -1, 16, -3, -10, -3, 2, 14, 15, -16, 0, -6, 1, 0, 0, 0], [0, -10, -6, 14, 0, 0, -5, 6, 2, 9, -10, 0, -5, 6, -4, -1], [24, 12, -6, 0, -8, -12, 4, 0, -20, 0, 4, -2, 14, -14, -10, -8], [-26, -1, 27, 1, 4, -4, 0, 0, 0, 4, 4, 4, -4, -4, 0, 4], [1, -8, 4, -4, 8, -4, 5, -7, -7, 2, 0, -6, 3, 0, 0, 0], [26, -4, -10, 5, 0, 0, -7, 10, 8, -7, -4, 0, -7, 10, -2, 2], [-14, -6, -2, -2, -2, -2, -6, 0, 6, 6, 0, 8, -20, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_495_n_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_495_2_n_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_495_2_n_g(:prec:=16)
    chi := MakeCharacter_495_n();
    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_495_2_n_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_495_2_n_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_495_n();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![1, -10, 147, -416, 507, -44, 111, -18, 252, -84, 113, 46, 61, 22, 10, 2, 1]>],Snew);
    return Vf;
end function;