
// Make newform 69.6.a.c in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_69_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_69_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_69_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 := [20, -30, -39, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-4, -36, -1, 1], [-42, -40, 1, 1]];
    Rf_basisdens := [1, 1, 2, 2];
    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_69_a();"
function MakeCharacter_69_a()
    N := 69;
    order := 1;
    char_gens := [47, 28];
    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_69_a_Hecke(Kf)
    return MakeCharacter_69_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+1)]];
    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 := [[1, 1, 0, 0], [-9, 0, 0, 0], [-29, 9, 3, 1], [14, 34, -3, -4], [19, 23, 22, -19], [330, 76, -22, -12], [124, 158, 109, 8], [725, 13, 19, 101], [529, 0, 0, 0], [-1298, -592, -6, -316], [-176, -936, 542, -292], [931, -595, 188, -477], [-4180, 1170, 472, 134], [6319, 951, -61, -181], [-6844, 1852, -668, -488], [-8101, 2273, -199, -27], [-14266, -2710, 2036, 162], [9137, 51, 352, -1683], [19641, 3033, 2553, 877], [6386, -8430, 556, -1042], [30086, 1284, -1084, -756], [23538, 3390, 1991, 460], [8305, -3539, 2314, -1881], [-4846, -12740, 4271, 1102], [7724, -11646, 7158, -1182], [3798, -384, -8612, 2568], [58432, 13028, -3297, -282], [94653, 513, -5154, 3123], [-68107, -5233, 6242, -851], [2542, 12288, 5795, -3326], [-106992, -3336, 2374, -8780], [69670, -37558, 11328, -6514], [-126952, 22058, 6147, -3936], [-84548, 24256, -10380, 208], [-61369, -47195, -3233, 3013], [127332, 43052, -12400, 7628], [-40313, 31225, -1068, 2887], [76578, 9030, -17886, 7750], [9254, -38522, 26336, 1594], [-239626, 61544, -12198, -3492], [210840, 63396, -43224, 7944], [87941, -28937, 13782, -2011], [30454, -94690, 17570, 1190], [-145712, -66682, 1398, 13218], [77416, 20954, 15362, -33622], [2286, 24602, 19311, -19360], [814082, 24030, -8862, -4890], [142608, 120144, 9928, 6448], [-543785, 41259, -40800, -10523], [-304635, 160183, 16346, 6597], [-304994, 76084, -13152, 5412], [-230268, -177052, -6588, 10828], [-535628, -74886, 91706, -39286], [954273, 49821, -41352, -2901], [-362708, 115658, 4316, 470], [-1053128, 261656, -20086, 40844], [1876, -171938, 40482, -7866], [-422660, 6676, 92418, -19232], [860992, 165034, -27092, -20354], [-353402, 31144, 23959, -81606], [720171, 182611, 82289, -6333], [-835185, 95517, -63347, -7767], [1102062, 39410, 58814, 58922], [927566, 139958, -32644, 65862], [462492, 150962, -188872, 89942], [-795738, -188760, -56886, -95340], [1182986, -548418, 52642, -15330], [-279182, 241736, 79078, 87948], [1742932, -39432, 6420, 12364], [1225376, -448926, 32778, -77634], [-1388858, -115284, -142206, 43168], [1467998, 153966, 64486, -107842], [91526, 534898, -227649, 129656], [-943685, 154325, -65396, 39867], [-544963, 27765, -119185, 155973], [-2054232, -262384, 4782, -143948], [1223121, 240447, 7589, 132567], [-1848306, 99696, -88592, 67168], [-1803736, 185914, -189535, 210964], [-4127860, 268074, -98602, 72054], [1720021, -460783, 160890, -55021], [2455667, -359675, 211846, -21865], [-1139626, -194890, 241172, -59670], [-2467596, 102626, 127580, -33370], [-2359504, -69640, -262192, -25904], [-3655812, 38520, 109812, -18384], [3142312, 726134, -200480, -102934], [565008, 481774, 337814, 39438], [-616732, 356494, -18202, -57674], [2014336, 55616, 180364, 134040], [6153353, 239357, 123636, 65811], [1854412, 844444, -317304, -95700], [1297836, -82956, 187720, -305828], [1798708, -244360, -344252, -66604], [3947650, 530566, 300306, -93146], [1855354, 170354, -489152, 149462], [3089574, 124392, 303998, -44964], [167748, 635646, 251715, -59388], [-5722339, -599947, -54403, 889], [1497800, 887834, 284450, 296734], [-5029366, 129574, 38098, -201634], [-1471763, 70691, 80241, 69083], [-1751809, 1935955, -223160, -45971], [-1046624, 508114, -790787, 406380], [4744673, -706735, -170467, 276253], [-4056300, -987502, 394318, -36658], [-2043030, -543402, 56832, 263442], [-6278384, -1411522, -199844, -100582], [898672, 695032, -386580, 125544], [3813468, -441790, 73174, -158530], [-10875108, 1255644, -24460, 108196], [-708111, -1681141, -22188, -220699], [-1062358, -1884140, 374035, 26206], [-942733, 583427, 146309, 97243], [-7370364, 685712, -268333, -420526], [-2576424, 646906, -281643, 274268], [-6781513, 1441447, 210531, 234299], [1424674, -645094, -149136, -263422], [4412434, 963108, 447468, -284276], [7848133, 613113, -449620, 416599], [-1526195, 1331063, -216544, -515631], [5770700, -19606, -782302, 253750], [-6343005, -523071, -876777, 117705], [2977914, -714938, 1027700, 13898], [-4528398, -709602, 539678, -420194], [10385677, 2798219, 968359, -403465], [6599951, -1703631, 175966, -629229], [3200614, -1806490, 602216, -343354], [-6066270, -1886642, -1038787, 116736], [3368027, 873829, 127562, 768479], [-4693820, 11080, -590524, 666256], [-2181352, 2598376, -745626, 157948], [-3618476, -3097088, 440261, -427154], [-46767, 2943939, 284702, 720937], [8062406, 45364, -662894, -332216], [-5017992, 610294, 1114688, 466050], [-4441295, 3260559, -55261, 446035], [280763, -4251813, 104715, 585159], [12226257, 1085583, -1055651, 783567], [-7838718, -3026640, 2159738, -281244], [-3437094, 2394302, 1260926, 94190], [11655922, -1444660, 557872, 692276], [-5495144, 570984, -10774, -1301572], [2761673, -2202875, -1548124, -514757], [6289924, 2109462, 396386, 34754], [-602772, -2521236, 1555638, -1326768], [7183534, -1813896, 694496, -725032], [-3853398, -2228256, -511628, 58224], [-5620444, 2679312, -660132, -757008], [30146126, -14786, -620976, 380086], [-8012996, -2244706, 638952, -1199694], [-12847114, 521776, -1025921, 1390978], [-4874210, -5667478, 648862, -177558], [-27420788, 1837724, -600856, 519896], [8249459, 505307, 596645, 545539], [-16719410, -1532002, 2148160, -851782], [9621502, 2832570, 295547, 727592], [12881248, -2644786, 1009496, -1110022], [15780258, 196232, 978340, -498880], [6083295, 4255389, 1773995, 1062909], [5798620, 1097688, -1998568, 1707412], [-4776244, -5881650, 1035345, 1132568], [13333612, -2951220, -2316046, -783424], [-10824497, 486443, -2170532, 89213], [1035408, -4813230, -1690705, 678168], [10044890, -5467454, 639224, -1088426], [-15718372, -923740, -229294, -351104], [-2670152, -2939102, 2206818, -147266]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_69_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_69_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_69_6_a_c(:prec:=4)
    chi := MakeCharacter_69_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(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_69_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_69_6_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_69_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![12, 44, -33, -4, 1]>],Snew);
    return Vf;
end function;