
// Make newform 390.2.bd.b in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_390_bd();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_390_bd_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_390_2_bd_b();".
// 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_390_2_bd_b();".
// 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 := [4, -40, 164, -344, 390, -336, 358, -180, 351, -176, 118, -24, 67, -48, 12, -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], [4680253552809794, 4742345058394342, -19428846797347660, -5327429661771194, -26263502656698172, -6622116382602757, -17495309067416083, 3536477625795241, -8792384561334166, -900494454550979, -1607350163227359, 2680829374033629, -648847305484636, 217326371958939, -74224360591111, 1434138866353], [195044141171618, -814448920872776, 47788976778038450, -21876042039069938, 48096185658956821, -26694324268699259, 18681773772251579, -34533205664857133, 22625006932641203, -12957947975492223, 281604145705947, -7621279603788347, 5707540667520213, -1406992399278677, 492304781090243, -123434729989149], [6950822659807744, -37418608795158304, 77038886286558388, -62657114582598388, 85474895099571132, -44775296775045806, 55051784324946342, -58228159495736079, 37940274269902486, -15122432396762870, 7288708077624688, -13885376435295071, 7694802116157034, -2027562782554100, 666808683532056, -137809854283897], [-16575048540328, 162118602709476, -622728293466680, 1087029641011808, -488205468817916, 1336974192211299, 11545660383276, 1073827229563468, -395501573216208, 464520812336313, 18595969360728, 154868117754112, -162143292202288, 38145193554947, -13126607646508, 3909951128714], [3631882693804, -56848696686768, 338424533456400, -1127861763864064, 55329885176253, -1495012504742632, -327950045248708, -1058958936197574, 264781323438119, -507559901300404, -55417826512144, -115488770848206, 160755388928989, -36598537974476, 12665097411614, -4143762135082], [35411484066617244, -192208665603330138, 446449271988400340, -517428552172387524, 437389184714757453, -494473747233645422, 215899963434715562, -482812364930441289, 237626790891811969, -167480504119187474, 26412913789425376, -90330349700000641, 67570735976932179, -16762149286150656, 5626426049162414, -1439070217869327], [-77929949288, 520681411390, -1441782411844, 1933409293532, -1324040796852, 2053184268060, -458012963070, 1863520118983, -820031528032, 709289788986, -40514369326, 314950092835, -270219726184, 65510725326, -22259671750, 6100180981], [65633529574178, -411232893748306, 1306467148621370, -1824887125776248, 1207350248071826, -1990877398734524, 332786417052279, -1797695843305223, 777595182487398, -701312474278478, 17152993349497, -295959094070367, 264606089742658, -63731636791632, 21780610045393, -6072104849199], [-28123111426177514, 198734847296148758, -504441981276855820, 666044503208027234, -490835043167996523, 683022296693330837, -188961643415479902, 636133145212162719, -292701695999447459, 235208674633202009, -19058949252444566, 111269852929486391, -91579556495364929, 22354204007810251, -7578221328661024, 2035054902038187], [-330526984, 2513736318, -7254602740, 9461086554, -6825888288, 10021703527, -2344575592, 9212296429, -4158557204, 3515753069, -188871116, 1575363211, -1344589864, 326080511, -111020724, 30320067], [-7740432548067096, 53424782974620022, -157676074754561598, 181717723715357082, -154497881200594756, 182753898461327581, -65452477393295353, 179418986889806458, -87228624024570764, 64640506440221435, -6275666808832427, 32832120300673190, -25955396623934578, 6376823282252541, -2163110819836755, 567889621787826], [-60388611162910706, 413425841726845612, -1197019598040248580, 1638034897211160076, -1105265950762762657, 1765864153109925593, -344839767257990343, 1588081348228614396, -694365286936506611, 615506034577358971, -25993531049108449, 264944456866733364, -232054361068567251, 56052725193796619, -19095159515314451, 5281395788857158], [258618081490, -1753345508964, 4768566345236, -6274129258728, 4492931472132, -6516717498206, 1643327598977, -6018321521990, 2719627979686, -2258419134670, 152629602893, -1035106924390, 869648666130, -211530176114, 71829768307, -19482487322], [791533522, -6297003604, 18964234070, -25400492652, 17742563129, -27237589476, 5661417851, -24845185642, 11027434227, -9561674912, 407798693, -4191737118, 3640243297, -880560228, 300206917, -82631746], [-83437215315298168, 607998971285547366, -1699651856766889730, 2200212896950517088, -1620912261036340171, 2300137181821316574, -584968875881439509, 2135058242437940538, -975207215422026373, 803087087863156658, -50736196725114107, 369420728986424472, -310349129733580443, 75476948193017452, -25667361154231553, 6956104161848134]];
    Rf_basisdens := [1, 5173992472766390, 5173992472766390, 1034798494553278, 28585593772190, 28585593772190, 5173992472766390, 18265555126, 16530327389030, 5173992472766390, 63923990, 1034798494553278, 5173992472766390, 18265555126, 63923990, 5173992472766390];
    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_390_bd();"
