
// Make newform 4032.3.d.c in Magma, downloaded from the LMFDB on 13 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_4032_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_4032_d_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_4032_3_d_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_4032_3_d_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 := [9, 0, 8, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 2, 0, 0], [0, 5, 0, 1], [4, 0, 1, 0]];
    Rf_basisdens := [1, 1, 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_4032_d();"
function MakeCharacter_4032_d()
    N := 4032;
    order := 2;
    char_gens := [127, 3781, 1793, 577];
    v := [2, 2, 1, 2];
    // 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_4032_d_Hecke();"
function MakeCharacter_4032_d_Hecke( : Kf := false)
    N := 4032;
    order := 2;
    char_gens := [127, 3781, 1793, 577];
    char_values := [[1, 0, 0, 0], [1, 0, 0, 0], [-1, 0, 0, 0], [1, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), 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]];
    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 := 3;
    raw_aps := [[0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, -1], [0, 2, -1, 0], [-6, 0, 0, 4], [0, 3, 6, 0], [6, 0, 0, -10], [0, -6, -5, 0], [0, -2, 7, 0], [38, 0, 0, 2], [32, 0, 0, -4], [0, -11, -8, 0], [20, 0, 0, 12], [0, -6, 2, 0], [0, 12, 3, 0], [0, 6, 14, 0], [12, 0, 0, -38], [-6, 0, 0, -28], [0, -6, 9, 0], [4, 0, 0, -14], [22, 0, 0, 0], [0, 6, 4, 0], [0, 5, -20, 0], [40, 0, 0, -2], [0, 47, 18, 0], [-110, 0, 0, -6], [0, 14, -5, 0], [44, 0, 0, -16], [0, -16, 9, 0], [38, 0, 0, 44], [0, -4, -36, 0], [0, 42, 25, 0], [-176, 0, 0, -8], [0, -24, -11, 0], [100, 0, 0, 12], [-12, 0, 0, -26], [-54, 0, 0, -4], [0, -26, -30, 0], [0, 17, 30, 0], [0, 22, 47, 0], [-234, 0, 0, 40], [0, 46, 7, 0], [-160, 0, 0, 24], [0, 28, -7, 0], [32, 0, 0, -4], [216, 0, 0, 56], [24, 0, 0, -68], [0, -54, 34, 0], [-134, 0, 0, -36], [0, 6, 51, 0], [0, 6, 61, 0], [-4, 0, 0, -18], [0, -40, 10, 0], [0, 43, 52, 0], [0, 34, 7, 0], [0, -33, -60, 0], [90, 0, 0, -86], [-186, 0, 0, -56], [0, 70, 3, 0], [-402, 0, 0, -10], [0, 11, 86, 0], [18, 0, 0, 158], [0, 18, -50, 0], [-70, 0, 0, -60], [0, 84, -25, 0], [-40, 0, 0, 144], [240, 0, 0, -76], [0, -14, -53, 0], [-264, 0, 0, -86], [0, 71, 26, 0], [0, 14, 43, 0], [-172, 0, 0, -100], [10, 0, 0, -144], [112, 0, 0, -104], [0, 48, 28, 0], [0, -18, -7, 0], [428, 0, 0, 122], [0, 138, 53, 0], [-64, 0, 0, -54], [0, 60, 86, 0], [442, 0, 0, 48], [0, -78, -105, 0], [486, 0, 0, -4], [-208, 0, 0, 8], [0, 90, -89, 0], [0, 84, 129, 0], [384, 0, 0, -160], [0, 101, 54, 0], [-414, 0, 0, 124], [0, -60, 114, 0], [0, -16, 90, 0], [36, 0, 0, -140], [0, 178, -11, 0], [180, 0, 0, 20], [0, 78, -120, 0], [0, -37, 20, 0], [0, -57, -126, 0], [-120, 0, 0, 152], [142, 0, 0, -144], [-654, 0, 0, 104], [0, 64, 185, 0], [0, -166, 6, 0], [0, -10, 47, 0], [-34, 0, 0, -264], [270, 0, 0, 68], [0, 26, 182, 0], [0, -141, 30, 0], [0, -210, -89, 0], [394, 0, 0, -284], [460, 0, 0, -36], [-366, 0, 0, -116], [0, -30, 143, 0], [72, 0, 0, -244], [-122, 0, 0, -204], [0, -234, -125, 0], [-58, 0, 0, -114], [0, -70, 70, 0], [0, 174, -17, 0], [0, -54, -239, 0], [432, 0, 0, -146], [-420, 0, 0, -40], [0, 45, -250, 0], [0, 78, 9, 0], [80, 0, 0, -84], [0, 162, 27, 0], [188, 0, 0, 152], [0, 156, 156, 0], [586, 0, 0, -6], [-58, 0, 0, 80], [-2, 0, 0, 172], [0, -138, -17, 0], [-312, 0, 0, 184], [-548, 0, 0, 312], [0, -9, 68, 0], [950, 0, 0, 48], [0, 17, -86, 0], [-804, 0, 0, -184], [0, -119, 78, 0], [0, 300, 27, 0], [-328, 0, 0, -12], [0, -124, -63, 0], [110, 0, 0, 344], [0, 54, -147, 0], [430, 0, 0, 288], [0, -320, -98, 0], [112, 0, 0, -18], [0, 95, 8, 0], [146, 0, 0, -138], [0, -42, 27, 0], [438, 0, 0, 244], [0, -105, -42, 0], [620, 0, 0, 300], [0, -226, -142, 0], [-4, 0, 0, -36], [0, 270, -7, 0], [-740, 0, 0, 252], [0, 79, -252, 0], [-446, 0, 0, 112], [0, -7, 20, 0], [0, -326, -237, 0], [0, -140, -85, 0], [1098, 0, 0, 196], [0, -54, -120, 0], [0, 54, -25, 0], [0, 198, 236, 0], [196, 0, 0, -180], [-996, 0, 0, 70], [834, 0, 0, -208], [0, -229, 134, 0], [0, -42, 349, 0], [-808, 0, 0, -214], [0, 174, 289, 0], [-286, 0, 0, -132], [-200, 0, 0, -60], [0, -179, 10, 0], [1242, 0, 0, -64], [0, -86, -283, 0], [446, 0, 0, -94], [-900, 0, 0, 226], [-494, 0, 0, -456], [0, -60, -80, 0], [262, 0, 0, 432], [0, -59, 86, 0], [0, 102, -245, 0], [0, 131, 30, 0], [1344, 0, 0, 136], [156, 0, 0, 716], [-450, 0, 0, 236], [0, -14, 308, 0], [408, 0, 0, 146], [0, -138, 31, 0], [-472, 0, 0, 96], [0, 237, 254, 0], [0, 38, -365, 0], [0, 315, -34, 0], [-220, 0, 0, 624], [-58, 0, 0, -160], [0, 195, 76, 0], [0, 318, 222, 0], [0, -244, -235, 0], [964, 0, 0, -96], [1394, 0, 0, 356], [960, 0, 0, -394], [0, -224, -160, 0], [0, -355, -98, 0], [-1324, 0, 0, -16], [0, -6, 527, 0], [0, 360, -65, 0], [-1638, 0, 0, 182], [-218, 0, 0, -224], [0, -333, -152, 0], [420, 0, 0, 508], [0, 308, 236, 0], [0, -256, 62, 0], [1242, 0, 0, -172], [-620, 0, 0, 36], [0, -313, 242, 0], [0, -218, -211, 0], [0, -126, 175, 0], [1468, 0, 0, 216], [-1518, 0, 0, -230], [0, 148, -29, 0], [-992, 0, 0, -504], [0, -686, -212, 0], [544, 0, 0, -468], [0, -43, 8, 0], [0, 674, 223, 0], [598, 0, 0, -666], [0, 210, 289, 0], [-1476, 0, 0, 448], [-1278, 0, 0, -562], [-572, 0, 0, 60], [0, -412, -423, 0], [1618, 0, 0, -338], [0, 516, 308, 0], [492, 0, 0, 842], [0, -328, -299, 0], [0, -6, -253, 0], [0, -598, -236, 0], [0, -42, -419, 0], [-2132, 0, 0, 88], [-496, 0, 0, 716], [1296, 0, 0, -176], [0, -45, -268, 0], [0, 16, 94, 0], [-18, 0, 0, 778], [0, 286, 370, 0], [1158, 0, 0, 464], [0, 42, -417, 0], [-272, 0, 0, -24], [0, -237, -186, 0], [0, 250, -375, 0], [-1308, 0, 0, 326], [0, -401, 10, 0], [0, -590, -19, 0], [802, 0, 0, 312], [-470, 0, 0, 94], [0, 267, -174, 0], [1166, 0, 0, -408], [802, 0, 0, -312], [0, -98, -339, 0], [-662, 0, 0, 240], [-380, 0, 0, 558], [0, -401, -206, 0], [1292, 0, 0, 576], [0, -24, 435, 0], [0, -103, 446, 0], [-1722, 0, 0, -256], [0, 322, 285, 0], [-240, 0, 0, 454], [1448, 0, 0, 336], [828, 0, 0, 566], [2224, 0, 0, -432], [-1692, 0, 0, 74], [814, 0, 0, 822], [0, 182, 285, 0], [248, 0, 0, -376], [2352, 0, 0, 200], [0, -74, 258, 0], [0, -34, 644, 0], [-1078, 0, 0, 164], [0, 422, -36, 0], [1056, 0, 0, -902], [1052, 0, 0, -252], [0, -102, 129, 0], [-48, 0, 0, 296], [0, -372, -449, 0], [-3266, 0, 0, 30], [0, 237, 276, 0], [0, 28, -587, 0], [0, -412, 136, 0], [0, 390, -361, 0], [0, 822, 422, 0], [1326, 0, 0, -776], [0, 703, 102, 0], [-636, 0, 0, 664], [0, -169, -468, 0], [0, 634, 434, 0], [1700, 0, 0, -516], [-2870, 0, 0, 148], [0, 366, 627, 0], [654, 0, 0, 340], [0, -262, -33, 0], [1210, 0, 0, -728], [-344, 0, 0, -116], [0, -162, -725, 0], [1610, 0, 0, 500], [0, 46, 483, 0], [2712, 0, 0, 136], [0, -270, -208, 0], [0, 434, 523, 0], [0, -330, -59, 0], [-140, 0, 0, -476], [0, -358, -443, 0], [-292, 0, 0, -138], [0, -114, -536, 0], [0, -390, -107, 0], [-1152, 0, 0, 26], [0, 162, -643, 0], [-2686, 0, 0, 450], [1716, 0, 0, -760], [0, -153, -318, 0], [2236, 0, 0, -132], [0, -156, -77, 0], [1260, 0, 0, 518], [198, 0, 0, -4], [-850, 0, 0, -594], [0, -94, 201, 0], [0, 126, -567, 0], [-1488, 0, 0, 256], [0, -234, -665, 0], [82, 0, 0, -798], [0, 1104, 322, 0], [1926, 0, 0, -76], [0, -112, -290, 0], [406, 0, 0, -804], [0, 339, 368, 0], [-3964, 0, 0, 102], [2874, 0, 0, -62], [1158, 0, 0, 112], [0, -578, -459, 0], [0, -165, -80, 0], [696, 0, 0, 1096], [0, -838, -51, 0], [0, 362, -173, 0], [-438, 0, 0, -800], [-3444, 0, 0, 284], [0, 180, -28, 0], [0, -379, 94, 0], [-978, 0, 0, -118], [-1718, 0, 0, 232], [0, 424, 699, 0], [-1792, 0, 0, -28], [-2334, 0, 0, -8], [0, 79, 338, 0], [0, 840, -68, 0], [0, -18, 528, 0], [0, 328, 145, 0], [0, 354, -217, 0], [-238, 0, 0, 488], [0, 119, 128, 0], [0, 666, -207, 0], [0, -446, 297, 0], [-1576, 0, 0, 156], [-348, 0, 0, -400], [0, 89, 204, 0], [-2670, 0, 0, -296], [712, 0, 0, 1600], [0, -414, -269, 0], [-3626, 0, 0, 466], [0, -90, -437, 0], [0, 816, 107, 0], [1186, 0, 0, -582], [-138, 0, 0, 448], [0, -280, -108, 0], [0, 70, 593, 0], [-2410, 0, 0, 144], [0, 777, 54, 0], [1228, 0, 0, -1226], [0, -79, 6, 0], [0, 1176, 347, 0], [2400, 0, 0, -272], [0, 544, 801, 0], [-2228, 0, 0, -44], [0, -130, 700, 0], [1300, 0, 0, 1044], [1626, 0, 0, 1072], [-2134, 0, 0, -96], [0, -108, 178, 0], [354, 0, 0, -940], [0, 177, -604, 0], [0, 42, 177, 0], [158, 0, 0, 378], [0, -190, 489, 0], [1200, 0, 0, -1396], [-3600, 0, 0, 4], [0, 159, 706, 0], [934, 0, 0, 1240], [0, 378, 67, 0], [1180, 0, 0, 846], [0, 52, 311, 0], [-1194, 0, 0, 868], [0, 477, -376, 0], [0, 417, 360, 0], [-228, 0, 0, -740], [1754, 0, 0, -1216], [0, 472, 441, 0], [944, 0, 0, 1296], [0, 324, 226, 0], [1526, 0, 0, 288], [0, -658, -687, 0], [0, 262, 323, 0], [-1404, 0, 0, -1324], [-1430, 0, 0, 4], [0, 549, 840, 0], [0, 450, 645, 0], [190, 0, 0, -798], [0, 243, 930, 0], [0, -972, -242, 0], [0, 534, -13, 0], [-4404, 0, 0, -2], [0, -178, 339, 0], [0, -368, -584, 0], [4094, 0, 0, -384], [0, -465, 262, 0], [0, -502, 221, 0], [0, 966, 591, 0], [2260, 0, 0, -452], [0, 438, 890, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_4032_d_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_4032_3_d_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_4032_3_d_c(:prec:=4)
    chi := MakeCharacter_4032_d();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    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_4032_3_d_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_4032_3_d_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_4032_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<5,R![144, 0, 32, 0, 1]>,<11,R![36, 0, 212, 0, 1]>,<19,R![-664, -12, 1]>],Snew);
    return Vf;
end function;