
// Make newform 1280.3.e.f in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1280_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1280_e_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_3_e_f();".
// 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_3_e_f();".
// 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, 14, 0, 9, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0], [-7, 0, 10, 0, 2, 0], [0, 38, 0, 20, 0, 2], [23, 73, 20, 60, 2, 7], [21, -73, 30, -60, 4, -7]];
    Rf_basisdens := [1, 1, 5, 5, 5, 5];
    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_1280_e();"
function MakeCharacter_1280_e()
    N := 1280;
    order := 2;
    char_gens := [511, 261, 257];
    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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1280_e_Hecke();"
function MakeCharacter_1280_e_Hecke(Kf)
    N := 1280;
    order := 2;
    char_gens := [511, 261, 257];
    char_values := [[-1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+1)]];
    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 := 3;
    raw_aps := [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [-2, 0, -1, 0, 0, 1], [-2, 0, 0, 0, -1, -1], [-2, 0, -2, 0, 2, 2], [-1, 0, -3, 0, -1, -1], [-2, 0, -2, -6, -2, 2], [2, 0, -6, 0, -2, -2], [12, 0, 2, 0, -3, -3], [0, 8, 0, -1, 0, 0], [4, 0, 4, 4, 4, -4], [33, 0, -5, 0, -3, -3], [13, 0, 5, 0, 1, 1], [-6, -5, -6, -6, -6, 6], [42, 0, -8, 0, 1, 1], [-5, 0, 17, 0, -5, -5], [-62, 0, -6, 0, -2, -2], [-7, -8, -7, 8, -7, 7], [2, -11, 2, -30, 2, -2], [8, 8, 8, -12, 8, -8], [-4, 4, -4, -4, -4, 4], [-4, -16, -4, -44, -4, 4], [-14, -11, -14, 18, -14, 14], [-10, 0, 8, 0, 16, 16], [-6, -8, -6, -18, -6, 6], [-16, -24, -16, 25, -16, 16], [-20, 0, 2, 0, -3, -3], [20, -1, 20, 20, 20, -20], [-7, 0, -7, -16, -7, 7], [-20, -8, -20, 20, -20, 20], [-20, 0, -26, 0, 3, 3], [34, 0, 42, 0, -2, -2], [6, -4, 6, 10, 6, -6], [-98, 0, 30, 0, 2, 2], [-17, -40, -17, -8, -17, 17], [-20, -8, -20, -32, -20, 20], [125, 0, 15, 0, 9, 9], [20, 41, 20, -60, 20, -20], [16, 0, -34, 0, 1, 1], [81, 0, 43, 0, -3, -3], [62, 0, -50, 0, 2, 2], [16, 88, 16, 41, 16, -16], [-8, -64, -8, -8, -8, 8], [14, 24, 14, -54, 14, -14], [-109, 0, 9, 0, -5, -5], [-40, -56, -40, 68, -40, 40], [-134, 0, -30, 0, -26, -26], [72, 0, -54, 0, 31, 31], [-4, -39, -4, 44, -4, 4], [0, -24, 0, -39, 0, 0], [36, 52, 36, 20, 36, -36], [-4, -16, -4, 4, -4, 4], [139, 0, -29, 0, 7, 7], [-130, 0, -18, 0, 2, 2], [16, 80, 16, 96, 16, -16], [18, 0, -20, 0, 3, 3], [-7, -72, -7, -88, -7, 7], [20, -16, 20, 44, 20, -20], [-203, 0, -41, 0, 33, 33], [213, 0, 13, 0, 33, 33], [12, -1, 12, 188, 12, -12], [-51, 0, 79, 0, 1, 1], [-2, -3, -2, 126, -2, 2], [12, -72, 12, 80, 12, -12], [2, 36, 2, 142, 2, -2], [47, 0, 29, 0, -9, -9], [-94, 0, -86, 0, 30, 30], [0, 104, 0, 32, 0, 0], [-14, 27, -14, -62, -14, 14], [48, -8, 48, 31, 48, -48], [52, -32, 52, -4, 52, -52], [4, -88, 4, -112, 4, -4], [-108, 0, -34, 0, -21, -21], [213, 0, 23, 0, 49, 49], [190, 0, 46, 0, -30, -30], [-116, 0, -122, 0, -45, -45], [47, 56, 47, -136, 47, -47], [115, 0, 9, 0, 75, 75], [266, 0, -24, 0, 16, 16], [-179, 0, -91, 0, 17, 17], [-482, 0, -2, 0, 34, 34], [15, -56, 15, 184, 15, -15], [20, -16, 20, -228, 20, -20], [10, -32, 10, -194, 10, -10], [-36, -136, -36, -160, -36, 36], [8, -9, 8, -184, 8, -8], [-293, 0, -77, 0, -9, -9], [106, 108, 106, -74, 106, -106], [16, 24, 16, 239, 16, -16], [306, 0, 112, 0, 25, 25], [56, 81, 56, -168, 56, -56], [16, 128, 16, 160, 16, -16], [-62, 0, 124, 0, -45, -45], [-470, 0, 34, 0, -10, -10], [-42, 0, 86, 0, -86, -86], [252, 0, 18, 0, -35, -35], [0, 136, 0, 47, 0, 0], [350, 0, -80, 0, -48, -48], [-48, -137, -48, 96, -48, 48], [80, 40, 80, 95, 80, -80], [-16, 145, -16, -32, -16, 16], [-95, 0, 91, 0, -3, -3], [4, -55, 4, 20, 4, -4], [-131, 0, 117, 0, 65, 65], [198, 0, 70, 0, 58, 58], [100, 112, 100, -148, 100, -100], [34, 123, 34, 306, 34, -34], [12, -72, 12, 292, 12, -12], [-80, 56, -80, -172, -80, 80], [229, 0, -67, 0, 33, 33], [-54, 0, 184, 0, 17, 17], [-5, 0, -191, 0, -45, -45], [0, 52, 0, 88, 0, 0], [74, 0, -190, 0, -10, -10], [-20, -168, -20, -16, -20, 20], [347, 0, -13, 0, 39, 39], [-58, -131, -58, -10, -58, 58], [366, 0, 208, 0, 63, 63], [19, 0, 105, 0, -69, -69], [-266, 0, 22, 0, 42, 42], [31, -176, 31, 128, 31, -31], [50, 248, 50, -42, 50, -50], [591, 0, 45, 0, -81, -81], [-106, -205, -106, 6, -106, 106], [-142, 0, -22, 0, 78, 78], [-55, 256, -55, 96, -55, 55], [16, -104, 16, -119, 16, -16], [76, -16, 76, 164, 76, -76], [-214, 0, -12, 0, 75, 75], [-999, 0, -77, 0, 61, 61], [-170, 0, 38, 0, 42, 42], [342, 0, -216, 0, 7, 7], [-112, -80, -112, 232, -112, 112], [-807, 0, -109, 0, -83, -83], [438, 0, -40, 0, 112, 112], [2, 0, -16, 0, -48, -48], [79, 0, 13, 0, 47, 47], [-118, -155, -118, 266, -118, 118], [675, 0, -183, 0, 3, 3], [-418, 0, -144, 0, 80, 80], [454, 0, -10, 0, -134, -134], [-177, -224, -177, 176, -177, 177], [-184, 0, -58, 0, 41, 41], [126, 67, 126, 142, 126, -126], [-87, -104, -87, 376, -87, 87], [148, 104, 148, -176, 148, -148], [811, 0, 129, 0, 75, 75], [-42, -348, -42, -246, -42, 42], [-494, 0, 138, 0, -50, -50], [-114, 0, -268, 0, 133, 133], [-203, 0, -249, 0, -119, -119], [547, 0, -37, 0, 55, 55], [-56, -239, -56, -312, -56, 56], [502, 0, 40, 0, -41, -41], [-68, -1, -68, -564, -68, 68], [-20, 272, -20, 4, -20, 20], [-16, -72, -16, 116, -16, 16], [75, 0, 323, 0, 7, 7], [-28, -124, -28, -156, -28, 28], [-48, 72, -48, 255, -48, 48], [-14, 229, -14, 322, -14, 14], [-42, -12, -42, 74, -42, 42], [88, 0, 22, 0, 25, 25], [-246, 0, -94, 0, 214, 214], [-14, -80, -14, 22, -14, 14], [-846, 0, 44, 0, 3, 3], [192, 416, 192, -80, 192, -192], [-905, 0, 69, 0, -73, -73], [-286, 0, -208, 0, 80, 80], [327, 0, 5, 0, -113, -113], [238, 0, 126, 0, 50, 50], [-48, -40, -48, -193, -48, 48], [-68, 168, -68, 248, -68, 68], [-48, 180, -48, 312, -48, 48], [16, 80, 16, -264, 16, -16], [-210, 0, 112, 0, 16, 16], [1006, 0, 222, 0, -14, -14], [-64, 8, -64, 73, -64, 64], [-76, 0, -70, 0, 229, 229], [25, -144, 25, -368, 25, -25], [0, 0, 18, 0, -25, -25], [1642, 0, 130, 0, 54, 54], [-893, 0, 25, 0, 91, 91], [-80, 36, -80, -184, -80, 80], [-66, 0, -28, 0, 213, 213], [112, 424, 112, 57, 112, -112], [-347, 0, -89, 0, 209, 209], [86, -179, 86, -74, 86, -86], [-35, 0, -203, 0, 129, 129], [0, 32, 0, -352, 0, 0], [180, 160, 180, -308, 180, -180], [136, 151, 136, -216, 136, -136], [-1246, 0, -38, 0, -2, -2], [121, -16, 121, -208, 121, -121], [186, 309, 186, -566, 186, -186], [-56, 20, -56, 80, -56, 56], [291, 0, 91, 0, -121, -121], [-5, 0, 337, 0, -133, -133], [-128, -400, -128, -464, -128, 128], [312, 0, -138, 0, -151, -151], [64, 56, 64, -817, 64, -64], [-216, -432, -216, -48, -216, 216], [27, 0, -239, 0, 171, 171], [218, 0, -56, 0, -160, -160], [42, 0, 98, 0, -10, -10], [-831, 0, -21, 0, -11, -11], [76, 256, 76, -452, 76, -76], [-126, -27, -126, -622, -126, 126], [-498, 0, 112, 0, 80, 80], [-390, 0, -142, 0, 6, 6], [82, -464, 82, -170, 82, -82], [79, 120, 79, -40, 79, -79], [-118, 0, -172, 0, 59, 59], [202, 443, 202, 106, 202, -202], [48, -280, 48, -372, 48, -48], [-371, 0, 325, 0, -79, -79], [1480, 0, -214, 0, 95, 95], [-822, 0, -88, 0, -144, -144], [-848, 0, -290, 0, -31, -31], [1087, 0, 237, 0, 199, 199], [-97, -128, -97, -32, -97, 97], [316, 248, 316, 96, 316, -316], [-470, 0, -152, 0, 208, 208], [-864, 0, -174, 0, 7, 7], [-54, -683, -54, -390, -54, 54], [207, -32, 207, 528, 207, -207], [172, 460, 172, 380, 172, -172], [140, 128, 140, 556, 140, -140], [280, 0, 86, 0, -55, -55], [-998, 0, -334, 0, -250, -250], [251, 0, -31, 0, 163, 163], [-746, 0, -234, 0, 170, 170], [-8, 256, -8, 632, -8, 8], [341, 0, 173, 0, 33, 33], [-22, 155, -22, -86, -22, 22], [1268, 0, 62, 0, -245, -245], [731, 0, 83, 0, -153, -153], [-1049, 0, -187, 0, -49, -49], [698, 0, 322, 0, -186, -186], [-100, 104, -100, 456, -100, 100], [70, -323, 70, 534, 70, -70], [70, 0, 134, 0, -102, -102], [-54, 0, -140, 0, -245, -245], [-64, -392, -64, -465, -64, 64], [16, 184, 16, -480, 16, -16], [20, -40, 20, -184, 20, -20], [140, 0, -314, 0, -109, -109], [334, 0, 14, 0, 114, 114], [-694, 0, -62, 0, 406, 406], [-146, 0, -204, 0, -235, -235], [-625, 0, -451, 0, -281, -281], [-838, 0, -280, 0, 96, 96], [2026, 0, 212, 0, 43, 43], [805, 0, 221, 0, 81, 81], [-1227, 0, 39, 0, 89, 89], [-1534, 0, -6, 0, -98, -98], [128, -56, 128, -663, 128, -128], [102, 227, 102, 678, 102, -102], [873, 0, -13, 0, -155, -155], [254, 324, 254, -590, 254, -254], [-1850, 0, 60, 0, 205, 205], [-40, -463, -40, -200, -40, 40], [176, -152, 176, 185, 176, -176], [825, 0, -557, 0, 205, 205], [-18, -8, -18, 1338, -18, 18], [-146, 0, -274, 0, -270, -270], [-64, -584, -64, -1025, -64, 64], [302, 0, 240, 0, -176, -176], [-8, -345, -8, -1080, -8, 8], [1545, 0, 179, 0, 149, 149], [320, 616, 320, -481, 320, -320], [336, 321, 336, 16, 336, -336], [328, 620, 328, 192, 328, -328], [116, -224, 116, 116, 116, -116], [-224, -264, -224, -448, -224, 224], [-402, 0, 176, 0, -241, -241], [-116, -577, -116, -836, -116, 116], [0, 248, 0, 1023, 0, 0], [-219, 0, 221, 0, 241, 241], [334, 0, 606, 0, 114, 114], [1794, 0, -64, 0, 57, 57], [-96, 392, -96, 220, -96, 96], [-80, 0, 30, 0, 257, 257], [-80, -344, -80, -247, -80, 80], [-66, -381, -66, 78, -66, 66], [432, 688, 432, 24, 432, -432], [-70, -320, -70, 894, -70, 70], [-621, 0, 153, 0, -205, -205], [192, 600, 192, 324, 192, -192], [-909, 0, 43, 0, 167, 167], [-55, 88, -55, 248, -55, 55], [70, 781, 70, 806, 70, -70], [-220, -116, -220, 660, -220, 220], [-2430, 0, 10, 0, -98, -98], [165, 0, -9, 0, -135, -135], [169, 152, 169, 696, 169, -169], [352, 128, 352, 208, 352, -352], [-759, 0, -221, 0, -323, -323], [170, 0, 242, 0, -42, -42], [-120, -223, -120, -72, -120, 120], [-74, -212, -74, -182, -74, 74], [1881, 0, -381, 0, 21, 21], [200, 464, 200, 176, 200, -200]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1280_e_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1280_3_e_f();".
// 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_3_e_f(:prec:=6)
    chi := MakeCharacter_1280_e();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    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_3_e_f();".
// 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_3_e_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1280_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<3,R![64, 0, 224, 0, 36, 0, 1]>,<7,R![8, -40, 6, 1]>,<11,R![-1600, -272, 4, 1]>,<13,R![-832, -208, 0, 1]>],Snew);
    return Vf;
end function;