
// Make newform 196.14.e.a in Magma, downloaded from the LMFDB on 04 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_14_e_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_196_14_e_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 := [1, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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, -1]];
    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 := 14;
    raw_aps := [[0, 0], [-468, 468], [0, -56214], [0, 0], [6397380, -6397380], [15199742, 0], [-43114194, 43114194], [0, 365115484], [0, 57226824], [-46418994, 0], [5682185824, -5682185824], [0, 1887185098], [-7336802934, 0], [-26886674980, 0], [0, -101839834224], [-278731884294, 278731884294], [-59573945772, 59573945772], [0, 27484470418], [-784410054932, 784410054932], [-360365227992, 0], [1592635413718, -1592635413718], [0, 23161184752], [2050158110436, 0], [0, 3485391237126], [6706667416802, 0], [-10653736099446, 10653736099446], [0, 10924465533496], [0, -12587565522204], [436641848098, -436641848098], [-31831198952526, 0], [39407680341632, 0], [0, -73744029229140], [-85410026296938, 85410026296938], [-79782728036164, 0], [0, -189340621038054], [-283931821277240, 283931821277240], [-27493181043278, 27493181043278], [0, 374651855577100], [126476544252168, 0], [0, 362732128582626], [317214254387772, -317214254387772], [455668962760070, 0], [0, 966029530347072], [182063056758334, -182063056758334], [862598124343638, 0], [-324819447518888, 324819447518888], [-703122653862556, 0], [1508649743016800, 0], [-2503060674367284, 2503060674367284], [0, 1221116802675466], [0, -3537908036396874], [-3112798054881744, 0], [4570914891142606, -4570914891142606], [-1663317001905300, 0], [0, 3740522836521726], [-2506157776421352, 2506157776421352], [81129982670082, -81129982670082], [0, 2291408802506800], [-998960307482726, 998960307482726], [-11758003102314054, 0], [-3812373638412044, 3812373638412044], [18983079522948150, 0], [15202097546210372, 0], [-19648629162159192, 19648629162159192], [0, 19994252842377382], [0, 24456461290397586], [0, 33992443483613572], [-2887183035494638, 0], [-33601121683234380, 33601121683234380], [-19052688341090290, 0], [68547375932093982, -68547375932093982], [0, 11515414775891256], [943078961967952, -943078961967952], [0, -27434453204114246], [65132658943109612, 0], [0, 87834445767126144], [40928249341090026, -40928249341090026], [0, -25377606630246782], [0, 81198461546163630], [-156903059661641786, 156903059661641786], [-19165867577647884, 0], [22062861443818166, 0], [136346835968196624, -136346835968196624], [-43494919999192078, 0], [0, 208497563333221672], [0, -249282611233714476], [145109873387955906, 0], [0, 198127166900027734], [-230381995342550850, 0], [364296360673153424, 0], [0, 21717482203717020], [198718990347079584, -198718990347079584], [-471597862471979336, 471597862471979336], [-114636339459987300, 0], [0, -12879360668887556], [-272812154344161768, 0], [0, -408824236278402606], [468975502839432726, -468975502839432726], [0, -612358729613548604], [0, -468270288292416974], [1116108302757722996, 0], [278972996588388450, -278972996588388450], [497446108616742588, -497446108616742588], [0, -1156535003004963930], [-88014962752765868, 88014962752765868], [154048129795441342, -154048129795441342], [1461113904643961724, 0], [0, -1323717200623180818], [1543250474746700040, -1543250474746700040], [266564324178438650, 0], [0, 1032813282165950752], [451541280745588618, -451541280745588618], [-1868698635269928246, 0], [1237237618430421220, -1237237618430421220], [602949442486809752, 0], [-2687833301629079682, 2687833301629079682], [-1922605140695672236, 0], [-1548294892937413992, 1548294892937413992], [0, 2118678527719586178], [-1713757470500782044, 0], [339226139764007962, -339226139764007962], [19960663323281954, 0], [0, 3267444788377428042], [-980130018496892508, 980130018496892508], [0, 2721452079908411452], [587143117623057390, 0], [0, 3678038066296362154], [0, 2246089731903594864], [6280820086726448504, 0], [0, -5840677960868928398], [6402491090486212300, -6402491090486212300], [6617169652386922056, 0], [0, -1097599476209942576], [-8916992483146692922, 0], [0, 8551667918713393638], [-3404202799496751358, 0], [-4271867214173115030, 4271867214173115030], [2010200967685144924, -2010200967685144924], [-1681311643363833138, 0], [-8897418238258646154, 8897418238258646154], [7391518821461146844, 0], [0, -4725754002670149126], [-2480898418352227928, 2480898418352227928], [-10202605667477005140, 0], [7916032028703180178, -7916032028703180178], [-13707611597228931288, 0], [9046006856817082790, 0], [-5969414824479999738, 5969414824479999738], [0, -10355010557739735116], [0, 3959227035493399584], [0, -4384031090314337246], [-4000583698570364238, 0], [-9474501965671045756, 0], [0, 12210143957657149032], [-3273050939281057724, 3273050939281057724], [25069385557117868112, 0], [0, -5265471710300882744], [0, -1827193373979186978], [37261453685003018, 0], [-40875511169879907102, 40875511169879907102], [0, 25048939926347127612], [28898055405610176474, 0], [39569284620897394088, 0], [0, -15385483855769992956], [20046487543543693422, -20046487543543693422], [5840067887528590728, -5840067887528590728], [-32168704058142394976, 32168704058142394976], [-2941734610476942326, 2941734610476942326]];
    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_14_e_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_196_14_e_a(:prec:=2)
    chi := MakeCharacter_196_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 14));
    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_14_e_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_196_14_e_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_196_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,14,sign)));
    Vf := Kernel([<3,R![219024, 468, 1]>],Snew);
    return Vf;
end function;