
// Make newform 975.6.a.c in Magma, downloaded from the LMFDB on 05 January 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_975_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_975_6_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_975_6_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 := [-14, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 2]];
    Rf_basisdens := [1, 1];
    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_975_a();"
function MakeCharacter_975_a()
    N := 975;
    order := 1;
    char_gens := [326, 352, 301];
    v := [1, 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_975_a_Hecke(Kf)
    return MakeCharacter_975_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 := 6;
    raw_aps := [[2, 1], [9, 0], [0, 0], [-36, -11], [-298, -42], [169, 0], [134, 106], [564, 73], [884, -168], [-3806, -84], [-2080, -817], [-8734, 742], [-14000, 521], [12164, 1150], [9054, -2164], [-710, -804], [3394, 5336], [-18574, -1612], [-53056, -1595], [-15230, -4830], [18810, -6986], [-1080, -6716], [-103502, -476], [-37068, -11273], [60578, 2786], [45562, 16226], [-47408, 11494], [38040, 4732], [43242, -19516], [105138, -6260], [-169584, 11330], [-62128, 25704], [174640, -9881], [189364, 19684], [146844, -4901], [205824, 26229], [293770, 5808], [-98572, -42527], [63686, 20852], [337662, 13490], [17916, -67792], [-464338, 42840], [50888, 83152], [3798, -96596], [406768, 60879], [-170192, 117526], [-89892, -69672], [-87248, 177933], [205038, 62290], [-138806, -8348], [-493078, 16278], [190738, -6798], [-557754, 46610], [1565928, 1812], [-25078, -186830], [40212, -55812], [-1051422, 115644], [-709460, 147523], [-4798, -106488], [-174816, -11239], [-292956, -147306], [-1449420, -30479], [-710416, -43405], [-776196, 49600], [-630438, 334248], [-466296, 53559], [-471144, -123689], [-1118350, 325276], [204460, -177124], [-1093778, 48118], [-771056, 128535], [-568374, 146820], [-547896, 324408], [-1281754, -178152], [-3810644, 5925], [-858358, 304536], [-1525514, -451830], [-2719070, 159894], [-34764, -47269], [-1045122, 311406], [-2839312, -221392], [3632666, 209636], [-6457994, -68432], [4559674, -219268], [-133416, 358218], [-3580288, 415188], [5435964, -295849], [-23854, -360458], [1214080, -15427], [-1309604, 529209], [4803760, -338796], [38254, 208546], [-518304, 1111457], [-4439552, -616732], [-1781544, 139423], [7610092, -200624], [872288, -425147], [-2370362, 12820], [-3869660, -52660], [9410266, 294072], [-2243628, -868772], [-13404996, 101821], [9896356, 24660], [964934, -1355058], [974788, 937614], [132574, 1608972], [689850, 916068], [2139588, -15507], [838932, 682952], [-6030794, -141136], [-3222776, 886236], [-3212982, -1745306], [-3787352, -1230185], [3441976, -363163], [9375480, 996085], [-7982678, 595582], [-3097472, -689099], [4893120, -446236], [7566190, -1214840], [-4559196, -1670932], [4192446, -1799562], [-4104858, -1451584], [-5126734, 196336], [13985066, 90150], [-20043320, -605729], [14290166, 535890], [-13821390, 128000], [5448692, -2266740], [6962704, 163490], [-3482770, 1153240], [10037072, -164239], [2065502, -2001258], [15341800, 717990], [8202318, 2130876], [-12099552, -837627], [-16219686, 1159944], [9673700, 1385881], [-8952320, 428711], [-11859918, -300262], [-6201402, 2273276], [-9394252, -600427], [8615668, -694909], [19578136, -1048638], [-1093598, 2905290], [67290, -2442956], [8398334, 235918], [4917458, -3391054], [10412186, -449254], [22264428, 213332], [-7154614, -2525444], [-23449886, -2125406], [-8351714, -61970], [-27943764, -703618], [-18684152, 2083812], [-10074004, 3377082], [1485640, -1390812], [2256112, 3629252], [636752, 2106649], [-17076710, -2916772], [2374924, 3455183], [19468486, 1663788], [-5402462, 3766598], [11730248, 677957], [25600852, 3561428], [18319564, 1433269], [-31097758, 296822], [30001072, -2826188], [48466314, -356128], [-31636106, 2152494], [41001502, 349838], [15805394, 850542], [-15499890, -1204574], [-23525364, -2567900], [23409138, 3691730], [-26052496, 282206], [-27208846, -3812440], [-31193384, -1513179], [25783180, 1336847], [28962640, 3173622], [2003922, -5237264], [8746852, -5491471], [-5841220, -9164216], [26134302, 3115876], [-1011308, 4221441], [-16867994, 2791100], [-11686186, 4361714], [-27593478, 121312], [-20690396, -1092813], [-37932218, 1915894], [-20844454, 6605828], [-35668546, 399616], [35524746, -6475824], [-25429028, -3052336], [-6801812, -1317901], [12923404, -8039448], [10040738, 267526], [-6189502, -8428940], [-50969826, -3314744], [28059948, -6992479], [15138112, 9193552], [-13335088, 2714933], [-19609184, -5550876], [-18297682, -3155664], [20321538, -5081592], [9319954, -1276748], [-1988286, 2420336], [-95291304, -2336565], [2586600, -4956648], [41010300, -2151209], [-78092764, -744310], [8251098, -8877556], [-75557370, -3609368], [58878776, -4963968], [84602234, -4417698], [-51049090, -5098820], [-39287678, -2634216], [14053512, -13180376], [11453098, -2897220], [-125494682, 290486], [3737284, 17282049], [-49079354, 6168448], [39307436, -9084717], [-11814196, 16654475], [-19666064, -6532135], [-32012960, 14926488], [-3937498, -9548748], [5959054, -10953984], [61390276, 3158604], [-9828144, -2768378], [61260274, 8069600], [37601946, -145568], [-22051100, 14889600], [1158740, -5062655], [-24722478, 11965230], [14071932, -10393448], [-35872402, 7531478], [-57877018, 4127126], [55579316, 1514365], [-25533940, 7916184], [51599632, 1306732], [-5698822, -5232732], [94616204, 6264094], [51221584, 3769460], [-59234730, 1465114], [9646140, 1818349], [73281884, -10947344], [-13452348, 9256209], [2409770, 3009640], [-20266404, 4757241], [8831660, 6287316], [8291526, 11751944], [129255760, -6045735], [-103406670, -11786666], [74209590, 7602956], [-82826106, 1815320], [-1273274, 11733218], [60761018, 2089160], [-35347164, 6727711], [-27703606, -6688738], [-43492194, 1671344], [-46870176, -3099946], [-97118436, 6634604], [-144444350, 2612132], [31094770, 3091336], [-63479436, 16784025], [148475940, -2413184], [-30862872, 15262425], [74021472, -15262343], [91126040, -1830961], [20076438, 14293614], [-5195046, -20221168], [-826976, 11403929], [43244818, -15990994], [-14847352, -17267646], [-58276078, 24598072], [47438828, -22645877], [44648494, 9614894], [-140496234, 12896834], [134360882, -8983132], [138277024, -15219292], [-151346488, 5626816], [55443300, 14025711], [5733056, -12358440], [-99483370, -3434218], [-133579968, -21233213], [203678704, 5570628], [-216427942, 3593764], [-29913564, 7189253], [-239507528, -5266747], [107296742, -1127486], [68563414, -7084568], [122144100, 17916108], [-151902756, 21890317], [-6580406, -22553736], [169025498, 6633264], [-100720922, 5169638], [5013936, 9641400], [5275914, -37515330], [-152067268, 7291692], [54981584, -14566565], [92308870, -14102008], [85593272, -34806429], [117360344, -14995970], [50476340, -29678368], [-9167132, -21716560], [4114290, 10987110], [212017628, 3658604], [-20412770, -2956552], [-276470882, -2638702], [-83853586, -4563092], [-169393396, -9518268], [-3233024, 24843009], [36527062, -1351596], [-131223228, -5610932], [226218270, 11660712], [-74317930, -20622752], [37079098, 5136678], [36065886, 30143704], [-300677174, 206270], [-90746094, -35701722], [-298606372, -7812726], [-40377818, 17244092], [-345418010, -5828660], [86581976, -4608357], [117110116, -1020007], [-119214938, 17709252], [280358188, -8855041], [43909736, -43607315], [325267168, -2254060], [-218465298, -12813000], [319596338, 12317040], [90898854, -33281016], [-91898576, 33197536], [389246698, 6308998], [-187601236, 6578605], [140384202, 32265248], [60112278, -34241238], [-319156072, 5232159], [-43990114, 19449786], [-72555816, 20691942], [29283650, -38122998], [-232879446, 11449136], [14260092, -8867433], [-92773560, -26528810], [171553720, -12209661], [-123359220, -12618820], [89503210, -10116960], [-30490276, -29862331], [189063938, -15536420], [-77348198, -9084142], [275731712, 20737371], [225958618, 40139206], [410793252, 14684207], [244413072, 12310670], [215451234, -33114256], [-271926382, 29468228], [-65170598, 14754028], [-229279534, 15267186], [104844658, -46737650], [48624658, 28142736], [-421354726, 7885218], [-113087446, 20538178], [-151205428, 23163976], [-341919902, 799122], [-251358596, -32655410], [248836814, 24540720], [-118806408, -5592825], [294293248, -24508825], [-247959262, -7157304], [-138826608, -16057316], [-141850404, -46770550], [-152624890, 23069016], [60664942, -23522236], [-50641984, 51021236], [528642018, -13643296], [23461094, 13585880], [-120055752, 33338044], [-29222962, 13050748], [-1344262, 91628], [128113790, 28388452], [141713844, 36067619], [-343983768, -25576965], [390773948, -30473031], [-356663548, -1970463], [61505164, 53027399], [-167214774, -25205634], [106087852, 16208457], [526419454, -19117644], [144900380, -15387237], [98571004, 1341128], [81474598, -8223882], [48654532, -21519507], [387355566, 6051614], [-171405252, -18358380], [38304194, 8611772], [146778482, -32645308], [-261889076, 17852457], [17941882, -46214142], [105124588, -24226020], [-11056840, -64660511], [402404678, 33335702], [347440158, 6062122], [-265557332, 45062581], [264520588, 15125813], [188617176, 20176001], [131213128, 15043708], [203178350, -14190232], [421371988, -22677725], [-456432808, 37907003], [-342266802, 29430554], [102509774, -41303000], [121547890, 73089136], [-399266548, -10923948], [-213636348, 17168926], [-120460706, -15864508], [666005862, 6107432], [326282234, 18630090], [373249416, 4342580], [251515684, -40799571], [-208677172, -38888636], [198144250, -27408598], [180070474, -82257742], [-125905866, 47095074], [102118800, 7786872], [-122177314, -19082444], [259279532, 8472369], [-102341832, -34708828], [-226554732, 76208563], [491250724, -44187893], [18828760, -103316340]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_975_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_975_6_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_975_6_a_c(:prec:=2)
    chi := MakeCharacter_975_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 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_975_6_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_975_6_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_975_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![-52, -4, 1]>,<7,R![-5480, 72, 1]>],Snew);
    return Vf;
end function;