
// Make newform 192.7.e.g in Magma, downloaded from the LMFDB on 13 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_192_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_192_e_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_192_7_e_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_192_7_e_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 := [324, 192, 112, -12, -14, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [1143, 138, -152, -40, 17, 1], [-12069, -8994, 896, 1160, 19, -53], [-13824, -15744, 896, 1280, 64, -128], [-792, 1758, 448, -200, -13, 11], [216, -54, -304, 200, 49, -23]];
    Rf_basisdens := [1, 45, 135, 135, 15, 15];
    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_192_e();"
function MakeCharacter_192_e()
    N := 192;
    order := 2;
    char_gens := [127, 133, 65];
    v := [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_192_e_Hecke();"
function MakeCharacter_192_e_Hecke( : Kf := false)
    N := 192;
    order := 2;
    char_gens := [127, 133, 65];
    char_values := [[1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), 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]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 7;
    raw_aps := [[0, 0, 0, 0, 0, 0], [-2, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0], [-27, 3, 0, 0, 0, -1], [-9, 15, -12, 2, 3, 0], [-10, -48, 0, 0, 6, -2], [36, -92, 16, 18, -12, 0], [-697, -159, 0, 0, 21, -10], [54, -274, -112, -64, -18, 0], [-72, 275, 59, -116, 24, 0], [12397, -69, 0, 0, 18, -31], [-28554, 96, 0, 0, 18, -86], [-720, 2090, -70, 112, 240, 0], [-48977, 1401, 0, 0, -159, 10], [-540, 1324, -296, 44, 180, 0], [-864, 1877, -715, 416, 288, 0], [-81, 1059, 816, -616, 27, 0], [-96250, -7296, 0, 0, 714, 290], [-93625, -4575, 0, 0, 399, 328], [2106, -4998, 1320, 1388, -702, 0], [188002, -4176, 0, 0, 192, 816], [174269, 4011, 0, 0, -270, -527], [-1827, 3949, -1532, 282, 609, 0], [-4140, 16278, 3858, -126, 1380, 0], [-125446, -22920, 0, 0, 2934, -1162], [-1512, -2871, -7407, -4500, 504, 0], [127493, -9309, 0, 0, 900, 403], [7659, -20665, 2312, 868, -2553, 0], [406118, 7680, 0, 0, -846, -22], [-8568, 16492, -9212, 4820, 2856, 0], [18413, -14277, 0, 0, 2166, -1739], [-9603, 35585, 6776, 3068, 3201, 0], [13608, -39422, 1402, 3500, -4536, 0], [2122719, -2679, 0, 0, 879, -1744], [288, -22723, -21859, 1296, -96, 0], [292693, 79059, 0, 0, -10920, 6407], [320534, 42192, 0, 0, -6330, 4926], [2910135, -70479, 0, 0, 6129, 5106], [11610, -58446, -23616, 3048, -3870, 0], [40320, -84337, 36623, -4208, -13440, 0], [-7623, 1669, -21200, -33928, 2541, 0], [-1991130, 106608, 0, 0, -12666, 2462], [-39240, 99152, -18568, -25460, 13080, 0], [3542066, -3984, 0, 0, -6480, 20768], [64296, -191375, 1513, 33380, -21432, 0], [8255621, 13347, 0, 0, 24, -4521], [1192375, -163983, 0, 0, 21819, -10796], [8303501, -140709, 0, 0, 15882, -743], [-40455, 192537, 71172, 74202, 13485, 0], [-6628282, -57552, 0, 0, -618, 21038], [15588, -110998, -64234, -56646, -5196, 0], [-33084, 172444, 73192, -54284, 11028, 0], [-3820302, 163344, 0, 0, -13704, -13336], [-3501, 95427, 84924, -88634, 1167, 0], [-59544, 232928, 54296, 28820, 19848, 0], [162234, -286998, 199704, -25340, -54078, 0], [-58464, 281527, 106135, 110512, 19488, 0], [11712061, -158421, 0, 0, 6138, 34393], [11124182, -62496, 0, 0, 6786, 474], [-41220, 131366, 7706, 14198, 13740, 0], [5163215, 560217, 0, 0, -72981, 32204], [-49608, 107033, -41791, 43564, 16536, 0], [11160183, 67569, 0, 0, 12771, -60836], [116118, -497898, -149544, -3660, -38706, 0], [-19904982, -692712, 0, 0, 77538, -1710], [15984, -240533, -192581, -57640, -5328, 0], [41078975, -19479, 0, 0, 5991, -11480], [1529802, -583320, 0, 0, 33366, 94342], [259515, -1058293, -279748, 68710, -86505, 0], [42413334, -155952, 0, 0, 21774, -13338], [-15984, -355144, -403096, 83528, 5328, 0], [360306, -1227006, -146088, -92796, -120102, 0], [-34092547, -1003989, 0, 0, 110994, 1681], [-30868538, -339696, 0, 0, 18342, 58206], [-21692545, 372393, 0, 0, -59835, 55374], [-193752, 69120, -512136, -44820, 64584, 0], [173232, -760991, -241295, -242136, -57744, 0], [-14884538, 1558944, 0, 0, -197382, 72498], [753372, -2174364, 85752, 6222, -251124, 0], [62753682, -94272, 0, 0, -7320, 53384], [49041, -14135, 132988, 111062, -16347, 0], [17175526, 264528, 0, 0, 35310, -194106], [9972, 646220, 676136, 122772, -3324, 0], [31057402, 633240, 0, 0, -34002, -109074], [-55113867, -1793997, 0, 0, 179040, 60879], [280539, -448333, 393284, -368566, -93513, 0], [-241740, -247296, -972516, 143882, 80580, 0], [-21728782, -99840, 0, 0, 7560, 10600], [-97416, 508263, 216015, 504460, 32472, 0], [43265533, -869589, 0, 0, 144534, -143739], [592245, -1622803, 153932, 17662, -197415, 0], [-230040, 1000568, 310448, -37896, 76680, 0], [-16526299, -620733, 0, 0, 58692, 30835], [-926685, 2244167, -535888, -441608, 308895, 0], [-115482345, -1051887, 0, 0, 187419, -211628], [-246474, -520954, -1260376, -128804, 82158, 0], [-174672, -599109, -1123125, -328056, 58224, 0], [450792, -2105118, -752742, 587692, -150264, 0], [-119765777, -632967, 0, 0, 190425, -360286], [83000358, -5889312, 0, 0, 716130, -185286], [107237207, 1923537, 0, 0, -391503, 533330], [433512, -310065, 990471, -830252, -144504, 0], [912861, -3596171, -857588, -213506, -304287, 0], [-791064, 1955262, -417930, 429884, 263688, 0], [-42712209, -2340807, 0, 0, 133611, 379436], [-62852470, -6348408, 0, 0, 584622, 362270], [274995, 603951, 1428936, -418684, -91665, 0], [-1284624, 5860260, 2006388, 630248, 428208, 0], [-2516058, 7684094, 135920, -209264, 838686, 0], [-126344894, -483792, 0, 0, 147456, -281104], [-25075379, -1037349, 0, 0, 54246, 183045], [-119847818, 1593696, 0, 0, -246006, 206786], [-1758420, 4030570, -1244690, -860002, 586140, 0], [139317919, 1501065, 0, 0, -126561, -120672], [-98999755, -4199373, 0, 0, 465708, 2667], [-450324, 717648, -633324, -1481434, 150108, 0], [-155286537, 1196721, 0, 0, -52599, -241110], [-841230, 2577706, 54016, -769400, 280410, 0], [-1830312, 4242231, -1248705, 1401756, 610104, 0], [193617, -2397075, -1816224, -382992, -64539, 0], [-190623722, -875616, 0, 0, 371514, -822670], [-171874886, 4260792, 0, 0, -557994, 253718], [599112, -1936135, -138799, 1103972, -199704, 0], [-1575801, 3002599, -1724804, -1133978, 525267, 0], [171591047, 2924001, 0, 0, -229395, -286482], [-449352, 3616043, 2267987, 285148, 149784, 0], [-63166538, -7209120, 0, 0, 694050, 320890], [-148716, -883532, -1329680, -1871256, 49572, 0], [164002677, -7779789, 0, 0, 804924, 178491], [-107140106, 9205680, 0, 0, -1100730, 233630], [-161079673, 6377121, 0, 0, -697977, -31776], [332442, -3302398, -2305072, 610448, -110814, 0], [203535741, 4891755, 0, 0, -846162, 907901], [-298122554, 4238736, 0, 0, -721938, 752902], [182592, -12786, 534990, 447016, -60864, 0], [-63153262, 2662992, 0, 0, -246120, -149304], [4931640, -15390943, -596023, -642692, -1643880, 0], [110281639, 12471873, 0, 0, -1319931, -197498], [1576584, -957805, 3771947, -571900, -525528, 0], [-1140192, 4039082, 618506, 1091432, 380064, 0], [116820751, -1617831, 0, 0, -107823, 862746], [456552, -4466251, -3096595, -1373900, -152184, 0], [483713461, -18010701, 0, 0, 2190612, -568269], [-2761065, 7996291, -286904, -1611132, 920355, 0], [292494614, 2565264, 0, 0, -649482, 1093358], [3836106, -14478982, -2970664, -1502972, -1278702, 0], [-552253466, -1004688, 0, 0, 385422, -821370], [1369080, -1070490, 3036750, 2095044, -456360, 0], [495772575, -1953015, 0, 0, 151245, 197270], [7796160, -22601672, 786808, 2345772, -2598720, 0], [721923030, -15946896, 0, 0, 1854246, -247106], [2609784, -5438996, 2390356, -4316820, -869928, 0], [71941415, -5733759, 0, 0, 893037, -767858], [-4289130, 8470886, -4396504, 529596, 1429710, 0], [515143567, -7245927, 0, 0, 1196889, -1175358], [-3538404, 596292, -10018920, 1092652, 1179468, 0], [-342630187, 1267731, 0, 0, -157260, 49203], [-4357188, 9405240, -3666324, 3194446, 1452396, 0], [10418874, 8823240, 0, 0, -1187982, 622866], [3749832, -16083473, -4833977, -2074732, -1249944, 0], [-7159311, 13066277, -8411656, 892540, 2386437, 0], [-2159784, 5423454, -1055898, -7074252, 719928, 0], [-298737467, 30416163, 0, 0, -3331212, -145085], [8710767, -27479297, -1346996, -1538386, -2903589, 0], [-3111516, 16838612, 7504064, -724046, 1037172, 0], [-7675506, 22762494, -264024, -5339364, 2558502, 0], [-572410003, -18913413, 0, 0, 1899750, 605221], [-546434026, -2878848, 0, 0, -372726, 2077794]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_192_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_192_7_e_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_192_7_e_g(:prec:=6)
    chi := MakeCharacter_192_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 7));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_192_7_e_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_192_7_e_g( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_192_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,7,sign)));
    Vf := Kernel([<5,R![28037120000, 0, 265190400, 0, 36192, 0, 1]>,<7,R![-17262936, -302868, 78, 1]>],Snew);
    return Vf;
end function;