
// Make newform 35.10.a.c in Magma, downloaded from the LMFDB on 02 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_35_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_35_10_a_c();".
// 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_35_10_a_c();".
// 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 := [-8308, 6926, -648, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [756, 1318, -47, -3], [-34688, 7770, -117, -15], [-38656, 6038, 71, -3]];
    Rf_basisdens := [1, 118, 118, 118];
    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_35_a();"
function MakeCharacter_35_a()
    N := 35;
    order := 1;
    char_gens := [22, 31];
    v := [1, 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;

function MakeCharacter_35_a_Hecke( : Kf := Kf)
    return MakeCharacter_35_a();
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 := [[-5, -1, 0, 0], [-4, 0, 1, 0], [-625, 0, 0, 0], [-2401, 0, 0, 0], [20976, 1412, 27, 6], [-18554, -200, -527, 72], [-88282, 2368, 1023, 48], [75320, 3460, -1456, -1162], [-583912, -4444, 4816, 1782], [-348502, -7636, -7175, -4786], [-1165672, -41332, -15234, 9002], [-9778762, -202732, -21930, -6622], [14404906, 431132, -49296, 20202], [-10887124, -157980, 6468, -57374], [22670436, -781848, -179315, -14808], [-15718362, -1459584, -163490, -3388], [17670136, -1001392, -443872, -170032], [-56725174, -2209548, 494944, -99402], [-1666428, -3386280, 575144, 79864], [-116679040, 1842024, 955400, 297000], [-41125070, 1875392, 975396, 314428], [-146979716, 10401652, 242565, 96422], [-287718680, 10860272, -1330344, 67796], [-346412238, -5919124, 211592, -690206], [193925814, 11894656, 4467259, -1215024], [139259818, 5217348, 6749986, 2451334], [-551355012, -11428104, -3258511, 277144], [-983435468, 31636200, -8387366, -1267128], [338477282, -6759444, -443173, -939186], [99406162, 39906948, -5074526, -2977818], [-1167015208, -15391440, -13521792, 3957680], [-401340472, 19150388, -17358928, -2161914], [-1236026046, 105565116, 29075896, 2217122], [2955677304, -33963928, 12394170, -1777404], [829664438, -106440056, -8968808, 7548108], [-6518360052, -53357492, 4253497, 8428482], [-5093462246, -76183024, 7010524, 3512400], [-1917879148, 55884128, 7343682, 12081180], [8270527372, 33296680, 3575697, -4631896], [-8078563714, 222716640, 35727771, 11995244], [7129416548, 177619224, -65041792, 8646456], [2658785274, -208113544, 8303642, -12601508], [1881931316, -627375148, 39285151, 4138494], [-169384726, 451736444, -22650080, 18781562], [18896230918, -330419212, 136938184, 18329994], [11209142352, 157899896, -120035156, -8199660], [-170593448, -686949820, 26433985, 39778910], [13329156892, 874792448, 121593349, -8757180], [5347239892, -740840760, -38470823, -81217236], [-42789371462, 752287404, 157226696, 8427658], [12946171154, 815682104, -141054226, -51618252], [-8038725020, 230689740, 228966933, 19219618], [6206631098, 493728468, -214355326, -10520986], [26807031608, -353906152, 426571630, -25038828], [44682370122, -84753040, -1111984, 127150732], [11964976144, -1437979976, 444025250, -68936908], [9156130618, -3751733896, 196564812, 32206004], [4043203872, -733047300, 71586434, 209485338], [-39300688418, -541937760, -8342804, -203463076], [-11740253058, -3538390500, 275482457, -105517874], [-8154557996, -957251816, 22399703, 121484236], [-56427598098, -545991872, -507471097, -187224140], [-33125572788, 4079878840, -154874801, -59136956], [28237499744, -3368347724, -1212830592, -70549770], [54383457270, 3157101592, -107244887, -144515100], [-109870062490, 742691264, -1365820524, -10833348], [-131298668012, -2738274712, 907146208, -362519344], [-135377237534, -5418052608, -75617020, 251078216], [-49501050228, -3142811020, 633364292, 385026354], [-214701161014, 6898024188, 1334242690, 173268122], [-149208401810, 8301452232, -587216425, 46211332], [250580101528, 2104716424, 247699672, 343885192], [240527820428, 6291626488, -555807395, 239067136], [-335660203626, 129166524, 751500080, 20152038], [77789983524, 7176037912, 131228512, -619754272], [-6631021752, 13255137176, 870671560, -339985292], [14896497754, 8038904092, -504142569, -782768554], [-289026842498, -68959800, 326455391, 67525576], [290385179310, 3892794364, 2923383795, -292406970], [117843721970, -10034924520, 4424600688, -26131852], [15302482504, -6719739088, -1552434572, 26683936], [23526141554, -13947458204, -2000191049, -46441526], [369807344428, -9477853332, -3702283169, 263061242], [-210555863470, -14393299448, 2197985816, 104343920], [721505802064, -1958222968, -571998506, 804710420], [-318833477196, 7514579844, 2256282348, 1211516250], [-300997028906, -7770126868, 415320669, 1406040550], [-391149967134, 20734491732, -470056648, -354920066], [178822262370, 7302426264, 7486256742, 67329020], [350104680784, -24947946996, -1344379142, 102242834], [3400906972, 7279722760, 714302011, -1496727940], [37292854832, -65805211244, 1976878136, -493502826], [577836322312, 19948290760, -2371256990, 3365760452], [9414657200, -42099818196, 5131028985, 1969203626], [-197850630576, -4620319308, 2573397335, -2783669506], [693090986364, -35256427616, 1578437363, 1344432132], [43413514, -17101263728, 5163768320, -813859704], [747949134162, -29781995020, 3704388442, 590888126], [461676539984, -20461294856, 11413943612, 126299640], [-211373471534, 74426445532, -2663486735, 49394270], [-619504902644, 12558398252, 9475727002, -837250874], [-978477582194, 24707065232, 5375017906, 3704401924], [1290391969872, 18190873928, 3309623004, 449298728], [-2669177228582, -11601400336, -5715466720, 69418536], [-48242184508, 34945456240, -7971731332, -6707244], [-733428621562, 33899913928, -10722601787, -6116485868], [-1085156836456, -45191027984, 13086760700, 1593715244], [-849944706922, 11355561416, -10130108163, 3688081620], [-1725407386100, 88097324700, -18187581025, -2322586990], [-1052155784614, 49572669232, 170355628, 5614239168], [1178279746900, 22281735984, -980641949, 1982921100], [-822166018874, -66356360040, 26508684, 6069910584], [158067467562, -41209338200, -3799776548, -3017314236], [1449515287488, 15154028044, -1286618644, 3802290586], [680877132092, 41621644340, -16404670221, -4489439034], [715219721218, 27956092528, 1366806184, -2076004376], [-696701833476, -97739869056, 28064271865, -4375909160], [-133006242000, 38404472024, -1273621092, 2198481204], [-471126028338, 54737403868, -20285595022, -3351338490], [-1149565403848, -24263854804, 10791658491, -8397474030], [-1534805350446, 61594139216, -2948702174, -1286026896], [-1393696875814, -14292761700, -7706732336, 11726940146], [1676628504350, 25581060864, -24009617235, 3767239844], [2647505874748, 110608218516, -15939617098, -3627751326], [-383152436176, -18285987784, 33647704216, -5724094956], [8134796567882, 19342079100, 2904784173, -6586928698], [518236131938, -171900940556, 20883133349, 3923074362], [-1043106972560, -65912358660, 9788425860, -9114927950], [-6483002513056, -22315649864, -11535594244, -12563214684], [-4501726339698, -108567813832, 10851117613, -11343142528], [3777961402536, -21113368332, -2691223253, -8068464962], [-8258030834048, 119042792968, 42193216920, 6019696172], [-1710012752172, -84376841292, -64225560915, 10854851990], [-3278302122770, 197731909144, -22975482858, -11023398128], [8866882368354, -22895997364, -40534066658, 6358956994], [-1454213510694, 57431985488, -34250310684, -7597580688], [6156862292758, 63795684136, -20550317103, 9574674072], [-4156550692956, -11759657344, -67652297483, 5694716664], [-6419646081970, -230230054496, -47133195605, 8081460556], [10265734526934, -63169708228, -11104368773, -5784197898], [-3013011664096, 452330836816, -12551658614, 8358172904], [-3168181710478, -166271678540, 70086782067, -20918749070], [815222022248, -12666107444, -26839305978, -16416838894], [-3759176728620, -87992091456, 65000269502, 6613901700], [-2228065956070, 366784371340, 61339123976, 7284351338], [3407901847864, 90342369412, 25799105508, 20511575462], [9867800655778, 40394804016, -66022666836, 10292557776], [3560427420410, -327661660856, 88226346800, 1501360944], [-7964853074112, -486432251216, -53185281164, 5209447352], [-4808021821728, 352689731308, 13119710978, 12434018106], [-2246256577170, -126311609796, -16521218150, 13821344774], [-3934300819430, 8777015384, 108183719150, -28287975596], [4741703107268, 968742290916, -33766670406, -5931798494], [-1663204306896, -184832624704, 37515464560, -10777445928], [-9143159040444, -440053180868, 54335843156, 9214995646], [-3604207427408, -254463310240, -148946921372, -4987835156], [-6852190117180, 359548878620, -67642244163, -11630407542], [7449619749506, 630068289328, -45986757370, 41916864832], [8404993578726, 409909651752, 40824727239, 17659666292], [11691970002618, -255435909772, 18024147944, 14421394038], [-10602879135988, 122842332980, 7131122606, 13362480314], [-15733623154238, -332176066772, -170400712204, 14149702962], [-7310686273816, -92944689344, 140551464346, 40077446528], [13798427037000, 888098821324, 36021011794, -6962057414], [1154345488338, 1058164536388, 75817407066, 13803026150], [-579555327804, -878590757040, 142651381355, -3377940660], [-30042944016200, -128513675656, -96264180528, -9932420480], [11439596545038, 236951886128, 32993597023, -44981907556]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_35_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_35_10_a_c();".
// 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_35_10_a_c(:prec:=4)
    chi := MakeCharacter_35_a();
    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_35_10_a_c();".
// 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_35_10_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_35_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![559840, -18088, -1708, 19, 1]>],Snew);
    return Vf;
end function;