
// Make newform 2025.4.a.i in Magma, downloaded from the LMFDB on 16 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2025_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_2025_4_a_i();".
// 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_2025_4_a_i();".
// 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 := [-3, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_2025_a();"
function MakeCharacter_2025_a()
    N := 2025;
    order := 1;
    char_gens := [326, 1702];
    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_2025_a_Hecke( : Kf := Kf)
    return MakeCharacter_2025_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 := [[-1, 1], [0, 0], [0, 0], [0, 4], [-11, 28], [32, 4], [-16, 56], [-5, 68], [42, -32], [-85, 24], [-129, -12], [-38, 148], [-289, -48], [-190, -156], [242, -16], [272, 100], [-353, -28], [334, -192], [726, 52], [-487, 196], [-592, 92], [204, 104], [222, 600], [-513, 0], [334, 440], [141, 608], [-230, 28], [-1062, 260], [1271, -416], [-16, 284], [-100, 1008], [-1089, 852], [1740, 712], [2285, 36], [446, 552], [-1133, -1044], [538, -1784], [-116, -136], [-1524, 892], [-1206, -1916], [-1001, -1516], [503, 1760], [-2263, 1468], [-1922, 956], [-4260, -272], [2464, 240], [2555, 100], [2116, 900], [5476, 172], [1950, 1656], [2994, -1676], [-2480, -1736], [-1403, 2552], [-252, 1728], [-630, -1092], [-3206, -740], [-6647, -1088], [736, -496], [2754, 2196], [246, -4232], [1890, -2288], [5334, 1036], [3314, 1744], [-1401, -3460], [-3404, 2504], [5326, 1968], [3483, -2756], [9260, 428], [8048, -912], [1789, 5416], [1602, 124], [-3627, 1564], [918, -4776], [6644, -3488], [100, 7632], [-5136, -1964], [1638, 6352], [1094, -3792], [-6450, -3808], [854, -4640], [-2776, -3432], [-971, 4344], [-3645, -908], [-3142, -136], [2035, 60], [4134, 2528], [-4367, 5144], [2714, 8792], [345, 2792], [-4050, -5856], [-8540, -1932], [11601, -4204], [12028, -3228], [1907, 572], [13759, 748], [7816, 4484], [1042, -2952], [16658, 1120], [10196, 1084], [10587, -5072], [-2800, -2188], [-8256, -7432], [6810, -3868], [2229, -5288], [15341, 3420], [412, -1928], [-15522, -3596], [-2054, -2068], [8327, 5772], [7445, -5744], [-10774, -3864], [-28, 1312], [1452, 2516], [8156, -5600], [-8129, 9308], [12315, 7976], [2826, 14980], [8930, -1024], [-16772, 772], [-15788, 5384], [-8423, 5872], [594, 2820], [-11466, 8940], [4488, -8304], [12772, 5240], [8315, 4152], [-10034, 9488], [4827, -1764], [-14792, 3012], [28042, -4764], [-20291, 4148], [-10540, 15940], [16168, -6960], [-26140, 4992], [3189, 1168], [-24835, 872], [-2706, 13372], [-520, -4960], [2488, -6012], [30311, 1960], [-8829, 11116], [-18453, 16120], [3322, -2588], [25232, 732], [-1965, 1512], [-34099, -4140], [972, -3488], [-32152, -6632], [-16577, 2124], [12628, -2116], [4728, 19048], [16303, -4816], [700, 21204], [20514, 3660], [-31578, 2556], [-7049, -4764], [-12587, -7932], [-15055, -11808], [-40350, 3028], [-20410, 9720], [-18918, -8164], [27764, -16812], [-35084, -12144], [16749, 9220], [-18952, 16052], [18852, 8808], [-33649, -10684], [-12060, 5744], [1913, 17312], [-33872, 2376], [-5511, -18332], [12199, -7400], [-7887, -22404], [43230, 2292], [19936, -11640], [5331, -22696], [-11868, 12824], [11097, 29512], [34900, -12816], [-29501, -12968], [11098, 7584], [-24040, 7048], [-8236, -24892], [-7298, -2288], [-27258, -13612], [23647, 9440], [-30366, 15440], [11480, -21100], [9851, -968], [36964, -15512], [-10150, -17884], [-658, 976], [43716, 1384], [14251, -440], [-32574, 4540], [-56540, 7448], [-8135, 19536], [31146, 18216], [888, -41568], [27460, 5264], [-22353, -9944], [-36303, -17660], [-27768, 15616], [-7199, 752], [-29292, 10552], [16872, -35612], [6395, -25220], [37340, -25316], [3678, -17584], [8516, 19168], [-28610, -11684], [-13, 12456], [54132, 14000], [31112, 18000], [38793, 1500], [-10207, 13408], [-33322, 21196], [6045, -42648], [-8558, -21804], [8058, 36124], [14821, -4688], [39293, 24452], [-61617, 2184], [-55288, -2728], [58408, -10560], [24623, -17560], [-63762, -14584], [-85024, -632], [18266, 25360], [-68748, -2168], [53592, 6880], [3301, 28180], [-24184, 16768], [17230, 31424], [5608, -55796], [8298, 7168], [-24345, -3808], [100492, 2976], [-43428, -29736], [39579, 36444], [6120, 8088], [26016, -40232], [-9010, 40972], [43470, 29032], [29832, -708], [12343, 22404], [-7478, 23288], [-18596, -11080], [-17905, -8796], [41534, 252], [17030, -5184], [-19211, -33864], [-5934, 12840], [28035, -26424], [-7718, 8708], [-40680, -20728], [9019, 63008], [-31598, -1400], [-32952, 19288], [-17432, 15100], [-37714, -13956], [57910, -3780], [-15427, -2992], [-71892, 3864], [-21090, -46184], [80365, -24588], [-83606, -14968], [-41407, 1960], [38740, -17988], [-22846, 26880], [-54133, -30456], [71468, 27172], [-57032, 6708], [100761, -19452], [-33210, -20404], [20254, 12212], [68118, 39740], [33321, -12696], [-20598, -48280], [11652, 28376], [-46826, -1056], [94408, -7784], [-17210, 184], [-75858, 9136], [49452, 39856], [21681, -18556], [103718, -12976], [-21270, 4672], [51587, 51372], [-594, -6064], [-5137, 18000], [-48692, 4636], [9132, -46236], [31761, 51052], [28696, -53080], [14205, 752], [35339, 612], [-40572, 35112], [-11577, 45780], [75130, 31992], [2238, -5740], [-79396, -17932], [59941, 5444], [-81618, 8000], [-60389, -48476], [16036, 73244], [-66060, 6104], [12581, 6760], [63423, 17732], [-50232, 39104], [-63498, 51144], [-41985, 6048], [23565, -32288], [53470, 37768], [-11804, -55552], [-103943, -17584], [3465, -70996], [8529, 13332], [88734, 38588], [-60951, -9064], [46100, 27792], [-17420, -49504], [-56957, -52184], [61508, -3768], [-13956, -548], [-28391, -4840], [101903, 15908], [-189862, 1616], [-46728, 60304], [-10018, -6336], [67017, -2840], [-25018, 70572], [-27751, -95268], [-19136, -60260], [59969, 31732], [43270, 5020], [-110269, -58664], [72106, -34852], [-25243, -41784], [106656, 9160], [-138262, -26156], [55438, 85196], [-100587, 29376], [-66252, 71176], [49244, -25272], [-35028, -39176], [-199915, 9344], [52070, -61324], [-8697, -34692], [7588, 72052], [-61911, -6620], [1680, -16700], [70418, 74576], [132254, -22548], [-55347, -30728], [-21570, 24176], [113843, -45476], [1539, -7524], [-14982, 11560], [-28312, -92848], [-115900, 57020], [-18035, 35816], [53748, 28376], [-151793, 20380], [-26330, -24804], [764, -11400], [12240, -116848], [-57762, -26980], [3185, 72024], [-42195, -63620], [53676, 25560], [-71794, 60996], [-69399, -83496], [-93837, 33732], [16268, -118744], [80761, -1692], [-28131, -67236], [81766, -24044], [22425, 92504], [-67756, -28104], [34046, -23392], [149538, -32280], [-88126, 94496], [-106130, 39760], [-101979, -84036], [-180592, -21868], [-53776, -18272], [-167582, -57904], [-15240, 50340], [84618, -55052], [-62106, 24416], [-13276, 98792], [31828, 34624], [-112490, 47752], [-57065, 20788], [-189794, 29544], [-177949, 21092], [-25050, 15144], [-64892, 8584], [32271, -5528], [21691, -46016], [53328, 71600], [-36022, 12084], [-46004, 60180], [83069, 44456], [21352, -106272], [-77612, -79260], [48194, -38128], [153318, 48980], [-8805, 52540], [22632, -159284], [31542, 46332], [-127852, 52912], [-214851, -22468], [-246236, -11376], [15790, 24376], [35117, -26220], [28346, 87084], [234276, -10464], [-232046, -41092], [111494, -9512], [-31318, 8952], [-113088, -74700], [115573, 115060], [161566, -45208], [-66394, 49900], [-36686, 75080], [90150, -80368], [-20059, -72348], [-149960, -49848]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2025_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2025_4_a_i();".
// 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_2025_4_a_i(:prec:=2)
    chi := MakeCharacter_2025_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_2025_4_a_i();".
// 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_2025_4_a_i( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2025_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![-2, 2, 1]>,<7,R![-48, 0, 1]>,<11,R![-2231, 22, 1]>],Snew);
    return Vf;
end function;