
// Make newform 1470.4.a.bf in Magma, downloaded from the LMFDB on 15 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1470_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_1470_4_a_bf();".
// 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_1470_4_a_bf();".
// 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 := [-126, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-1, 2]];
    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_1470_a();"
function MakeCharacter_1470_a()
    N := 1470;
    order := 1;
    char_gens := [491, 1177, 1081];
    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_1470_a_Hecke( : Kf := Kf)
    return MakeCharacter_1470_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 := [[-2, 0], [-3, 0], [5, 0], [0, 0], [-29, -1], [-28, -2], [5, -5], [1, -5], [-65, 5], [-17, -11], [-172, 6], [-27, -17], [-30, 4], [-103, 13], [479, 3], [675, -1], [66, 10], [-9, 11], [743, 3], [-682, -10], [22, -28], [-152, 0], [-946, -6], [-298, 16], [-254, 52], [-706, -36], [-1004, -16], [463, 25], [974, -8], [-67, 49], [-1162, -34], [978, -30], [795, 71], [-1707, -37], [2395, 41], [1172, 20], [238, 48], [491, -117], [1311, -117], [678, 12], [403, -141], [-2075, -87], [2290, -98], [3716, -46], [687, -105], [-128, -34], [-1328, -4], [-858, 130], [1880, -172], [-2649, 31], [1915, 75], [-806, -18], [-922, 78], [1550, 6], [2371, -155], [4789, 127], [-198, 260], [1228, -70], [-441, -239], [-824, 110], [-1794, -170], [5254, -32], [-5100, -80], [-4028, 32], [3512, -90], [2275, -281], [-3720, 4], [7828, 18], [3759, -167], [-1783, -219], [7333, -41], [4244, -104], [-7752, 116], [2501, 419], [4794, -242], [7377, 293], [-1179, 63], [1168, 78], [-3008, 378], [-8386, -6], [1392, -204], [4496, 54], [4110, -426], [-9424, 238], [-5850, -476], [-3421, -155], [7040, -178], [646, -512], [6592, -434], [-9036, -100], [4850, -146], [-12236, -184], [-12316, 256], [-4357, -349], [-6698, -222], [18507, 87], [-4676, 502], [-11348, -542], [4282, 378], [-10982, -112], [13535, 235], [4559, 371], [4878, 306], [-7256, 282], [-2204, -296], [9228, -566], [-2834, 762], [-2697, -1007], [2046, 322], [-272, 548], [7650, -658], [-1087, 67], [-7791, -639], [-6245, 481], [17940, 44], [5298, 168], [9172, -512], [-243, 361], [477, -623], [17131, 59], [403, 431], [9928, -486], [-4616, -222], [-2127, 819], [2935, 201], [-10321, 661], [-9482, 844], [-1186, 74], [-9176, 792], [-15122, 280], [-10790, -362], [-1365, 465], [-9320, 1176], [-2175, 455], [19116, 726], [330, 622], [18868, -662], [3730, -62], [-20566, 16], [8098, 404], [-7779, -901], [17565, 519], [-5552, -928], [-13823, -493], [14227, -177], [-18914, 382], [19296, 134], [-4395, 675], [-3179, 987], [-9881, 1789], [13811, 605], [-25618, 1036], [957, 1157], [3393, 565], [-19035, 53], [20342, -1142], [34368, -656], [16392, -774], [-36960, -894], [-21812, 54], [-26001, -411], [2347, 815], [-14786, -502], [19464, -380], [19143, -513], [27011, -1145], [-24872, -1400], [20016, -906], [-28436, 906], [-20984, -646], [-15141, -633], [-41217, -1], [23824, 1432], [-6348, 2370], [25542, -848], [-20538, -60], [-11646, 670], [-36071, -133], [33248, 712], [10861, 1565], [29080, -636], [33108, -624], [1497, -2137], [17817, 1215], [13265, 651], [13632, 1182], [-11523, 1447], [41778, 322], [46328, 314], [-65610, -414], [-12686, 1876], [963, -2619], [23130, 702], [29904, 102], [10959, -307], [20375, 2585], [6, -2392], [27127, 1389], [-45905, 1553], [-27035, 313], [1711, -671], [32052, -1822], [31366, -1140], [39564, -1748], [5224, -404], [-57824, -1298], [43590, 424], [18973, -2129], [1840, -846], [-26323, -1221], [34524, 86], [39118, 1696], [-23004, 2348], [-40498, 682], [20526, -2242], [45970, 1454], [-13160, -724], [-51420, -1150], [-11763, -1185], [-20699, -1879], [18578, -1240], [-38550, 1796], [63170, 1532], [-54354, 1358], [-44518, -1410], [-46198, -1256], [-91233, 441], [-41832, 672], [34806, -94], [11459, -1069], [-26781, -1071], [35521, 2835], [52384, -688], [24228, -2570], [91084, -504], [25921, 677], [12354, -122], [9651, 267], [14491, -2357], [496, 1356], [4133, 83], [92787, 865], [19688, 824], [2576, -4206], [-32469, -3719], [-52036, 700], [-13376, -2552], [3380, 4600], [38716, -120], [22459, 3625], [-108405, -219], [23320, -2306], [-47931, 911], [-21184, 252], [-28292, -934], [-34279, 3085], [15388, 754], [-27938, 118], [-5360, 1094], [52684, -86], [-106888, -64], [3247, -2943], [-59975, 177], [5696, 5138], [-16919, 1787], [56147, -1747], [-7057, -3527], [-14292, -2574], [8753, -1867], [31541, 1241], [55763, 2323], [6195, 3623], [-86498, 1200], [-928, -3816], [-57178, -1176], [-7282, 4526], [-19229, -2203], [113442, -712], [-65250, 2792], [-93794, 1070], [70887, 627], [-107656, 1592], [-28895, 4301], [-47795, 1173], [-20690, 990], [-26524, 280], [-65518, 2020], [-13717, 1207], [67984, 1970], [-83828, -1938], [55103, 3409], [-30432, -4212], [26843, -1445], [-92216, -1468], [121251, -127], [53446, 2932], [75662, 608], [-14616, 210], [-59534, 2570], [3306, -1846], [138240, 394], [14121, 2461], [-32204, -2452], [-12953, -1163], [-18952, -468], [144022, -580], [-29239, -1849], [-48287, -2927], [-68658, 630], [-54675, -1805], [-50949, 847], [-91921, -1787], [46284, 1606], [-99631, -175], [46839, -4707], [142700, -932], [-42918, -3534], [-31834, -1578], [-34430, 6492], [112794, 740], [-39955, -3549], [-24544, -4038], [107058, 936], [72860, -3156], [45089, 4753], [40742, -5658], [-26824, 3348], [-92202, 502], [-88523, -4857], [94693, -795], [-120792, -698], [51257, -2571], [42426, 2600], [57488, 4412], [-1182, -6602], [-153464, -1796], [37186, 6952], [-47335, -421], [71464, 1544], [846, -6194], [-51927, -6961], [-38163, 3717], [-39836, 5126], [-27180, -540], [-8979, 5713], [180217, -239], [90915, 4019], [15939, -2981], [10308, 1896], [-42178, 7032], [-42405, -3819], [-45942, -988], [-110771, 4687], [-39444, 3004], [67210, 2712], [81097, 3715], [-24842, 762], [117182, -1570], [-4491, -7215], [66463, -4035], [58021, -989], [-21084, 4662], [27771, 1521], [-76481, -2449], [1114, -990], [-44186, 1064], [119992, -854], [-135312, -1012], [-45940, 766], [-51103, -1615], [98085, 4827], [-32029, 6889], [-39051, 6555], [66932, -1158], [-25109, -467], [26386, 26], [-144850, 4230], [72484, -6838], [24860, 906], [-76074, -2236], [-83516, 4458], [94453, -1047], [65772, 6208], [14931, -4109], [156429, 779], [16605, 4281], [-65704, -216], [104810, -1452], [-143637, 1135], [-138159, -2811], [-118626, -1840], [140260, -4390], [-150913, -753], [-164892, -176], [61134, 1614], [100042, 7576], [-213492, -1226], [-24810, -2060], [98266, 6182], [95701, -277], [-102091, 725], [181267, -1745], [-64756, 5664], [12587, -191], [12784, 9194], [132892, 862], [21515, -1363], [-20648, -2218], [-2384, 2028], [-44730, -7002], [71352, 1754], [31069, -2395], [-126453, 5613], [47466, -10330], [-49304, -4954], [67792, -6382], [-97850, -6574], [64102, 3310], [72023, -4691], [74729, 2101], [195273, -4125], [-76106, -460], [-158089, -2403], [-96612, 6360], [-192052, 5402], [-10470, -11572], [-43577, -5707], [-14006, 5180], [261813, 703], [-161930, -722]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1470_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1470_4_a_bf();".
// 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_1470_4_a_bf(:prec:=2)
    chi := MakeCharacter_1470_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_1470_4_a_bf();".
// 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_1470_4_a_bf( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1470_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<11,R![336, 58, 1]>,<13,R![-1236, 56, 1]>],Snew);
    return Vf;
end function;