
// Make newform 528.4.a.q in Magma, downloaded from the LMFDB on 14 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_528_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_528_4_a_q();".
// 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_528_4_a_q();".
// 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 := [-34, -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_528_a();"
function MakeCharacter_528_a()
    N := 528;
    order := 1;
    char_gens := [463, 133, 353, 145];
    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_528_a_Hecke( : Kf := Kf)
    return MakeCharacter_528_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], [3, 0], [-3, -1], [-8, -2], [11, 0], [11, 1], [-11, -3], [31, -3], [105, 5], [-107, -7], [164, 4], [-100, 2], [57, 29], [303, 17], [191, -21], [-1, 29], [542, 2], [-177, -55], [-228, 8], [17, -27], [-56, -70], [-410, 20], [506, 82], [518, -12], [654, 16], [77, 9], [-300, -48], [302, -42], [7, 37], [304, 2], [-1054, 104], [1600, 60], [330, -196], [-569, -155], [-59, 77], [-786, 228], [-584, -62], [1462, 222], [-1540, -120], [1313, 77], [530, -194], [744, 162], [3031, 139], [-1112, 214], [-767, 197], [-4354, -34], [-1231, -161], [30, 458], [2026, 170], [-3542, 0], [-587, -39], [-1908, 272], [-5606, 44], [3454, -230], [-1430, 328], [-2838, 398], [1955, -255], [-618, -256], [1185, 15], [-3701, 23], [-4997, -219], [2337, 393], [-2945, 149], [-1683, -7], [2228, 526], [5291, 421], [2138, 314], [-4564, 54], [10, 210], [9609, 35], [10114, -24], [786, 578], [2282, -202], [3717, 143], [10026, 194], [-2127, -771], [1317, -73], [5718, -4], [4114, -188], [-150, -1228], [-6334, -2], [-254, 1220], [3458, -346], [6972, 294], [780, 118], [5554, -714], [3072, -658], [-9410, -136], [7245, 493], [3868, 408], [588, -1592], [-490, -438], [-4850, 518], [8722, 746], [12560, -236], [-13508, 488], [-10597, 121], [-5010, 1224], [-237, 549], [18407, 109], [-11915, -545], [-13035, 557], [5300, -256], [-2687, 169], [14505, -197], [7536, -698], [6202, -50], [4203, 159], [13601, 309], [-15834, -460], [10166, -124], [3391, -463], [4504, 1418], [-5610, -946], [12460, 84], [-15312, -50], [246, -754], [3625, 949], [-13415, -761], [4236, -1144], [-2544, 626], [26872, -394], [-21235, -111], [-7362, 2082], [7422, 510], [-21451, -59], [-2206, -2552], [12261, 1353], [15598, 1926], [2535, -1291], [-15417, 585], [-12590, -30], [-11000, 2240], [7422, 2144], [-7747, -515], [-13228, -518], [-14185, -747], [-9085, 1013], [21809, 1627], [-10049, 2935], [-33951, 719], [-12791, 2005], [1950, -1006], [22586, 1458], [36544, -274], [-14477, -857], [20031, -887], [-13445, -2325], [23894, -2010], [-7361, -1949], [-24587, 1383], [-15012, -2506], [-32320, 1036], [10682, -2942], [32970, 322], [2665, 45], [-3070, -540], [33126, -944], [4738, -1416], [-17739, -1031], [17512, 828], [-8269, -3037], [42622, -324], [8906, 1654], [22554, -1004], [3033, -275], [43932, 620], [617, -221], [1470, 1664], [4901, -437], [-17988, -2080], [-17206, -112], [5570, -1630], [-28832, 2546], [40478, -2014], [28992, 314], [-4011, 839], [-2271, 3847], [-15696, 2198], [20501, -2777], [33436, 1348], [26812, -1584], [53526, 1112], [-20329, 1711], [-20307, -1463], [11957, -4541], [42957, -469], [26358, -1202], [-38694, -220], [-398, 2678], [672, -6210], [778, -374], [-1204, -1536], [5589, -3033], [3024, -3052], [34570, 904], [-9266, 3372], [22660, -3978], [47019, -3085], [42000, -2424], [-42531, -1851], [-42908, -3150], [-44368, 394], [7048, 490], [-20554, 2514], [-11377, -1303], [-51476, -936], [-33168, 276], [17677, -1419], [-20812, 2688], [-12292, 666], [-13807, 4567], [-13224, -5304], [19592, -148], [-42354, 470], [-85558, -132], [11540, 4366], [26123, -1521], [2005, 2169], [41849, -585], [-44283, -1021], [-702, 6496], [-19586, 4240], [-71998, -34], [67116, 3424], [-26263, -2765], [-43568, -4150], [-22429, -3049], [-23052, -3370], [22542, -290], [-27064, 4278], [-48699, -3301], [-10808, -5818], [-41395, -2427], [-2828, -2448], [53944, -1440], [-7842, -6812], [-88779, 1877], [39994, 2022], [-52981, -4705], [47152, -5516], [-21597, 7245], [-67080, 1032], [-58236, -82], [-11993, 7187], [37746, -6214], [-14098, -6042], [44288, -4028], [-19, -6337], [-15294, 850], [55889, 175], [-81707, 3601], [27119, -1669], [21846, 592], [9989, -867], [17246, -2706], [-45208, 782], [40149, 843], [-25457, -135], [55532, 6450], [-32234, 688], [31632, -3772], [-9537, 7293], [22601, -3213], [73136, 3494], [20448, 3028], [-27063, -2401], [-51060, -3178], [-15857, -3363], [-82199, -4899], [-27886, -4184], [25342, -4050], [43168, 3878], [-11352, -5862], [97204, 2102], [-20074, 1934], [-46196, 1856], [-12937, 2105], [48070, -2484], [111844, 968], [41286, 8770], [-32090, 814], [17726, -1490], [-2095, -4221], [39445, -6065], [-95679, 4445], [30966, 2952], [88517, 1401], [1246, 3526], [69639, 1475], [-57635, -3617], [-37374, 838], [-32641, 10115], [-44876, -424], [80089, -1565], [122269, -3779], [23638, -5730], [-20121, 7661], [-16086, -6334], [-13591, -7289], [-54212, -566], [61429, 6141], [84692, 50], [-34048, -4172], [78428, 7344], [14556, -10938], [95820, -3408], [-14638, 508], [-12021, 8367], [-147, -5361], [-6300, 2688], [2495, -14055], [66441, 7605], [112436, -3712], [12442, -2026], [-33608, 2202], [-52772, -512], [65980, 3404], [23246, -11052], [1615, -5521], [-31621, 8145], [86824, -2570], [15765, 2621], [87962, 794], [27707, -3785], [-16952, 3742], [-17500, -10312], [63284, -5544], [55556, -3888], [-403, -5679], [-13855, -497], [-12919, 7067], [101672, -1738], [78830, 4806], [108399, -3647], [-2892, 7944], [3102, 5012], [-130521, -1789], [-56542, -5528], [59850, -1792], [-125574, 5704], [102032, -4626], [96577, -831], [-24494, 10414], [51019, -4407], [44934, 8454], [-195764, -826], [85782, -3610], [-86158, 11114], [-50593, 2461], [18761, 14951], [-16314, -9540], [-94333, 9953], [103190, 3508], [-65953, 3369], [-201321, -2401], [-50295, -1819], [-141362, 4062], [124027, 2435], [117451, -4769], [141907, -707], [-15281, 7875], [-74467, -4551], [-5758, 3634], [13072, 5252], [43450, 9360], [40497, -14679], [88050, -9952], [73672, 7382], [-68510, 4326], [-43230, -4726], [30160, 2872], [104361, 8101], [-124652, -378], [-93850, 8320], [-135564, 3760], [-70324, -2600], [159210, -5448], [-76321, -11713], [63890, 8356], [84481, -3205], [-175488, -3410], [-22422, -5032], [71685, 9653], [-90941, 5613], [2231, 2827], [-65504, -5696], [42008, -16434], [34051, 10005], [114639, 9547], [124146, 6804], [-106391, -3401], [-99954, 3682], [-100840, 8564], [82159, 14027], [62498, -12516], [114716, 7010], [19908, -12286], [44154, 14378], [177169, 701], [172179, 2341], [-104054, -1772], [179548, 5842], [-128252, 2730], [89649, 10785], [-222120, -3394], [-124844, -2142], [11441, 685], [-66052, 10344], [56372, 13112], [-7194, 5052], [86877, -4947], [-45044, -7880], [-174343, -9973], [173592, -7110], [-121401, 10897], [-75224, 14172], [1688, 15620], [-27176, 12310], [160980, -5912], [-30175, 2399], [-77393, 17121], [204489, 2941], [-94450, 1094], [1616, -14354], [-104521, 2077], [101448, 11684], [-18491, 2633], [-20198, -614], [196366, -1558]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_528_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_528_4_a_q();".
// 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_528_4_a_q(:prec:=2)
    chi := MakeCharacter_528_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_528_4_a_q();".
// 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_528_4_a_q( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_528_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-128, 6, 1]>,<7,R![-484, 16, 1]>],Snew);
    return Vf;
end function;