
// Make newform 1568.4.a.u in Magma, downloaded from the LMFDB on 14 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1568_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_1568_4_a_u();".
// 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_1568_4_a_u();".
// 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, -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_1568_a();"
function MakeCharacter_1568_a()
    N := 1568;
    order := 1;
    char_gens := [1471, 197, 1473];
    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_1568_a_Hecke( : Kf := Kf)
    return MakeCharacter_1568_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, 1], [3, -1], [0, 0], [-22, 2], [-7, 1], [-48, -10], [85, -9], [-76, -16], [-64, -34], [34, -26], [-128, -2], [-44, 58], [-362, -18], [-122, -22], [94, 64], [69, -33], [179, -9], [-100, 144], [700, -28], [314, 116], [-100, -164], [309, 159], [454, 80], [-760, 38], [247, 123], [-746, -6], [544, -52], [260, -190], [-1488, 22], [-1016, 156], [-223, -205], [1878, -108], [275, 129], [-974, 212], [-2328, -188], [-903, -383], [-1074, 230], [-550, -146], [-1667, -115], [-224, 364], [-3027, 277], [-1596, 588], [1092, -182], [-726, 468], [3186, -2], [-3076, -64], [3652, -444], [2805, 263], [-107, 125], [-1838, -264], [404, 88], [-1832, 662], [-3225, -235], [4542, -528], [6156, 36], [-187, -411], [6088, 144], [-610, 1048], [-1590, 864], [-2647, 835], [-8853, 135], [3561, 235], [-6600, -16], [2420, -1062], [-1286, 252], [-1594, 654], [-1796, -462], [-122, -162], [-1015, 289], [-3202, -584], [6144, -1116], [4692, 612], [-4110, 212], [-854, -518], [-10578, -110], [-2800, 174], [-10463, -311], [4924, -630], [-3528, -866], [10559, 421], [8294, 48], [3012, 1872], [3044, -1166], [-368, -1952], [-1732, 216], [-2262, 1080], [-2596, -1094], [6597, -43], [-3712, -1200], [5905, -1093], [346, 1310], [132, 3152], [-14500, -8], [-4964, -2280], [468, 2508], [-2103, 3057], [5588, 50], [-2639, -189], [-2966, -1404], [-262, 90], [-13878, -276], [-17569, 845], [16668, -414], [11682, -670], [2854, 1200], [15671, -1235], [-1334, -1804], [8000, 1528], [3718, -32], [-792, 3320], [-21088, -1050], [-6508, -446], [4401, 2587], [-12188, 884], [-4396, 930], [-26057, 69], [2706, -274], [3012, -2518], [1154, -3022], [-3309, -4353], [17478, 1004], [-9747, -2187], [-10772, 880], [-23927, -1573], [8276, -1286], [1144, -938], [-6350, 478], [5670, 2114], [-16397, 487], [13070, 1958], [7400, -772], [3300, 4208], [-6440, -3954], [13160, -2570], [28764, -878], [9287, 2155], [4913, 219], [19349, -2075], [16740, 1810], [21045, 743], [4974, -712], [14576, -928], [-28616, 1540], [21603, -505], [17110, -4022], [-15603, -411], [10560, 1062], [-7873, -4211], [32332, -1580], [15920, -1914], [5922, -5580], [9344, -4716], [5838, 2954], [-14552, 4604], [-16736, -1108], [-96, -1376], [6928, 2518], [-21182, -4100], [-22065, -1845], [-24742, -2470], [-3246, -5496], [31020, 3592], [32389, -3297], [1198, -1340], [-12602, -5974], [-360, 2512], [7439, -1629], [-1276, -3990], [31389, 1509], [1532, 2872], [1485, 6381], [-34628, -3404], [-21966, -2024], [-25326, 3710], [-37966, 3396], [27544, -4940], [28272, -3882], [-27092, 2524], [-8201, -4813], [-1436, -8496], [-6337, 109], [16644, 7514], [17118, 416], [40656, 476], [-42663, -951], [-11506, 5400], [-12339, 1487], [-62666, 1172], [35774, -4726], [-53714, -1176], [-34900, -4064], [23096, -20], [45625, -4927], [-10912, -828], [-7990, 4844], [-17412, 2434], [-20800, -7378], [-6494, 3796], [17296, -2448], [-9426, -2232], [50750, -3878], [24215, 795], [27090, -1756], [705, 627], [-42217, 4195], [50670, -1478], [38390, 6310], [-3688, 5542], [-1061, -2575], [-15228, 5794], [-46357, -2457], [-456, 2900], [25489, -277], [18504, 11432], [-50120, 6294], [-15824, 3984], [53620, 1402], [-20528, 2472], [-34636, -7398], [-52508, 2066], [-39880, 1752], [10282, -1576], [-26156, 3144], [-49939, -7201], [12476, 6890], [50070, -720], [12316, 1184], [-14924, 9324], [10314, 3858], [3980, 3570], [76615, 1869], [-42584, 10184], [48578, -8648], [6413, -12049], [-14960, -4744], [-104632, -210], [44674, 8484], [35164, -10408], [12108, -6212], [-4454, -13086], [-70703, 3779], [4692, 9180], [3070, -120], [45194, -356], [45682, 7406], [-15392, 13424], [-97543, 4091], [-66242, -2322], [5304, -14640], [29154, 7996], [26638, 9432], [66076, -1364], [-64426, -768], [-40469, 4847], [57856, 1916], [-18188, -12366], [-13897, 1229], [2547, 14367], [-60640, -1242], [2500, 7992], [-15946, 15190], [6323, 8031], [17363, 2519], [41104, 1310], [48283, -11999], [-10990, 9996], [-51138, -5208], [-93768, -3004], [9412, 8650], [-28899, 4589], [-49534, -9446], [-8030, -15308], [-22464, -2588], [1542, -20072], [31260, 9692], [6702, -12018], [-55966, 692], [-67384, 6934], [-21531, 12479], [-63924, -9828], [37768, -11864], [71054, 7818], [-69533, 10575], [56429, -11841], [-55664, -14756], [-69638, 5880], [-68734, 3100], [12174, -14870], [60446, -3480], [-10570, 16912], [-53843, -4489], [53348, 11570], [-27043, 4351], [36342, -10520], [-3191, -2159], [29480, 13840], [4345, 7545], [-14921, -13803], [58963, 14465], [-88872, 8398], [93348, -12990], [-136472, -5544], [32598, -5178], [-22546, -4818], [89270, 5132], [-35874, 14166], [13247, -19061], [68500, -24], [-96450, 14488], [39420, -22644], [-69336, -5226], [57902, -5756], [-38770, -11122], [-64972, 14388], [-826, -9200], [-40489, -1979], [44192, -1024], [95042, -1436], [51994, 15720], [17199, 13461], [64670, -6708], [76295, -18909], [35548, 11756], [25596, -17238], [-39140, 7018], [44562, -2926], [90173, 6351], [-6280, -17708], [-49868, -2414], [58002, 10868], [-78484, -5790], [72798, -7262], [30099, 7401], [152776, -7548], [87073, 7315], [127908, 6146], [21550, 11912], [6358, -4168], [-61146, -14222], [-48454, 7396], [-37116, 15354], [70885, 5165], [38580, -7916], [38796, -10974], [882, -5670], [179757, 6053], [82402, -1662], [-63076, -10740], [-35073, -237], [-32509, 16417], [-16174, 1352], [46262, -3568], [31518, -2262], [-150062, -9924], [-50494, -18780], [-67550, 18326], [9877, 33103], [-15054, -26928], [-92420, 6424], [65818, -25796], [130786, 5788], [75392, -6780], [-183296, 3236], [-131027, -8881], [3308, -32774], [156421, 5509], [-197596, -3696], [21820, 9994], [-60024, -6036], [-60997, 1097], [172968, 2832], [-91174, 19388], [-62320, -9144], [-110182, 7620], [-122395, -22729], [138228, 14184], [-94134, -3268], [87616, 3582], [-41568, 34470], [21457, -25223], [-33260, 17698], [28384, 20960], [16586, -2792], [80071, -395], [49008, -23088], [102140, -3156], [-11669, 18615], [8964, 13376], [-3210, 10578], [-13700, -35662], [45315, 20335], [-29488, -23876], [70799, 20501], [-142416, -9924], [-64810, -2268], [-31942, 32398], [-69452, -13054], [-48872, 14836], [-72800, 1814], [-151089, -5141], [-61814, -10072], [185888, 2304], [159072, 14694], [-44315, -3299], [-3818, -17494], [-178106, 10696], [47588, -21382], [120455, 19245], [89887, -8883], [49442, -18348], [-23092, -17958], [-130462, -2094], [121068, -1000], [-172630, 4256], [-104963, 18029], [-80316, 35220], [-157602, 5930], [59584, 36462], [5236, -33460], [59484, 33850], [-33457, 34915], [28824, -31776], [-45485, -14695], [-38692, -11118], [-293993, -3149], [-15926, -26654], [42354, 5304], [-83133, -15783], [21410, 10086]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1568_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1568_4_a_u();".
// 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_1568_4_a_u(:prec:=2)
    chi := MakeCharacter_1568_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_1568_4_a_u();".
// 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_1568_4_a_u( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1568_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![-28, -6, 1]>,<5,R![-28, -6, 1]>,<11,R![336, 44, 1]>],Snew);
    return Vf;
end function;