
// Make newform 196.10.e.f in Magma, downloaded from the LMFDB on 08 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_196_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_196_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_196_10_e_f();".
// 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_196_10_e_f();".
// 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 := [1299600, 1140, 1141, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [1299600, -1141, 1141, -1], [-1299600, 2602621, -1141, 1], [6842, 0, 0, 4]];
    Rf_basisdens := [1, 1300740, 650370, 1141];
    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_196_e();"
function MakeCharacter_196_e()
    N := 196;
    order := 3;
    char_gens := [99, 101];
    v := [3, 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_196_e_Hecke();"
function MakeCharacter_196_e_Hecke( : Kf := false)
    N := 196;
    order := 3;
    char_gens := [99, 101];
    char_values := [[1, 0, 0, 0], [-1, 1, 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 := 10;
    raw_aps := [[0, 0, 0, 0], [0, 112, -1, 0], [-798, 798, -9, -9], [0, 0, 0, 0], [0, 25296, -168, 0], [-92386, 0, 0, -585], [0, 76062, 3042, 0], [302512, -302512, -2097, -2097], [1251804, -1251804, 546, 546], [-1363746, 0, 0, 1806], [0, 3327520, -44226, 0], [3430114, -3430114, 99918, 99918], [7077378, 0, 0, -59694], [-566920, 0, 0, -116424], [-17743320, 17743320, -68286, -68286], [0, 16655970, -486780, 0], [0, -14709744, 858429, 0], [-17975846, 17975846, -577161, -577161], [0, 85143352, 548730, 0], [-231807744, 0, 0, -29568], [0, 50403430, -1998828, 0], [98746912, -98746912, -1018836, -1018836], [25713744, 0, 0, -1920243], [-324643746, 324643746, -1535628, -1535628], [1390646810, 0, 0, -1516194], [0, 58428762, -4396827, 0], [379641640, -379641640, -2803554, -2803554], [1419527184, -1419527184, -962094, -962094], [0, -559578470, -1835442, 0], [-691686906, 0, 0, 11363520], [-1358933764, 0, 0, 16201962], [701502816, -701502816, -28809489, -28809489], [0, 397739958, -14413980, 0], [6909750848, 0, 0, -12578193], [8030083818, -8030083818, -7847868, -7847868], [0, -10392738284, -7801794, 0], [0, -7655104478, 37126935, 0], [1843498096, -1843498096, 20897856, 20897856], [3333306144, 0, 0, -81230790], [18639228258, -18639228258, 11084205, 11084205], [0, -1900239432, 63521430, 0], [-3002569234, 0, 0, -95560389], [4337818776, -4337818776, -182773752, -182773752], [0, -3533751230, -18614232, 0], [-24415082226, 0, 0, 78010464], [0, -1559364968, 4886406, 0], [5825861912, 0, 0, -90281646], [13794129272, 0, 0, -134085240], [0, 41838459936, -195960783, 0], [-1656197270, 1656197270, 148916133, 148916133], [-25372235658, 25372235658, 42008232, 42008232], [-18865173948, 0, 0, -16363494], [0, -65297213786, 35891262, 0], [-17460392544, 0, 0, 688332015], [-49363902546, 49363902546, -213628704, -213628704], [0, 50624132928, 300173664, 0], [0, 44793607026, 180752667, 0], [-52997683592, 52997683592, -797289876, -797289876], [0, 35086071898, 722633688, 0], [38157597690, 0, 0, -709900128], [0, 14811168736, 966409821, 0], [-183976661274, 0, 0, -298065423], [-69731155312, 0, 0, 1016401617], [0, -62766609192, -61328352, 0], [-18764157314, 18764157314, 1899824886, 1899824886], [-72801203814, 72801203814, 397812576, 397812576], [-72171906872, 72171906872, 1718004456, 1718004456], [61314419342, 0, 0, 1077068160], [0, -117912252312, 1049620824, 0], [-449631070378, 0, 0, 75180879], [0, -34479048954, -1064692692, 0], [-143076750420, 143076750420, -1476842010, -1476842010], [0, 249321500344, 1503414432, 0], [34803767146, -34803767146, -3891951756, -3891951756], [-235946052376, 0, 0, -2541399084], [202085393160, -202085393160, 3680277882, 3680277882], [0, -13463295150, 1239491442, 0], [166307780506, -166307780506, -4101374943, -4101374943], [-666460424454, 666460424454, 17860332, 17860332], [0, -113240142218, -4257209646, 0], [361513788384, 0, 0, -3569158149], [-246108652378, 0, 0, 2111855256], [0, -1086408369420, -152230890, 0], [575426986946, 0, 0, -1391784066], [436488294256, -436488294256, -1030598748, -1030598748], [732684669336, -732684669336, -914537190, -914537190], [-234922013694, 0, 0, 395819592], [843728244922, -843728244922, 2558892168, 2558892168], [672024604902, 0, 0, -5295091461], [-859047801880, 0, 0, -4500866916], [677458409712, -677458409712, -9832343661, -9832343661], [0, 1376028738672, 3534842454, 0], [0, 204796817644, -2542899618, 0], [174823406040, 0, 0, 4910323950], [-3252631376, 3252631376, -13823182422, -13823182422], [-280394242128, 0, 0, -3637417560], [-278750977638, 278750977638, -321609255, -321609255], [0, -1449968904762, -12806840106, 0], [-626694452384, 626694452384, -4087859913, -4087859913], [-2933275512062, 2933275512062, 1947605436, 1947605436], [-713579403760, 0, 0, -16326929556], [0, 943447140138, 8135177064, 0], [0, 3232895120784, 3900554271, 0], [1719702661842, -1719702661842, 11556091092, 11556091092], [0, -1289072616248, -24188500476, 0], [0, 157264131766, 7736438844, 0], [-4190830519008, 0, 0, -10524727293], [1677198422382, -1677198422382, 7520671788, 7520671788], [0, 1250318981880, 18824777328, 0], [-2443872923086, 0, 0, 17682842772], [194473843648, -194473843648, 412966224, 412966224], [0, 28370542426, 25522349454, 0], [-645366171066, 0, 0, 36774859968], [0, 1389708277888, 6757360389, 0], [3633875117192, 0, 0, -26875732716], [0, 1431714534666, 24623849628, 0], [231362311376, 0, 0, 9465130215], [0, 4587882177144, 9738890406, 0], [-3657551062110, 3657551062110, 11350837638, 11350837638], [710297561328, 0, 0, -18192264468], [0, -4584427913366, -24601970439, 0], [-4084378901806, 0, 0, -34570912572], [-7298882405262, 7298882405262, -5011583259, -5011583259], [0, 1950005889552, -14370974142, 0], [-2696542251200, 2696542251200, -16573315041, -16573315041], [1443589233390, 0, 0, -70879867086], [-2984810893454, 2984810893454, 2506732830, 2506732830], [4560535193928, -4560535193928, 2603095110, 2603095110], [-1979909165248, 0, 0, 1922327910], [-871877468966, 871877468966, -15258262833, -15258262833], [0, 3402849153136, -3891875904, 0], [726607168932, 0, 0, 37287030858], [2291206452676, -2291206452676, -20237013342, -20237013342], [-2481420947290, 0, 0, 50719079502], [-2682969081954, 2682969081954, 71687354058, 71687354058], [177606901850, 0, 0, 6594449706], [0, -2188126277358, -118975405299, 0], [0, -5737589849936, 86948756037, 0], [18279168804750, 0, 0, -13540622949], [0, -605963700294, -84686374080, 0], [6061977971840, 0, 0, -58117167207], [2439438622938, -2439438622938, 74076571296, 74076571296], [0, -3091453596272, -153693946476, 0], [3188338036848, 0, 0, -89324399850], [0, -12619010332166, 97917542577, 0], [4930628584056, 0, 0, -172256388774], [-6856306761178, 0, 0, -85162865877], [0, -14270157741882, 25028733162, 0], [11185722160144, -11185722160144, 132508603305, 132508603305], [8931713356968, -8931713356968, -83837326440, -83837326440], [9076779973546, -9076779973546, -32139448362, -32139448362], [11966119995690, 0, 0, -1863070896], [5278207782416, 0, 0, 216647188002], [-11882944810464, 11882944810464, -8767193454, -8767193454], [0, -4417398149048, -42528120390, 0], [-13961767455084, 0, 0, 14609450142], [-4004817489776, 4004817489776, 102653325180, 102653325180], [-3627752081058, 3627752081058, 141533796606, 141533796606], [17110917731306, 0, 0, 76443504876], [0, 3297243568626, 222445312293, 0], [6503125749840, -6503125749840, 17500012572, 17500012572], [24162162784938, 0, 0, 21218258544], [20146411722596, 0, 0, -108115234290], [-20766598351968, 20766598351968, 3045645051, 3045645051], [0, 12006266295006, -231100101876, 0], [0, 6439282221624, -98430508902, 0], [0, 26555278971136, -105880398120, 0], [0, 24233611304770, -172188423459, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_196_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_196_10_e_f();".
// 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_196_10_e_f(:prec:=4)
    chi := MakeCharacter_196_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_196_10_e_f();".
// 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_196_10_e_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_196_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<3,R![32490000, 1276800, 55876, -224, 1]>],Snew);
    return Vf;
end function;