
// Make newform 232.4.a.e in Magma, downloaded from the LMFDB on 19 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_232_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_232_4_a_e();".
// 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_232_4_a_e();".
// 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 := [-9, 48, -8, -88, -40, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [-113, 671, 447, 43, -9, -1], [321, -400, -365, 22, 12, -1], [-159, 261, 555, 201, -3, -5], [-123, -32, 731, 431, 6, -11], [-1035, 1093, 3347, 1595, 9, -41]];
    Rf_basisdens := [1, 14, 21, 14, 21, 42];
    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_232_a();"
function MakeCharacter_232_a()
    N := 232;
    order := 1;
    char_gens := [175, 117, 89];
    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_232_a_Hecke(Kf)
    return MakeCharacter_232_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 := 4;
    raw_aps := [[0, 0, 0, 0, 0, 0], [-1, 0, 0, 1, 0, 0], [-1, 0, 0, -1, -1, 0], [-6, -1, 0, -1, 1, 0], [-1, 2, 3, 0, 3, -1], [3, -2, -1, -6, 0, 3], [-37, 2, 3, -4, -5, -6], [-52, 0, -11, 1, 1, -1], [-34, -1, 2, 9, -5, 8], [-29, 0, 0, 0, 0, 0], [-117, 5, -10, 10, 1, -4], [-40, -6, -10, 2, 14, -2], [-89, 8, -11, 28, -7, -14], [-93, -12, 9, 12, 7, 13], [-165, -7, 3, 1, -12, 11], [83, -2, -11, -8, -8, 15], [-2, -1, 16, -33, 13, 6], [199, 38, 1, 6, 13, -24], [2, -4, 52, 6, 4, -10], [106, 56, 16, -70, 24, -8], [-2, -18, -40, 58, -52, -14], [-39, 21, -29, -9, 20, -9], [-260, -41, -40, 29, -55, -12], [-61, -44, 11, 30, -25, -12], [27, -22, -73, 124, 45, -16], [-76, -8, 28, 10, -98, -4], [72, -60, 26, 22, -6, 76], [-498, -15, 16, 21, -25, -92], [465, -20, 40, 53, 23, -6], [126, 60, 102, 50, 122, -34], [26, -8, -91, 39, 21, 73], [404, -2, 63, -51, -71, 33], [-564, -130, 28, -60, -4, 96], [28, 7, 26, -77, -133, -94], [-507, 78, -75, -18, 42, -21], [-206, 53, 72, -379, 27, -28], [-105, -174, 63, 128, -67, 96], [325, 62, -126, 155, -48, -46], [-936, -62, -38, 4, 172, 44], [-944, 128, -134, -12, 122, 16], [814, 68, 20, -22, -88, 20], [67, 76, 184, 99, -91, -58], [-1146, -72, 65, -121, -147, 65], [-1241, 90, -51, -78, -49, -74], [-2126, 64, 220, -160, 48, -124], [-586, -45, -68, 3, -235, -48], [905, 86, -102, -41, 228, -102], [-1552, -4, 192, 264, -120, 126], [1220, -46, 4, -290, 62, 90], [-591, -120, -79, -438, 233, -4], [-542, -42, 362, 26, -69, 121], [846, -59, 40, -339, 347, 94], [262, -166, -120, 392, 19, -11], [663, 20, 62, -433, 114, 86], [50, 178, 267, -311, 76, -10], [-393, 141, 74, -582, 9, -144], [447, 12, -475, 516, 203, 12], [-2535, -51, -92, -258, -1, 54], [2442, -132, 168, -484, 88, 332], [-1424, 66, -138, -256, -17, -29], [466, 103, 332, 435, 201, -222], [-3536, -152, -60, 554, -72, 58], [1199, 20, 11, 310, -75, -61], [-2710, 28, 329, -497, -567, -59], [2610, -30, 249, -949, -82, 60], [3055, 84, -19, -596, -61, -80], [2229, 40, -254, 121, 34, 130], [-1729, -278, -371, 294, -55, -84], [418, 340, 116, -682, 108, -216], [5413, 30, -317, -148, -178, -125], [-2318, 12, -336, 104, 384, -92], [-1399, -1, 29, -549, 112, 253], [-2846, 254, 161, 1085, 223, -43], [-441, -140, -762, 153, -473, -104], [3924, 196, -399, 161, 257, 111], [-5884, 159, -76, -719, 49, 10], [-106, -118, -34, 584, 318, -544], [1777, 492, 198, 387, 107, -334], [-2222, -382, 210, 894, -361, 221], [2978, -92, 40, 652, 668, -4], [-696, -314, 306, -148, -4, 44], [2601, -48, -291, 242, 335, 378], [1588, 231, 342, -53, 179, -326], [854, 210, 56, -82, -44, -658], [-7002, -27, -514, -61, 29, -396], [2328, 194, 723, -511, -107, 81], [-3572, 114, 628, -612, 842, 166], [5706, 200, 280, -108, -524, -36], [-1414, -94, -56, -970, 122, 544], [-7402, 77, -76, -51, 131, 22], [-4469, 304, -395, 892, 311, 385], [-1671, 359, -120, 0, -715, -942], [-1828, -791, 152, -49, 227, 1130], [2641, 68, -605, -356, 45, 151], [-5474, -465, 1062, -979, -105, 156], [-4011, 379, 32, 144, 121, 190], [-6369, -34, -69, -146, -1238, -463], [-524, -418, -745, 1399, 1030, 42], [500, 194, -674, -324, -608, -106], [648, 122, 320, 104, -220, 156], [736, -1, -410, 2907, 731, -460], [-708, 68, 226, -232, 1482, 112], [-159, -428, 170, 1913, 222, 194], [1042, 126, 378, 528, 180, 278], [-10160, -6, -8, -626, 554, 356], [3993, 736, -417, -752, 633, 488], [8296, -443, 110, -107, 29, 154], [-1928, 542, 593, 137, 888, -24], [4001, -641, -659, 1915, -900, -23], [-3731, 844, 81, 738, 541, -208], [2045, -65, 408, 1548, -923, 102], [783, 388, 338, -2711, 381, 310], [4896, 526, -96, -412, -744, -840], [-4567, 220, 8, -381, -1288, 292], [-6388, -36, 40, 256, 60, -922], [-5165, 686, 295, -1596, -625, -754], [-580, 745, -466, 1497, -583, -356], [14970, 463, -450, 477, -545, -316], [1775, 536, 273, 360, -199, -878], [1935, -186, 1376, -181, -566, -328], [1452, -616, -722, -564, -242, 988], [-10046, 958, -846, 774, 1305, 415], [-10064, 424, 476, -326, 1484, 314], [3472, -264, 1050, -1458, -326, -474], [8558, 444, 1416, -2502, 560, 654], [-2783, -242, -845, 1236, -104, -619], [8103, -782, -595, 2764, -402, 577], [376, 396, -128, 1208, 780, -850], [-2866, -976, -1115, 2123, -447, -27], [-3566, -1072, 462, 1254, -24, 228], [-2013, -1096, -1764, 1457, -836, 156], [13874, -426, -73, -1893, -259, 699], [-16678, -474, 143, 1315, -747, -97], [359, 568, 111, -2506, 97, 778], [12654, -1044, -1516, 2248, 296, 960], [-443, 684, 137, 1446, -669, -234], [-18843, -398, -645, -742, 697, -342], [-11272, -604, -300, -236, -1232, 782], [-4209, 246, -579, -446, 777, 1132], [6402, 58, -80, -1542, -1632, -390], [-9486, 937, -522, 671, 1809, 762], [15007, 750, -561, -1578, -2124, -929], [-19690, 68, 1061, -409, -2015, 581], [-11635, 642, -456, 1873, 706, -808], [22081, 242, -871, 2044, -1111, 86], [15835, -415, -855, 43, 458, -411], [8268, 550, 584, -2412, -782, 546], [-752, -1302, 543, -893, -980, 1364], [-3175, 516, -471, -1466, -1353, 89], [9756, 342, -220, -1158, 1310, 906], [20215, 170, 1021, 2384, 1260, -525], [1064, -356, 2142, 860, 878, 220], [-13390, 253, 112, 1025, -1353, -528], [-1157, -481, -472, -394, -871, 998], [4932, 1046, 191, -1787, 1773, -799], [-2587, 853, -460, -1334, -73, -1622], [-17366, 610, -1300, -592, 190, 632], [-4030, -736, 736, -484, -572, -1256], [23516, -1764, -1182, -1504, -966, -248], [24041, -732, -2636, 2921, -677, 838], [539, 186, -427, -1486, -115, 2133], [2668, 1006, -106, -3984, 1419, -317], [-11765, 1589, -1085, -275, 3280, 1539], [-10996, 1446, 1913, -105, -2465, -857], [3204, 1310, -1317, -745, -232, -892], [-13697, -675, -3503, 2491, -2286, -611], [12122, 514, -498, 1306, -788, 702], [3098, -316, -3984, 512, 98, 466]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_232_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_232_4_a_e();".
// 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_232_4_a_e(:prec:=6)
    chi := MakeCharacter_232_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_232_4_a_e();".
// 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_232_4_a_e( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_232_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-98, -651, 1581, -266, -92, 5, 1]>],Snew);
    return Vf;
end function;