
// Make newform 560.4.a.r in Magma, downloaded from the LMFDB on 07 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_560_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_560_4_a_r();".
// 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_560_4_a_r();".
// 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 := [-2, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [0, 4]];
    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_560_a();"
function MakeCharacter_560_a()
    N := 560;
    order := 1;
    char_gens := [351, 421, 337, 241];
    v := [1, 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_560_a_Hecke( : Kf := Kf)
    return MakeCharacter_560_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], [-1, 1], [-5, 0], [7, 0], [7, 8], [25, 1], [-25, 11], [-18, -11], [-122, 17], [-13, 6], [60, 45], [282, -15], [-164, 31], [130, -17], [175, 33], [-28, 32], [616, 0], [168, -27], [76, 16], [952, 0], [338, -86], [-507, -62], [188, -150], [-108, 11], [1371, 55], [-338, -17], [667, -179], [-862, 114], [241, 264], [-242, -285], [-1304, -16], [110, -331], [644, -277], [-166, 64], [226, 98], [645, 296], [774, 44], [174, 208], [795, 77], [403, -511], [-2300, 120], [2028, 100], [1099, 128], [-404, -201], [-696, 247], [-3080, -38], [-4863, 138], [2811, -629], [-325, -237], [-1260, -949], [88, -92], [-263, -940], [-3146, -557], [118, -76], [-4818, -538], [-2014, -568], [2266, -174], [-1904, -495], [4286, 826], [-1853, 262], [205, 993], [3863, 633], [-579, 237], [-4466, -575], [3561, 883], [-642, -1262], [7308, -420], [-3546, -632], [-846, -1537], [-4494, 1021], [4299, 265], [448, -480], [2095, 933], [1916, 801], [2460, 316], [2756, 694], [-3747, -464], [1131, 551], [-6503, -412], [-6010, 1006], [5028, 1372], [3401, -1794], [5807, -110], [1890, -1084], [5502, -12], [8490, 531], [-12041, -850], [6224, 1613], [10056, 704], [13792, -907], [-119, -1219], [-10266, -1391], [-11062, -968], [-379, 28], [-3269, -472], [3589, 1417], [7930, -1732], [7390, -225], [12228, 788], [15475, -1090], [-9192, -301], [8712, -2932], [-18716, -540], [-11182, -212], [8676, -514], [2069, 471], [12096, -646], [9261, 1711], [-1329, -3770], [-15970, 4], [5917, 3549], [-1982, 468], [-2382, 3674], [-610, 2079], [-9681, 760], [-17758, -300], [9599, 901], [-8360, 3722], [314, -2245], [-10701, 2258], [-4096, 914], [564, 4531], [-13319, 1607], [-9384, -3207], [12428, 3694], [-8633, -4354], [16803, -548], [9574, -265], [-13992, 3122], [989, -2823], [2543, -1604], [-20940, -886], [-5739, 3506], [1824, -774], [-13490, 2777], [-314, -3916], [-7935, 3113], [29083, -1439], [-8429, 5649], [-10079, -1436], [18406, -2810], [2117, 2790], [3740, -3143], [-25174, 1776], [26676, -829], [15282, -2299], [11374, 348], [-4638, 4124], [-12300, -1064], [-16688, -3791], [-24974, 931], [15392, -5212], [-4004, 157], [-20248, -3268], [-21466, 393], [-10368, -4286], [-20079, -1016], [18060, 246], [32427, 361], [6480, 1357], [18152, 3525], [6808, -313], [21982, -5918], [-22200, -27], [14374, -5], [-21139, -2355], [5344, 5276], [-50713, -3], [-4355, 7238], [6050, -3330], [41240, 1432], [12650, -5242], [-10069, 3998], [-2070, -4758], [9534, -3649], [38804, -36], [18331, 3734], [33781, 4200], [-28076, -1398], [22712, -4309], [29532, -6297], [500, -1177], [670, 1553], [19462, -1736], [39332, 701], [-30102, 3891], [-5864, -1122], [3143, 5377], [21249, 3708], [-25152, -3663], [61970, -2508], [35418, -6055], [-45531, 2210], [-66472, -1169], [-17268, -1502], [40221, 819], [16599, 2094], [-7324, -3769], [2919, -5385], [-25445, 7157], [15062, 1036], [23590, -5900], [34522, -3962], [77402, -395], [17418, -439], [29287, -6333], [-12170, 3888], [-35108, -2431], [42630, -5964], [54896, 2121], [-41916, 661], [1442, -5664], [-11516, -8369], [14435, -12121], [17758, 5350], [-41244, 175], [44222, -2555], [-31628, -11879], [-11922, 2285], [18910, -7264], [-15870, -13450], [-44138, 972], [9973, -10730], [-2506, 4566], [-23181, -2005], [26910, -1142], [-18037, 5697], [70911, -322], [-19469, -6555], [31852, 3446], [48388, 2645], [8986, -3934], [14032, -1222], [-10799, 4834], [75771, -3993], [17435, -4993], [-5032, 5923], [-17312, 2102], [17509, -9774], [-34562, -7825], [-46104, 2644], [-43624, -6006], [17127, 3155], [-14226, 7892], [41773, -1889], [15770, 8433], [-11944, -1142], [-4850, -19758], [-32639, -14084], [-8790, 5613], [-32062, -299], [-81886, 4382], [4140, 5666], [-80680, -2802], [16318, 2102], [-8549, -17736], [66654, -3394], [34980, 5436], [64977, -1839], [-84475, -4483], [-88910, -6073], [81230, 7914], [47844, -10806], [-32387, -15917], [61298, 494], [-98298, -3603], [38365, 3768], [-48414, 11672], [58684, -4204], [-77550, -1165], [49072, 16411], [1372, 1891], [-105541, -1063], [-16596, 11424], [-58298, 13438], [73383, 4355], [-72524, 7836], [874, -15368], [-83607, -4800], [-72594, -2582], [127731, -3179], [72013, 1934], [7888, -20244], [81942, -7894], [-41501, 19027], [-40169, 4194], [-26970, -12469], [-44342, -1409], [-59900, 11280], [42052, -3548], [-32363, 5434], [-51927, -411], [38688, -17137], [-95628, 2795], [84122, -7183], [-66216, -15867], [5102, -10810], [39409, -9643], [-36108, 7534], [87415, 10849], [-1201, -12407], [26534, 17088], [78531, 1830], [77392, 340], [-1883, 5056], [-79062, -7647], [19250, 10001], [-16192, 10932], [18408, -16186], [-25544, -6638], [82136, -2250], [53111, -6692], [45038, -23600], [-75902, 11900], [61938, -14261], [-34876, 19093], [66190, -6880], [105879, 872], [-12529, 18231], [95741, -8528], [126402, 6966], [8600, 18205], [20026, 4974], [-6076, 18329], [41230, 4472], [-16948, -14782], [-50251, -4266], [42044, 28146], [-30192, -3873], [64148, 19779], [-49826, 2348], [-21732, 5365], [-44230, -13338], [22325, 1569], [71388, -14610], [101615, -2711], [-15183, -4866], [106786, -16128], [-76698, -1305], [-104553, 6723], [69474, 24360], [-43416, -956], [73514, 8211], [-65853, -8138], [19046, -16835], [-83252, 8820], [92486, 6398], [-45564, -10523], [-9482, 31227], [-126109, 3483], [-46648, -28620], [-9264, 33277], [-19195, 64], [-5601, -21497], [-18619, 30274], [-36418, 5946], [109642, -12414], [58578, 19209], [177594, -979], [10694, -1656], [74688, -22509], [-142008, -16348], [31448, 4711], [13859, 18924], [-51092, -4624], [-160062, 3157], [8763, -26805], [124126, 3179], [-96419, 23372], [-7197, -31760], [-6928, -3623], [9928, 12236], [101591, 11744], [-806, 12088], [4306, -9728], [43432, 17842], [-112725, -2808], [39893, -32827], [59750, 12108], [-60583, 14129], [-7810, 14398], [-2858, -6578], [-53844, -11044], [81414, -22826], [44320, 6101], [-133125, 18855], [-61769, -17164], [117897, 16063], [28828, 27510], [25297, 13607], [-63511, -32260], [-25977, 4759], [-162631, 7570], [-157412, -21028], [136783, 14916], [66952, 2518], [-104532, -13491], [38240, 20879], [-52705, -28612], [-57302, -3620], [157948, -16643], [-20204, 46920], [-204306, -7243], [180531, 7979], [52188, -23036], [106518, 24944], [106162, 18092], [-154033, -7364], [107444, -5556], [-158796, 10812], [41323, 7429], [-36578, 36266], [82386, 30999], [16204, 31496], [-73826, 6411], [-102456, -14104], [51679, -636], [-36500, 15938], [34522, 19026], [144963, -12563], [77841, 19118], [-4706, -43664], [26694, -2316], [79884, -7666], [154745, 14757], [115491, -11359], [-170704, -17422], [-91446, -33978], [47480, 20097], [-110672, 27199]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_560_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_560_4_a_r();".
// 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_560_4_a_r(:prec:=2)
    chi := MakeCharacter_560_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_560_4_a_r();".
// 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_560_4_a_r( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_560_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-31, 2, 1]>,<11,R![-1999, -14, 1]>],Snew);
    return Vf;
end function;