
// Make newform 1350.4.c.ba in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1350_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1350_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_1350_4_c_ba();".
// 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_1350_4_c_ba();".
// 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 := [25, 0, 11, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 6, 0, 1], [0, 48, 0, 3], [33, 0, 6, 0]];
    Rf_basisdens := [1, 5, 5, 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_1350_c();"
function MakeCharacter_1350_c()
    N := 1350;
    order := 2;
    char_gens := [1001, 1027];
    v := [2, 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_1350_c_Hecke();"
function MakeCharacter_1350_c_Hecke(Kf)
    N := 1350;
    order := 2;
    char_gens := [1001, 1027];
    char_values := [[1, 0, 0, 0], [-1, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+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 := 4;
    raw_aps := [[0, -2, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -5, 1, 0], [15, 0, 0, 4], [0, 20, -1, 0], [0, -15, -5, 0], [-23, 0, 0, 5], [0, -12, 5, 0], [-45, 0, 0, 7], [-10, 0, 0, -20], [0, -20, 3, 0], [150, 0, 0, -12], [0, 305, 5, 0], [0, 312, 5, 0], [0, 123, -5, 0], [-45, 0, 0, -26], [68, 0, 0, 45], [0, -695, -9, 0], [390, 0, 0, 15], [0, 290, 12, 0], [223, 0, 0, -15], [0, 954, -10, 0], [-285, 0, 0, 69], [0, -1175, 26, 0], [315, 0, 0, 49], [0, -520, -6, 0], [0, -177, -80, 0], [532, 0, 0, -50], [0, 738, 20, 0], [0, -1280, -78, 0], [1605, 0, 0, -70], [0, 1047, 75, 0], [2221, 0, 0, -45], [-540, 0, 0, -54], [977, 0, 0, -195], [0, -980, 94, 0], [0, 830, -140, 0], [0, 1338, 175, 0], [0, 1245, -125, 0], [915, 0, 0, -158], [2774, 0, 0, -95], [-270, 0, 0, -214], [0, -1210, 240, 0], [0, -1152, 80, 0], [1888, 0, 0, 250], [2918, 0, 0, 50], [0, 3815, 127, 0], [0, 1941, -240, 0], [3214, 0, 0, -25], [0, -1479, -105, 0], [2610, 0, 0, 275], [-295, 0, 0, 220], [-5715, 0, 0, 10], [0, 459, -275, 0], [0, 240, 505, 0], [5850, 0, 0, 194], [-700, 0, 0, 120], [0, -5390, 92, 0], [-4005, 0, 0, 163], [0, -2575, -359, 0], [0, 4803, -75, 0], [0, -1790, -24, 0], [1890, 0, 0, 443], [0, 6770, 64, 0], [0, -201, 95, 0], [1280, 0, 0, 330], [0, -110, -568, 0], [0, 7896, -120, 0], [-3260, 0, 0, -450], [0, -1713, -465, 0], [6630, 0, 0, -409], [0, -3170, 618, 0], [0, -6520, -362, 0], [-6140, 0, 0, -550], [0, 6792, -145, 0], [1635, 0, 0, 523], [0, 7840, -265, 0], [6765, 0, 0, -381], [403, 0, 0, 740], [2310, 0, 0, 754], [-2662, 0, 0, -555], [-12600, 0, 0, -129], [0, -6265, -604, 0], [-719, 0, 0, 795], [0, 7731, 260, 0], [15180, 0, 0, 14], [0, 925, -894, 0], [5430, 0, 0, 858], [0, -2365, 843, 0], [0, 3741, -840, 0], [-1740, 0, 0, -728], [0, 13345, 451, 0], [17850, 0, 0, -122], [-3986, 0, 0, -1230], [0, 4914, -670, 0], [2820, 0, 0, -810], [-12855, 0, 0, 507], [0, -6340, 576, 0], [-12370, 0, 0, 485], [0, 7630, -258, 0], [0, -11541, 585, 0], [0, 11631, -1070, 0], [-2550, 0, 0, 236], [-9814, 0, 0, 560], [0, 16735, 642, 0], [0, 8304, 660, 0], [0, -10584, 220, 0], [-11460, 0, 0, -924], [-8605, 0, 0, 20], [0, 13570, -312, 0], [0, -8530, -21, 0], [0, 15516, 630, 0], [-7628, 0, 0, -690], [-14335, 0, 0, -455], [1725, 0, 0, -1461], [0, -4030, -1056, 0], [0, -12990, 775, 0], [0, 14703, 365, 0], [-7440, 0, 0, 568], [-9466, 0, 0, -585], [0, 2135, -1056, 0], [0, 11874, -1340, 0], [0, -1047, 1520, 0], [12854, 0, 0, -240], [-23955, 0, 0, 583], [8464, 0, 0, -1375], [7050, 0, 0, 267], [0, 550, 246, 0], [0, 20720, -333, 0], [-12701, 0, 0, -375], [0, 15954, -765, 0], [-28834, 0, 0, -570], [0, 16330, -1557, 0], [3570, 0, 0, -64], [-13556, 0, 0, -530], [0, -26061, -205, 0], [0, -1400, -2472, 0], [0, 633, -415, 0], [6105, 0, 0, -819], [-2233, 0, 0, -755], [-22080, 0, 0, -338], [0, 7985, -1579, 0], [0, -5295, 320, 0], [7882, 0, 0, -225], [7830, 0, 0, 183], [0, -1150, 855, 0], [0, -13326, 1490, 0], [2995, 0, 0, -765], [0, -23172, -1060, 0], [0, -14180, 1567, 0], [-37170, 0, 0, 558], [0, -9715, -2357, 0], [0, 474, 1105, 0], [0, -41375, 189, 0], [16770, 0, 0, -2163], [-611, 0, 0, 1605], [5820, 0, 0, -1874], [0, 14755, 634, 0], [-11895, 0, 0, 2099], [0, 10722, -550, 0], [0, -27912, 260, 0], [0, -4430, 1902, 0], [-8085, 0, 0, 56], [0, -33114, -630, 0], [0, -14628, -1465, 0], [7052, 0, 0, -1140], [0, -20900, -777, 0], [17311, 0, 0, -900], [0, -34962, 530, 0], [-23100, 0, 0, -380], [-2278, 0, 0, 2640], [32850, 0, 0, -1595], [0, 3335, -2866, 0], [12679, 0, 0, -1235], [-4425, 0, 0, 2983], [9296, 0, 0, -1880], [-8100, 0, 0, -3718], [0, 6005, -1807, 0], [45136, 0, 0, -65], [0, -41555, -1915, 0], [15915, 0, 0, 3926], [0, 31040, -1389, 0], [0, -47343, 145, 0], [0, 21114, 2450, 0], [8475, 0, 0, 2215], [0, -8930, -2568, 0], [0, 6050, -1418, 0], [4279, 0, 0, 140], [30660, 0, 0, -833], [0, 3965, -812, 0], [0, -12909, -2290, 0], [4667, 0, 0, 245], [-29475, 0, 0, 1101], [0, 22143, 630, 0], [0, -43596, -980, 0], [-10807, 0, 0, 90], [0, 31430, 1953, 0], [0, 4896, 3190, 0], [0, 49452, 940, 0], [28020, 0, 0, -482], [45425, 0, 0, 2505], [0, -21440, -3147, 0], [-4079, 0, 0, -1770], [5055, 0, 0, -3168], [0, 34149, 2545, 0], [3730, 0, 0, -5230], [0, -14643, 4480, 0], [-62985, 0, 0, -1605], [-6145, 0, 0, -1175], [0, 7090, 4652, 0], [-12810, 0, 0, -1274], [0, 27200, 690, 0], [0, 1113, -390, 0], [-25350, 0, 0, -1243], [17570, 0, 0, -2280], [0, -47195, -1787, 0], [-23385, 0, 0, -4021], [0, 74736, -1595, 0], [0, -4002, -5880, 0], [1634, 0, 0, -3455], [-19799, 0, 0, 1095], [-23520, 0, 0, 1742], [0, 54515, 3435, 0], [0, 39759, -3090, 0], [46618, 0, 0, 2185], [0, -8487, -1155, 0], [-71280, 0, 0, -573], [0, -48890, 3122, 0], [75630, 0, 0, 686], [0, -28840, -229, 0], [-17039, 0, 0, 4755], [27395, 0, 0, -2755], [-41910, 0, 0, 3914], [0, 27830, 3780, 0], [0, 23490, 1165, 0], [4489, 0, 0, -3150], [0, 38586, 2430, 0], [-22500, 0, 0, 2208], [95880, 0, 0, -913], [0, 3300, 820, 0], [13421, 0, 0, 825], [0, -85540, -2166, 0], [-20936, 0, 0, -1245], [0, -25653, -4145, 0], [-14310, 0, 0, 381], [0, 72085, -2977, 0], [-14145, 0, 0, -3926], [78724, 0, 0, 2840], [0, 38352, 1915, 0], [0, 26980, -2799, 0], [26550, 0, 0, 1894], [0, -46620, 3185, 0], [-6203, 0, 0, 3150], [0, -62250, 3440, 0], [-42045, 0, 0, 904], [4568, 0, 0, -6150], [0, 30265, -3903, 0], [0, 73203, 2515, 0], [0, 29995, -6270, 0], [0, 11210, -6644, 0], [0, 38448, 1980, 0], [-44048, 0, 0, 750], [0, -20200, 1841, 0], [0, -63996, 2170, 0], [-3053, 0, 0, 5415], [-6555, 0, 0, -6401], [-79965, 0, 0, -2973], [0, -82555, -2991, 0], [0, -103437, -225, 0], [4352, 0, 0, 8105], [0, -16850, 3456, 0], [0, -11455, -2868, 0], [23029, 0, 0, -4665], [0, 122635, 1256, 0], [0, -29515, -3531, 0], [0, -37722, 3430, 0], [-92042, 0, 0, -2980], [-56863, 0, 0, 1570], [-14715, 0, 0, -3824], [0, 18090, -235, 0], [35282, 0, 0, 1680], [0, -81810, -985, 0], [-98764, 0, 0, 1605], [0, 32155, 3177, 0], [115380, 0, 0, 2711], [0, -41065, 5246, 0], [0, -53709, 1355, 0], [24451, 0, 0, -6345], [-23550, 0, 0, 980], [-74820, 0, 0, 1254], [0, 35880, -140, 0], [0, -77325, 2785, 0], [-40455, 0, 0, 602], [0, -3790, 8760, 0], [1185, 0, 0, 6487], [-117238, 0, 0, 160], [0, 102702, 3720, 0], [-55680, 0, 0, 1884], [0, -31205, 1539, 0], [0, -2365, -1188, 0], [0, -23076, 3860, 0], [-93275, 0, 0, 2695]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1350_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1350_4_c_ba();".
// 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_1350_4_c_ba(:prec:=4)
    chi := MakeCharacter_1350_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(1999) - 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_1350_4_c_ba();".
// 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_1350_4_c_ba( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1350_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![26896, 0, 428, 0, 1]>,<11,R![-2799, -30, 1]>],Snew);
    return Vf;
end function;