
// Make newform 432.4.a.o in Magma, downloaded from the LMFDB on 28 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_432_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_432_4_a_o();".
// 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_432_4_a_o();".
// 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 := [-8, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-3, 6]];
    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_432_a();"
function MakeCharacter_432_a()
    N := 432;
    order := 1;
    char_gens := [271, 325, 353];
    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_432_a_Hecke( : Kf := Kf)
    return MakeCharacter_432_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 := 4;
    raw_aps := [[0, 0], [0, 0], [-4, -1], [-12, -1], [1, 0], [16, -4], [28, 4], [-92, -2], [46, -4], [168, -2], [-188, 5], [174, -4], [156, -10], [-40, 14], [-114, -8], [-76, 13], [340, -24], [-56, -32], [-176, -34], [908, -12], [-287, 0], [680, -32], [-391, 32], [-120, -18], [-169, 8], [828, 9], [56, 52], [693, -56], [46, 76], [732, 70], [164, -23], [-1003, -104], [1296, -2], [-1416, 100], [-2132, 31], [1468, 113], [-764, 72], [-1236, -120], [-390, 144], [-3252, 19], [-1197, 56], [2016, 16], [-840, -196], [-499, -40], [-1092, 245], [-1564, 129], [-3028, -34], [2192, -8], [1740, 24], [-1682, -8], [3128, 50], [-2878, -164], [1950, 248], [-1168, 336], [3940, 56], [2158, 132], [-560, -226], [-68, -185], [-3008, -24], [-284, 116], [1420, 178], [624, -134], [8148, -4], [1110, 84], [-2427, -96], [-36, 449], [-1952, 134], [-5694, -56], [2655, 304], [1434, -156], [460, -526], [-3462, -24], [8564, 193], [7628, 276], [-1856, -12], [10044, 108], [-5668, -409], [-5152, 36], [7104, -132], [9279, 128], [-612, 512], [3584, 360], [7346, 224], [5269, -264], [-3780, -291], [6884, -224], [-9652, 378], [-5569, -200], [7868, 255], [-3524, 3], [1209, 616], [-10114, 488], [-3448, -248], [14571, 328], [-2256, 926], [7986, 332], [948, -771], [-6380, 288], [6884, -788], [2556, 264], [-4652, -428], [-14788, 15], [-14921, 272], [-7144, 396], [15204, -488], [-17074, 344], [-15959, -456], [-2920, 1122], [-6594, 104], [-2645, 416], [19528, -264], [-3514, 880], [996, -38], [-21724, 192], [-7612, -345], [7172, -978], [8016, -276], [-13768, 328], [1308, 123], [-12993, -48], [-12862, -572], [-3203, -112], [872, -590], [9964, 224], [-9872, 1212], [15540, -875], [27548, -64], [20212, -272], [7692, -1545], [5486, -1292], [-2804, -1596], [4456, 1604], [-17172, 449], [1970, -40], [-22520, 168], [23849, -360], [14304, 478], [22592, 992], [14900, -749], [14200, 434], [2588, 726], [4608, -842], [-19916, 489], [31424, 320], [34, 184], [3492, -268], [13286, -408], [-11004, -468], [-8040, -1088], [16828, 1696], [2850, 1952], [8908, 1696], [-7172, 1190], [-34576, 380], [9116, 2094], [8230, -2208], [-36916, -3], [-42344, -468], [-14853, -888], [24660, 1019], [24999, 880], [17064, -1404], [11596, -641], [13929, 992], [6408, -826], [5934, -3096], [-14428, -1673], [-44552, 252], [2147, -2824], [19112, -1310], [-1965, -2056], [8166, 1320], [27518, 976], [2770, -2664], [-20756, -711], [-2564, 758], [-6740, -1730], [35604, 667], [1100, 855], [-700, 508], [42172, -639], [-14755, 2208], [-29766, 1196], [-1128, 2876], [41376, 1644], [-44412, -77], [-34382, -452], [2196, -2796], [13339, -1480], [7950, -1508], [-45158, 1384], [-5661, -2864], [-8368, 1650], [40460, -421], [-15828, -1088], [-7520, -772], [-28745, 400], [53446, -928], [-4592, 1780], [9324, -2024], [-25916, 2035], [-32900, -2095], [-12556, 876], [28045, 992], [-9333, -40], [-55104, -1074], [3784, -388], [-10935, 1112], [-5504, -3014], [-3292, -1452], [38409, -2080], [-82464, 166], [-1372, 659], [31751, 1520], [-73024, -1240], [-19639, -2136], [-3584, -2496], [56960, -718], [20826, 104], [12936, 2386], [6338, -604], [17784, 948], [3696, -1576], [-67064, -644], [-15939, 2728], [-21448, 1328], [78504, 144], [-15282, -1060], [6384, -1192], [-17444, -1496], [37254, -112], [32120, 576], [-7904, 5496], [-9976, -4140], [23448, 4238], [54932, 424], [41438, 2064], [-6928, -142], [-22885, 4840], [-9932, 3984], [53508, 1480], [10888, 4646], [63068, -345], [1948, 6292], [11700, -4236], [6392, 3292], [-244, 3149], [48765, -2056], [53132, -2350], [79616, 1380], [39516, 1416], [58692, -1020], [12878, -1856], [-2927, 2760], [-36972, -3279], [-3747, -2096], [-8944, -1428], [59768, -1200], [-3900, -4115], [45457, -2264], [-15340, 535], [71631, -3536], [1582, 2256], [-66684, -1236], [74000, 2604], [28600, 3884], [-43520, 3950], [12460, -94], [34132, -664], [85240, 2354], [49012, 4908], [-42680, -1368], [-66515, -4032], [2564, -5293], [109561, 1688], [31852, 3681], [-88887, -2088], [-7588, -3124], [77071, -2504], [-19436, -2864], [-16124, 6912], [52940, -2243], [25582, -28], [-29842, -1868], [-61640, 2306], [39106, -1712], [3299, 4080], [51516, 5103], [-40784, -336], [-18752, -4672], [92192, -2102], [-96687, 56], [41000, 4172], [57783, -3712], [16746, 6068], [12272, 6386], [-56348, 1857], [-38172, 877], [7245, 4312], [-15248, 5898], [-40846, -952], [-56756, -2753], [8956, 6311], [-80087, -416], [16896, 1178], [56879, 6272], [69324, -1312], [66578, -5140], [-100336, 2456], [-11524, -3084], [52776, -3196], [69084, -3035], [65980, 5518], [64520, 4476], [59920, -1240], [-39886, -1384], [51477, 7728], [42456, 7860], [47042, 2704], [-60000, -1258], [36656, -4748], [-35099, -5520], [42772, 2577], [135764, -2797], [-60184, -4656], [-51105, 5984], [-129384, 1618], [74676, 3116], [-80012, -2404], [-42804, 2155], [82126, 2300], [5616, -3350], [106380, 2873], [16392, 4528], [-25308, -1684], [-76947, -1536], [-75146, 5732], [60636, -514], [-28447, 9744], [104076, 1059], [-27278, 2664], [-33096, -6184], [-13788, -1375], [-77112, 3008], [156860, 677], [23452, -240], [-71586, 2612], [-81532, 2938], [-65514, -748], [-45464, 5438], [62436, -108], [181091, -2752], [64592, 1586], [77100, 5937], [-24874, 7088], [92380, -3122], [-49046, 852], [-14749, 2888], [139196, -2498], [16002, -1192], [54200, -376], [148932, -172], [130908, -5304], [-67165, -1048], [-154492, 902], [-31170, -4944], [-63600, 5630], [66788, 2677], [83137, -3568], [329, -7896], [30336, -4492], [16514, -4580], [39884, -8403], [-49780, 10065], [97508, 952], [-9600, -4768], [-3006, -6892], [-45749, -4320], [-4440, -4182], [28766, -4128], [197124, -729], [74608, -874], [-24528, -11016], [136572, 628], [-77908, 1328], [-60558, -6028], [64344, -7812], [-156040, -1932], [-34492, 2646], [-151104, 972], [94681, -776], [49304, -966], [51276, 5696], [29184, -7334], [40380, 13208], [-132362, 8296], [-28176, -10080], [-21540, 11262], [-10556, 6230], [-20212, -6661], [67016, 644], [-115644, -4198], [-135064, -5776], [176128, -2616], [25940, -3647], [107948, 7525], [231898, 1944], [-170772, -6664], [-95336, -6364], [42111, -1504], [-188665, -2424], [-106060, 811], [62717, 1752], [231440, 1052], [-16935, 9176], [62180, 2797], [-190614, 2888], [90208, 10920], [141972, 3550], [-71782, -11376], [-73664, 2590], [155654, -4508], [30116, 2264], [-76243, -7856], [74245, 11224], [-31316, -99], [171109, -416], [-64212, -11950], [37656, 5024], [20056, -708]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_432_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_432_4_a_o();".
// 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_432_4_a_o(:prec:=2)
    chi := MakeCharacter_432_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(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_432_4_a_o();".
// 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_432_4_a_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_432_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-281, 8, 1]>,<7,R![-153, 24, 1]>],Snew);
    return Vf;
end function;