
// Make newform 1280.4.d.l in Magma, downloaded from the LMFDB on 09 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1280_d();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1280_d_Hecke();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_1280_4_d_l();".
// 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_1280_4_d_l();".
// 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 := [1, 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_1280_d();"
function MakeCharacter_1280_d()
    N := 1280;
    order := 2;
    char_gens := [511, 261, 257];
    v := [2, 1, 2];
    // 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1280_d_Hecke();"
function MakeCharacter_1280_d_Hecke( : Kf := false)
    N := 1280;
    order := 2;
    char_gens := [511, 261, 257];
    char_values := [[1, 0], [-1, 0], [1, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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], [0, 2], [0, -5], [6, 0], [0, -32], [0, 38], [26, 0], [0, 100], [-78, 0], [0, 50], [108, 0], [0, 266], [-22, 0], [0, -442], [514, 0], [0, 2], [0, -500], [0, 518], [0, 126], [412, 0], [878, 0], [-600, 0], [0, 282], [150, 0], [386, 0], [0, 702], [-598, 0], [0, 1194], [0, 550], [1562, 0], [-1846, 0], [0, -2208], [2334, 0], [0, 700], [0, 2050], [1852, 0], [0, 2494], [0, 2762], [3126, 0], [0, 78], [0, -1300], [0, 1742], [-3772, 0], [-358, 0], [0, -2214], [-2600, 0], [0, -1168], [6478, 0], [0, 646], [0, 3750], [-1482, 0], [-1400, 0], [3022, 0], [0, 1248], [2106, 0], [-3638, 0], [0, 6550], [4388, 0], [0, 546], [6858, 0], [0, -9282], [0, 4842], [0, -2594], [7332, 0], [-1562, 0], [0, -1426], [0, 4008], [8866, 0], [0, 1714], [0, -1150], [-4398, 0], [1800, 0], [5874, 0], [0, -2078], [0, -7900], [7518, 0], [0, -1950], [0, -13786], [6402, 0], [-11150, 0], [0, -13700], [0, -5438], [-7692, 0], [-1118, 0], [-2600, 0], [0, 11958], [-17050, 0], [9494, 0], [0, 11418], [-7962, 0], [0, 6526], [-17400, 0], [1166, 0], [0, -7072], [0, 100], [2602, 0], [0, -11150], [3638, 0], [0, 2078], [0, -5622], [0, 16486], [0, -11706], [0, -25038], [-17550, 0], [0, -10712], [-13654, 0], [0, -14166], [17842, 0], [-17600, 0], [-27302, 0], [3794, 0], [0, -13238], [11574, 0], [0, -8300], [-7508, 0], [-27378, 0], [0, 1842], [-10114, 0], [0, -10402], [0, 7100], [0, -7118], [-31278, 0], [0, -30054], [0, 4518], [0, 29272], [0, 5798], [0, 8950], [-7800, 0], [-8554, 0], [0, -2882], [0, 18700], [12242, 0], [31148, 0], [0, -7694], [4518, 0], [-39550, 0], [0, 22122], [0, -16634], [0, -27586], [-3850, 0], [0, -10032], [0, 20562], [10322, 0], [0, -8846], [0, 25350], [46000, 0], [0, -16998], [26494, 0], [0, 21500], [-25762, 0], [0, -30546], [32942, 0], [0, -27118], [-38634, 0], [0, 1794], [-41732, 0], [29200, 0], [-48650, 0], [11334, 0], [0, 31178], [0, 4686], [598, 0], [41726, 0], [0, -24312], [40946, 0], [42282, 0], [-1172, 0], [0, -31614], [2450, 0], [0, 50362], [0, 12900], [0, -1462], [-30108, 0], [-8082, 0], [-5200, 0], [-29850, 0], [0, 46248], [0, -24018], [-30238, 0], [0, -35050], [-27566, 0], [0, -8528], [0, 63442], [67214, 0], [40398, 0], [0, 51350], [0, -36426], [0, -27278], [-6350, 0], [47548, 0], [2602, 0], [0, -23162], [0, 8712], [0, 358], [0, 77766], [15158, 0], [20302, 0], [0, 25038], [22626, 0], [-56678, 0], [0, 66450], [-79692, 0], [0, -75534], [-3950, 0], [0, 56700], [0, -40146], [-24800, 0], [0, 43682], [26550, 0], [0, 42328], [-6214, 0], [0, 57202], [-49398, 0], [0, -57206], [30000, 0], [-6662, 0], [20954, 0], [-13518, 0], [-64874, 0], [0, 13878], [0, -45758], [20000, 0], [28050, 0], [-11722, 0], [0, -29354], [0, -38350], [-17682, 0], [-44800, 0], [93886, 0], [0, 77448], [0, -82602], [0, -37100], [-68012, 0], [-71942, 0], [0, 34318], [17034, 0], [-89850, 0], [0, -106958], [0, 58500], [15732, 0], [0, 84522], [0, -36192], [47842, 0], [0, 46050], [-51198, 0], [33800, 0], [-91526, 0], [0, -57688], [0, -114500], [34918, 0], [0, -60586], [-25198, 0], [-101394, 0], [-64350, 0], [0, 42638], [0, -9900], [0, -23138], [0, 1954], [0, -58734], [-73706, 0], [82238, 0], [0, -55274], [0, -74650], [0, -19242], [39786, 0], [0, -5900], [0, -104750], [28838, 0], [0, 34678], [0, 58682], [0, 102778], [0, 14686], [-102602, 0], [78000, 0], [-139254, 0], [-43918, 0], [0, -68766], [0, -105150], [-80502, 0], [0, 89232], [-75922, 0], [-140108, 0], [-38114, 0], [0, -97218], [0, -49926], [120588, 0], [-87878, 0], [0, -24054], [-120400, 0], [40950, 0], [0, -127402], [0, 113206], [151038, 0], [0, -30192], [0, -59282], [0, -83850], [33148, 0], [0, 23322], [0, -152700], [0, 89966], [-96642, 0], [0, 66814], [96200, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1280_d_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1280_4_d_l();".
// 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_1280_4_d_l(:prec:=2)
    chi := MakeCharacter_1280_d();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(1999) - 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_1280_4_d_l();".
// 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_1280_4_d_l( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1280_d();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<3,R![4, 0, 1]>,<7,R![-6, 1]>,<11,R![1024, 0, 1]>],Snew);
    return Vf;
end function;