function MakeCharacter_390_bd()
    N := 390;
    order := 12;
    char_gens := [131, 157, 301];
    v := [12, 3, 11];
    // 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_390_bd_Hecke();"
function MakeCharacter_390_bd_Hecke(Kf)
    N := 390;
    order := 12;
    char_gens := [131, 157, 301];
    char_values := [[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, 0, 0, 0, -1, 0, 0], [0, 0, 0, 0, 0, 1, 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, 1, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -1, 1, 0, 0, 0, 1, 0, 1, 0, -1, 0, 1, -1, 0, 0], [-1, 1, 0, 0, 1, 1, 0, -1, 0, -1, 0, 0, 1, -2, 0, 1], [1, -1, -2, -1, -1, -2, 1, 1, 1, 1, -1, 0, 0, 0, 0, 0], [-1, 1, 1, 0, 2, 1, 1, -1, -1, -1, -1, 1, 3, 0, 1, 1], [1, 0, 2, 1, -1, 2, -1, 0, 1, -1, 0, 1, -1, -2, 0, 0], [1, 0, 1, 0, -1, 0, 1, 1, 0, 0, 0, 1, 1, -1, 0, -1], [2, -1, 1, 1, -1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, -2], [5, 0, 0, 1, -1, -2, -3, 1, 0, 1, 1, -1, -4, 3, 2, 1], [4, -2, 0, -1, -1, -1, 0, 2, 1, 1, 1, 2, -1, -1, 2, -1], [-1, 1, 3, 1, 0, 0, 0, -1, 1, 0, 0, 1, 3, -1, -3, 0], [0, 1, 1, -1, -3, -1, 1, 3, -3, -1, -1, 0, -1, -2, -2, 0], [-1, -2, -3, -3, 2, 1, 4, -1, 1, -1, -2, 2, 2, -2, 0, 3], [-1, -1, -1, 0, -4, -2, 4, -1, 1, 5, 1, 1, -1, 1, 1, 2], [2, 1, -2, 0, 1, -3, 0, 1, 1, 0, 1, -1, -2, 5, 2, 1], [-3, 1, -4, -2, -1, 1, -4, -1, -2, -3, 1, -1, -1, 0, -4, 3], [3, -2, 3, -3, -2, -4, -1, 3, 3, 3, -1, 1, -4, 2, 4, 0], [-2, 3, -1, 3, -1, -5, -2, 4, -4, 1, -1, -3, -2, 8, -3, -4], [-1, -2, 1, -1, -4, -3, 6, 5, 1, 1, -2, -4, -4, -2, 0, -3], [-3, 0, 3, 0, 1, 0, 0, 0, 2, 1, -2, 2, 1, 1, -4, -1], [2, 2, -8, 2, 2, 2, -2, -2, -6, 0, 6, -4, -4, 8, 0, 0], [-1, -1, 0, 2, 3, 2, -4, -1, -1, -2, -1, -3, -2, 0, -3, -1], [11, 0, -1, 0, -4, 0, 3, 1, -1, 4, 4, 3, -4, 7, 10, 0], [-3, 3, 0, -2, -3, -5, -4, 3, -2, -3, -5, -5, -3, 0, -8, -3], [4, 3, -2, -2, -3, -5, 3, 6, 1, 3, -1, 2, 2, 3, 5, 1], [-3, 1, -2, 4, 2, 7, -7, -3, -2, -4, 3, -3, -3, 1, 0, -3], [2, -3, -1, 3, -1, 5, 0, -2, 2, 5, 5, 3, 0, -4, -1, -2], [3, 0, 0, 1, -5, -3, -6, 6, -5, 1, 1, -6, -7, 4, -2, -7], [-1, -3, 0, 3, 0, 2, 1, -3, 3, 0, 3, 0, 8, 2, 1, 3], [2, 5, -1, 5, 4, -1, -3, -2, -2, 0, 0, 2, 2, 3, -1, 0], [-7, 3, 6, -4, 4, -2, 3, 3, -7, -7, -7, -3, 0, -1, -3, -3], [1, -2, 2, -4, -2, -4, 3, 0, 4, 0, 1, -1, -4, 0, 3, -3], [3, -1, -2, -4, 1, 1, -3, 1, -4, -1, 0, 0, -3, 0, 2, -4], [-2, 3, -1, 0, 4, 1, -1, 0, -4, -3, -3, -4, 2, -4, -7, 2], [-7, -1, 0, 4, 3, 10, 2, -5, 3, 4, 3, 5, 4, -10, -1, 1], [-3, 6, 5, 7, 3, 4, -5, 0, -3, -7, 1, 0, 2, 0, -3, -2], [-2, -4, 2, 2, 4, 2, -6, -2, 2, 2, 2, 2, 4, 0, 8, -8], [8, -4, -1, -1, 2, -1, -11, 2, -5, 2, 4, -1, -10, 0, 4, -11], [2, -1, 0, 1, 0, -3, -5, 3, 3, 2, -1, 0, 0, -3, 7, -1], [-3, 6, -1, 4, -1, 1, 12, -5, 1, -1, 3, 4, 10, -3, -1, 12], [-1, 1, 11, 0, -2, 0, -6, -1, 1, -3, -1, 1, -5, -4, 1, -6], [-9, 3, 4, 4, 3, 3, -8, -7, -4, -7, 3, -3, -3, 2, -10, 1], [-2, 0, -1, 3, 4, 0, -11, -4, -3, -4, 0, -3, -6, 3, -4, 5], [7, -1, -3, 0, 2, 3, 5, -3, -2, -2, -2, 0, 10, -3, 2, -5], [-6, -1, 5, 1, -1, 4, -6, -4, -1, -4, 3, -3, -7, -6, -8, -2], [3, -1, -7, 4, 6, 1, 3, -5, 2, 6, 2, 4, 2, -3, -4, 3], [3, -6, -11, -1, 3, -6, 5, 3, 2, 3, -3, -1, -3, -5, -5, 5], [-1, -6, -3, -5, 6, -3, -8, 1, -5, -1, -6, -6, -4, 0, 0, -9], [1, 2, 0, -3, -5, -1, 12, 0, 5, 3, -5, 0, 9, -8, 2, 3], [-1, -4, -4, -4, 4, -4, 6, -2, -4, 4, 0, -2, 2, 7, -2, 2], [-3, 1, 2, -3, 0, -9, -4, 3, 0, -3, -2, -3, 1, 1, 3, -2], [7, -4, 0, 2, -2, 9, 4, -4, 6, 2, 4, 2, 10, -9, 0, 14], [-8, -3, 3, -1, 3, 2, -8, 4, -1, -4, -10, -10, -1, 0, -8, -8], [1, 2, 7, 2, 7, 6, -5, -2, -2, -3, 3, 5, 1, 0, 5, 0], [-3, 2, -4, 2, -2, -3, 1, 5, 5, 4, -4, 3, 3, 4, -1, 0], [-4, 2, 8, 8, -2, 6, 0, -2, 8, 2, 2, 2, 10, 0, -2, -2], [-3, -1, -6, -1, 0, 2, 8, 1, 1, -2, 2, 1, 4, 1, 0, 0], [-7, 3, 2, 4, 5, 7, -5, -7, 2, -7, -3, -5, 3, 1, -1, 8], [-2, 1, -3, -2, -4, 8, 0, -1, -4, -2, -1, 1, 4, -6, -9, 6], [11, -2, 5, 2, -1, 7, 2, -3, 3, 9, 9, 4, -4, 3, 7, -20], [6, -5, -1, -1, 5, 7, -8, 0, -1, 0, 1, 1, -1, 0, 2, -8], [-7, 3, -4, 4, -3, -4, -8, 3, -5, 0, -5, -9, -16, 4, -9, 7], [7, -3, 2, -5, 0, -5, -10, 3, 0, 3, 0, -5, -9, 9, 13, -4], [3, 4, -10, -1, 3, -3, 10, -4, 3, -1, 3, 4, -1, 6, 6, 15], [5, -5, -8, -3, -6, -3, -6, 5, -6, -1, 6, -9, -9, 10, -3, 0], [-9, 7, -6, -2, 3, 5, 6, -5, -2, -9, 7, 3, 3, -6, 2, 9], [1, 7, -15, -2, -2, -4, 6, -7, -2, -2, 5, 7, 10, -1, 9, 24], [3, 12, 5, 7, 2, 1, 2, -9, -7, -5, 12, 2, 2, 12, -4, 1], [0, -2, -8, 2, 8, 3, -6, -4, 4, 0, 0, -4, 0, 5, 1, 8], [5, 3, -5, -2, -8, 4, -5, 5, -10, -8, 8, -2, -18, 6, -4, -5], [-15, 5, 0, 2, -5, -8, 4, -7, 5, -2, -3, -7, 6, -2, -17, 5], [4, 5, -5, -5, -5, 3, 14, -4, 4, 3, 3, 9, 20, -4, 5, 22], [4, 1, 1, -6, -6, -5, 7, 4, 2, 5, -1, 6, -4, -4, 3, 4], [-8, 2, 13, 2, -1, 6, -7, 4, 4, 1, -1, 3, -1, 1, 2, 0], [0, 6, 10, -2, 6, -4, -2, -2, 2, -2, -6, 6, 4, 4, 8, 8], [1, -1, 9, 8, -4, 8, 6, -1, 3, 5, 3, -5, 5, 0, -5, -10], [-5, -2, 5, 1, -2, -7, -4, -1, -1, -1, 7, -7, -18, 16, -8, -15], [6, 0, -12, 0, 7, -6, 4, -5, -5, -1, 1, 2, 3, 7, -5, 0], [-29, 9, 6, 2, 5, -15, -4, -3, -2, -11, -9, -5, 1, 1, -21, 5], [-4, -4, -2, -6, -4, -10, 10, 0, 2, 4, -4, 6, 8, 4, 0, 2], [6, -6, 1, -3, 0, 5, -4, -4, 0, 3, 3, -4, -7, -4, 4, 8], [-13, 8, 5, -8, -3, -9, 18, -7, 7, -3, -3, 10, 8, -7, 3, 16], [-7, 0, 10, -3, 3, 16, -7, -12, -9, -3, 0, 3, 3, -10, -6, -2], [4, -1, -15, 3, 5, 7, 14, -4, 0, 5, 3, 3, 4, 4, 1, 14], [2, -2, -6, 3, -5, 5, 10, -2, -5, 3, 1, 2, -9, -7, 0, 5], [3, -7, -17, -6, 2, -8, -10, 6, 8, 1, -7, 2, 2, -1, 5, 9], [-17, 1, -1, -4, 14, 2, 5, -13, 0, -14, -4, 4, 20, -6, -6, 3], [6, -14, -9, -10, 5, -3, 15, 1, 6, 4, -14, 5, 5, -10, 8, 5], [-3, -7, 10, -5, -6, -5, 4, 7, 10, 1, -10, 5, 13, -15, -5, 8], [3, 3, -14, 4, -1, -2, 0, 5, -1, 4, 7, -5, -14, 10, 1, 5], [3, -5, 14, 5, 2, 10, -2, -5, 5, 0, 0, 3, 2, -5, -2, -22], [1, 9, 2, -2, -9, -5, -2, 5, -2, -5, 8, 8, -3, 0, 8, -1], [7, 3, -14, 0, -2, -5, -1, 5, 2, 2, 2, 0, 11, 5, 6, 1], [4, -10, 10, -1, 3, -5, 0, 0, 3, -1, -11, 0, 1, -3, 4, -9], [8, -3, -3, 8, 8, 9, -19, 4, -12, -5, 3, -8, -14, 7, 0, -12], [-1, -5, 0, -5, -10, -3, -15, 4, 4, -4, 4, -6, -13, -6, 0, 0], [18, -5, 3, -1, 2, 13, 7, -5, 4, 3, 4, 5, 0, -7, 5, 5], [-8, 11, 7, 11, -3, -1, -10, -2, -2, 3, -3, -5, -2, 6, -11, 0], [-9, 4, 5, -5, -2, -9, -6, 4, -2, -5, -1, -4, 3, -3, 0, -4], [7, 3, -8, -1, -2, 11, 0, -3, 2, 1, -4, -3, -1, -15, 9, -4], [0, 3, -7, 1, 3, 12, 4, -6, -2, 3, 3, 1, 0, 11, 1, 4], [11, -9, 10, -2, -1, -13, 4, 9, 8, 7, -9, -1, -1, 6, 4, -9], [8, -9, -3, -2, 1, -6, -7, 8, -1, 1, -1, -2, -9, -4, 21, -7], [-19, 7, 21, 0, -2, 0, -2, -7, 5, -9, -5, 5, 7, -3, -19, 2], [-11, 6, 3, -5, 2, -5, 10, -6, 7, -4, -7, 2, 18, -10, 2, 16], [22, -6, -2, -14, -8, 8, 24, 2, 10, 8, -4, 14, 18, -22, 20, 4], [7, 6, -7, 6, 1, 6, -14, -6, -16, -5, 16, -10, -5, 7, 4, 5], [10, -6, -8, -6, -2, -6, 2, 6, 2, 4, -2, -4, -8, 4, 16, -4], [-1, -7, 2, -7, -2, -16, -2, 9, 1, -2, -8, -7, -2, -9, -11, -2], [4, -5, -5, -4, 2, -5, 18, 2, 4, 1, -5, 2, 2, 3, 0, 3], [-9, 1, 3, -1, 4, -11, 4, -5, 7, 4, -8, -1, 11, -10, 10, 4], [-5, -2, -8, -6, 2, -6, -15, 8, -6, -8, -5, -5, -16, 0, 3, -5], [13, -5, -9, -5, 3, 14, 2, 1, -3, 5, 0, 1, -3, -4, 20, -5], [6, -2, -12, 0, 10, 10, 0, -6, -4, 2, 2, -10, 10, 0, 0, 2], [-2, -3, -15, 5, 3, -9, -15, -4, 5, 4, 3, 3, -11, 0, 6, 1], [4, 0, -4, 4, 0, -4, -6, -4, -4, -4, 6, -6, -4, 16, 0, -2], [4, 4, 13, 4, -7, -4, -9, 10, 10, 5, -5, 3, -1, -7, 10, 0], [10, -8, -21, -8, -1, 1, -15, -2, -2, 1, -1, -3, -13, -12, 9, 0], [2, -2, -4, -4, 2, -6, 6, -2, -4, 2, -4, -4, -2, 0, -4, 4], [-4, 8, -12, 8, 14, 28, 1, -13, -13, 0, 0, 1, 5, -10, 11, 0], [-5, 2, 13, -2, -5, 7, 5, 2, -2, -7, -7, 3, -3, -17, -14, -6], [-19, -2, -8, 6, 2, 2, -18, -4, -2, -6, 8, -4, -12, 19, -8, -10], [-13, 5, 4, 0, -5, -19, 0, 9, 0, -9, -7, -7, -5, 0, -6, 5], [15, -8, -14, 8, 10, 7, -13, -5, 5, 8, 8, -5, -17, 18, 13, 2], [20, -10, 2, 5, 1, 5, -26, 10, -9, 11, 9, -4, -31, -1, 6, -27], [0, 5, -17, 4, -6, -5, 9, 4, -2, -1, 5, -6, -6, 12, -9, 6], [8, 2, 2, 2, 2, 0, -22, 0, -2, 0, 0, 0, -2, 4, 8, 18], [-5, -5, -12, -1, 3, 8, 9, -7, 3, -1, -6, 7, 6, -14, -2, 20], [-14, 0, -15, 2, 4, 12, -21, 0, -2, -4, -2, -4, -7, -5, -4, 3], [12, 0, -7, 0, 1, 0, -1, 0, 0, 11, 11, -1, -7, 13, 12, -10], [-6, 12, 2, 4, 2, 14, 8, -14, -2, 2, 6, 4, 12, 10, 2, 8], [-12, 3, -9, 9, 15, -5, -22, -12, -8, -15, 1, -9, 2, 14, -13, 4], [7, -8, -13, 8, 10, 8, -25, 7, -7, -2, -2, -17, -4, 9, -8, -4], [-3, -1, 3, 0, -4, -8, 8, 4, 0, 1, 1, 4, 12, -1, -5, -7], [4, -10, -4, -10, 8, 3, -12, -2, -2, 4, -4, 6, -8, 1, 5, 0], [19, -11, -2, -4, -11, -3, 15, 21, 4, 21, -2, 2, -15, -2, 12, -26], [5, -3, 12, 4, -3, 1, -16, 13, -4, 13, 3, -3, -31, 6, -2, -19], [-15, 0, -6, -4, 2, -15, 10, -4, 2, 4, 0, -2, 14, 0, -13, 4], [15, -5, -9, 2, -4, -15, 5, -1, 2, 4, 4, -2, 10, 17, 5, -9], [-9, 7, 3, -2, 2, -11, 10, 7, -2, 2, -9, 7, 8, 11, -2, -2], [15, 3, 6, -3, -16, -3, 16, 3, -3, 10, 10, 13, -26, 2, 15, -6], [1, 8, 13, 8, -11, -14, -8, 13, 2, 0, 8, -11, -11, 7, 4, -12], [-6, 0, 8, 2, 8, -10, -2, 0, 0, -8, 0, -2, -8, 6, -2, 6], [0, -3, -6, 0, 5, 9, 1, -2, 3, 5, -3, 0, 0, 9, -5, 1], [-8, 4, -24, -2, -2, 4, -6, -2, -4, -6, 4, -2, -2, 2, -10, 14], [10, -3, -15, -9, -1, -9, 0, 3, -2, 2, 2, -11, -12, 16, 21, -1], [8, -7, -17, 10, 0, 8, -6, 3, 0, 10, 3, -3, -10, 4, -1, 4], [-27, 17, 19, 8, -4, 8, 4, -17, -3, -21, 3, 5, 19, -13, -31, 14], [-27, 13, 6, -1, -4, 5, -2, 13, -10, -9, -10, -9, 1, -3, -9, -10], [2, -9, -11, 11, 9, 19, 1, -12, 11, 12, -2, -2, 1, 0, -8, 11], [-2, -7, -2, -19, -5, 3, 24, -2, 14, 5, -5, 19, 21, -22, 12, 14], [8, -8, -18, -8, 0, 6, -10, -2, 0, 8, 0, -2, -18, -2, 12, -8], [-18, 6, 3, -6, -3, -16, 1, 8, -8, -7, -7, -5, 5, -5, -10, -2], [-7, -7, 6, -7, -16, -14, -26, 17, 17, 2, -2, 1, -16, 5, -4, 0], [-8, 0, 14, 10, 4, 2, 0, 0, -2, -4, -2, -12, 4, 4, -12, -16], [9, -1, 0, 0, 1, -1, 2, -1, 0, 1, 13, 13, 1, 0, 18, 1], [4, -3, -10, -13, -6, -17, 13, 5, 1, 16, 3, 6, -6, 8, 10, 11], [6, -11, -5, -12, -14, -10, 6, 7, 14, 12, -1, 7, -6, -2, 9, 0], [-3, 14, 4, 3, 9, 3, 4, -4, -9, -3, -11, -4, 7, -6, -4, 5], [-9, 5, 10, 1, 4, -4, -8, -9, 5, 4, -4, 1, 6, -5, 18, -8], [2, -1, 26, 0, -3, 0, 12, -1, -4, 1, -1, -3, -3, 12, -15, -15], [18, -4, -6, 3, 14, 3, -7, 4, 1, 18, -1, 4, -5, 2, 26, -9], [-9, 4, -1, 1, 4, -5, -18, -7, -1, -7, 3, -3, 2, 12, -6, 19], [5, 1, -1, -4, 0, 4, 27, 1, 6, 0, 2, 4, 28, -8, 8, -19], [-2, -2, -1, 3, 0, 3, 12, 2, 5, 2, -5, 8, 18, 0, -6, 10], [-8, 3, -1, 1, -5, -1, 12, 2, 6, -5, -5, 1, 6, -2, -7, 12], [-15, -12, 16, -10, 0, 7, 15, 10, 10, 2, -12, 0, 0, -19, 2, -9]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_390_bd_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_390_2_bd_b();".
// 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_390_2_bd_b(:prec:=16)
    chi := MakeCharacter_390_bd();
    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_390_2_bd_b();".
// 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_390_2_bd_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_390_bd();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![10000, -48000, 151600, -283840, 394684, -365616, 265708, -135336, 61357, -20900, 8098, -2152, 695, -112, 34, -4, 1]>],Snew);
    return Vf;
end function;