
// Make newform 14.8.c.a in Magma, downloaded from the LMFDB on 25 November 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_14_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_14_c_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_14_8_c_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_14_8_c_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 := [356409, 597, 598, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [356409, -598, 598, -1], [-356409, 714610, -598, 1], [896, 0, 0, 1]];
    Rf_basisdens := [1, 357006, 357006, 299];
    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_14_c();"
function MakeCharacter_14_c()
    N := 14;
    order := 3;
    char_gens := [3];
    v := [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_14_c_Hecke();"
function MakeCharacter_14_c_Hecke( : Kf := false)
    N := 14;
    order := 3;
    char_gens := [3];
    char_values := [[-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 := 8;
    raw_aps := [[-8, 8, 0, 0], [0, 28, -1, 0], [119, -119, -2, -2], [14, 56, -14, -21], [0, -2924, 7, 0], [658, 0, 0, 196], [0, 23821, -260, 0], [20524, -20524, 243, 243], [24658, -24658, -847, -847], [86410, 0, 0, -868], [0, 35126, 3457, 0], [44083, -44083, 10962, 10962], [-578130, 0, 0, 924], [28772, 0, 0, -8064], [706146, -706146, -10215, -10215], [0, 1180587, 1890, 0], [0, -921256, -15541, 0], [-639121, 639121, 30350, 30350], [0, 1060740, 46823, 0], [1800080, 0, 0, -14168], [0, 817341, 50252, 0], [4596302, -4596302, 8141, 8141], [-14140, 0, 0, -68936], [-4468275, 4468275, -42324, -42324], [2937102, 0, 0, -32284], [0, -9546145, 43910, 0], [-8141966, 8141966, 211041, 211041], [-2885928, 2885928, -161217, -161217], [0, -3155829, -317758, 0], [2781214, 0, 0, -453628], [-9311384, 0, 0, 161560], [4298168, -4298168, 638839, 638839], [0, 35780873, -174328, 0], [8048796, 0, 0, 444584], [8208351, -8208351, 666918, 666918], [0, 927810, -710563, 0], [0, 22055719, -614034, 0], [-401600, 401600, -1105713, -1105713], [-59469956, 0, 0, 461468], [72450959, -72450959, 92734, 92734], [0, 5471496, 1135659, 0], [-68785682, 0, 0, 1741264], [-85784310, 85784310, -1294335, -1294335], [0, 35938765, 2032380, 0], [-30122062, 0, 0, 1217356], [0, 2885890, 1065021, 0], [-189926476, 0, 0, -1337784], [125957384, 0, 0, -3263400], [0, -41268024, -535221, 0], [15734943, -15734943, 1788694, 1788694], [-53071343, 53071343, -1041208, -1041208], [-23293380, 0, 0, 3352020], [0, -89835767, 4402152, 0], [53476080, 0, 0, 380100], [32571861, -32571861, -548004, -548004], [0, -105999066, 2603937, 0], [0, 147947135, -5422810, 0], [86791670, -86791670, -2372827, -2372827], [0, -377113973, 5646018, 0], [443592326, 0, 0, 1513204], [0, 102665388, 2393663, 0], [-590913330, 0, 0, 2686656], [-146057604, 0, 0, -1679776], [0, -433857466, 5712545, 0], [316763349, -316763349, -3625820, -3625820], [-138025065, 138025065, 5972358, 5972358], [94093948, -94093948, -4789029, -4789029], [-104044778, 0, 0, 212044], [0, 614060904, 871899, 0], [-559058262, 0, 0, 6688892], [0, -923573763, 4831980, 0], [-501938314, 501938314, -9609635, -9609635], [0, 1209674410, -10089003, 0], [-799627629, 799627629, 8646946, 8646946], [101850408, 0, 0, 16063628], [-795793502, 795793502, 25166825, 25166825], [0, 288707183, 9008342, 0], [1516421459, -1516421459, 3861674, 3861674], [-146907939, 146907939, -20558748, -20558748], [0, 479345377, 33211968, 0], [2101362060, 0, 0, -7744800], [-1280070902, 0, 0, -25060364], [0, -1985388522, 6151425, 0], [-1685117266, 0, 0, -7942284], [949642190, -949642190, 16551701, 16551701], [1889402008, -1889402008, 819791, 819791], [187656646, 0, 0, 63538412], [-463092003, 463092003, 48646444, 48646444], [1059946762, 0, 0, -59344852], [-1183046352, 0, 0, 20768384], [-2250738280, 2250738280, 17833639, 17833639], [0, -1585524038, 60243973, 0], [0, -1967102618, -8747487, 0], [-1907592552, 0, 0, 1018668], [-2824347480, 2824347480, -51745673, -51745673], [3977048880, 0, 0, 29926680], [205750083, -205750083, -41530806, -41530806], [0, -1389966795, -36925596, 0], [2079097720, -2079097720, 23274879, 23274879], [-787599277, 787599277, 63132314, 63132314], [-4131131576, 0, 0, -45061436], [0, 2098865099, -110783806, 0], [0, -1457042468, 68114143, 0], [-2287598379, 2287598379, -59810268, -59810268], [0, 188269244, -120752177, 0], [0, 4195013025, 44263904, 0], [-3534649132, 0, 0, -88092368], [-2404352811, 2404352811, 81786444, 81786444], [0, 262785462, 21653457, 0], [-1143580522, 0, 0, 36590820], [1134784322, -1134784322, -89806999, -89806999], [0, 1190498087, 104519086, 0], [808348046, 0, 0, 114095548], [0, 5095216392, -120362341, 0], [-8137716256, 0, 0, 28363944], [0, -1342907375, 81553360, 0], [5715647756, 0, 0, -42366912], [0, -4274130546, -107838711, 0], [-742261425, 742261425, -36292578, -36292578], [6058493828, 0, 0, -80070536], [0, -2242360365, -134104342, 0], [7960058822, 0, 0, 10970316], [-3277830129, 3277830129, -90507930, -90507930], [0, -443428116, -207537057, 0], [-2356208288, 2356208288, 106492671, 106492671], [-8794068890, 0, 0, 88300688], [4039107139, -4039107139, 88996194, 88996194], [-1473343242, 1473343242, 55476069, 55476069], [-6532514352, 0, 0, 61607000], [-8985760105, 8985760105, 22035494, 22035494], [0, 1305232952, 118507963, 0], [-2009339904, 0, 0, -47583144], [2712313874, -2712313874, 187646249, 187646249], [12248143714, 0, 0, 31333036], [249151777, -249151777, -179615704, -179615704], [-3725648010, 0, 0, -246225028], [0, -3755849377, -153567226, 0], [0, 21230689844, 20248759, 0], [-13078882950, 0, 0, -134764308], [0, 2891949965, 178390940, 0], [-2926213836, 0, 0, 292906544], [-13141341545, 13141341545, 24020654, 24020654], [0, 14773814694, -206551807, 0], [202285764, 0, 0, 211883280], [0, 418134339, -234203110, 0], [-6211994824, 0, 0, 222901504], [-4323911158, 0, 0, -29478204], [0, -295164891, 497715924, 0], [2092833064, -2092833064, -656366433, -656366433], [-15264687658, 15264687658, 294751765, 294751765], [6532726827, -6532726827, -18065390, -18065390], [5129168226, 0, 0, -692359248], [3712115780, 0, 0, 206439576], [37112055750, -37112055750, 2310621, 2310621], [0, 6003411920, 8200675, 0], [-19150702800, 0, 0, -338682624], [16581856638, -16581856638, -428874299, -428874299], [-3536054151, 3536054151, 443987976, 443987976], [9419103722, 0, 0, 330897840], [0, -10585848553, 410266142, 0], [13813893440, -13813893440, -746805857, -746805857], [-12838147978, 0, 0, -210216860], [14035142816, 0, 0, 47116440], [10380784764, -10380784764, -115450533, -115450533], [0, -29403944715, -250761084, 0], [0, -882982926, -947773107, 0], [0, 19549319722, -268892043, 0], [0, -21006212549, 675939186, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_14_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_14_8_c_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_14_8_c_a(:prec:=4)
    chi := MakeCharacter_14_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 8));
    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_14_8_c_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_14_8_c_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_14_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,8,sign)));
    Vf := Kernel([<3,R![2576025, 89880, 4741, -56, 1]>],Snew);
    return Vf;
end function;