
// Make newform 1440.3.e.b in Magma, downloaded from the LMFDB on 20 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1440_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1440_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_1440_3_e_b();".
// 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_1440_3_e_b();".
// 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, 3, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 2, 0, 2], [0, 6, 0, 2], [3, 0, 2, 0]];
    Rf_basisdens := [1, 1, 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_1440_e();"
function MakeCharacter_1440_e()
    N := 1440;
    order := 2;
    char_gens := [991, 901, 641, 577];
    v := [1, 2, 2, 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_1440_e_Hecke();"
function MakeCharacter_1440_e_Hecke( : Kf := false)
    N := 1440;
    order := 2;
    char_gens := [991, 901, 641, 577];
    char_values := [[-1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 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 := 3;
    raw_aps := [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1], [0, 1, -4, 0], [0, 3, 1, 0], [16, 0, 0, 2], [10, 0, 0, -4], [0, 3, 3, 0], [0, -1, 10, 0], [18, 0, 0, 12], [0, -2, -8, 0], [28, 0, 0, -2], [-40, 0, 0, 14], [0, 1, 8, 0], [0, 1, -14, 0], [-32, 0, 0, 14], [0, -1, -29, 0], [16, 0, 0, -22], [0, 11, -28, 0], [0, -16, -34, 0], [-2, 0, 0, 60], [0, 24, 36, 0], [0, 17, 2, 0], [30, 0, 0, 0], [66, 0, 0, -24], [-34, 0, 0, -32], [0, -39, -22, 0], [0, 13, 4, 0], [-40, 0, 0, 2], [26, 0, 0, 20], [0, 25, 40, 0], [0, 33, 3, 0], [-38, 0, 0, -28], [0, -27, -55, 0], [136, 0, 0, 30], [0, -12, 38, 0], [-212, 0, 0, 30], [0, 29, 56, 0], [0, -23, -22, 0], [-12, 0, 0, 66], [0, 17, -67, 0], [130, 0, 0, -48], [0, 6, -48, 0], [-130, 0, 0, -36], [-140, 0, 0, 106], [0, -78, -14, 0], [0, -65, -59, 0], [0, 7, 4, 0], [0, 23, -34, 0], [-130, 0, 0, 132], [70, 0, 0, -48], [0, 12, 120, 0], [144, 0, 0, 42], [0, -29, -79, 0], [-366, 0, 0, -36], [0, -15, 36, 0], [-160, 0, 0, -154], [0, -22, 56, 0], [168, 0, 0, 66], [-128, 0, 0, 150], [0, 27, -142, 0], [340, 0, 0, -30], [0, 75, 60, 0], [0, -4, 110, 0], [-310, 0, 0, -56], [-28, 0, 0, -6], [0, 21, 27, 0], [-54, 0, 0, 72], [0, 51, 146, 0], [-90, 0, 0, 12], [134, 0, 0, -88], [0, 66, -70, 0], [0, -39, 68, 0], [-136, 0, 0, -174], [0, 29, 157, 0], [0, 21, -56, 0], [304, 0, 0, 102], [-16, 0, 0, -222], [246, 0, 0, -120], [284, 0, 0, -146], [0, 81, -107, 0], [0, 0, 0, 90], [0, -130, 56, 0], [234, 0, 0, -192], [0, 162, 106, 0], [0, -7, 118, 0], [332, 0, 0, -38], [-390, 0, 0, 72], [134, 0, 0, -88], [0, 157, 26, 0], [0, 23, 122, 0], [0, -96, 220, 0], [0, -103, 32, 0], [0, -85, -79, 0], [0, -29, 59, 0], [0, 11, 202, 0], [-142, 0, 0, -228], [54, 0, 0, -360], [0, -133, -70, 0], [650, 0, 0, -184], [0, -19, 110, 0], [120, 0, 0, -210], [0, -73, 248, 0], [84, 0, 0, 258], [0, 57, -177, 0], [-490, 0, 0, -84], [0, 191, -70, 0], [46, 0, 0, -176], [0, 94, 2, 0], [-8, 0, 0, -14], [0, 171, -174, 0], [324, 0, 0, 78], [182, 0, 0, 192], [0, 45, 141, 0], [0, 24, -38, 0], [248, 0, 0, -178], [0, -9, 202, 0], [0, 11, 212, 0], [676, 0, 0, 10], [0, -283, -191, 0], [992, 0, 0, -6], [-790, 0, 0, 48], [-76, 0, 0, -390], [0, 227, 52, 0], [0, -49, -55, 0], [480, 0, 0, 294], [86, 0, 0, -420], [0, 268, 152, 0], [0, 177, 140, 0], [1004, 0, 0, 46], [0, -125, -193, 0], [0, -111, -72, 0], [0, 138, -220, 0], [-128, 0, 0, 218], [422, 0, 0, -296], [-590, 0, 0, -80], [-436, 0, 0, 210], [0, 135, 100, 0], [-628, 0, 0, 194], [-1178, 0, 0, -120], [0, -111, 19, 0], [688, 0, 0, 6], [0, 109, 58, 0], [0, 279, 254, 0], [432, 0, 0, -342], [0, 210, -18, 0], [-460, 0, 0, 366], [226, 0, 0, -116], [0, 73, -323, 0], [0, -81, -218, 0], [-580, 0, 0, -194], [160, 0, 0, 54], [0, 165, 300, 0], [0, -237, -304, 0], [0, -229, -296, 0], [0, -26, -548, 0], [0, 74, 46, 0], [52, 0, 0, 306], [-94, 0, 0, 24], [-626, 0, 0, 80], [0, 257, -16, 0], [-754, 0, 0, 144], [0, -293, -386, 0], [0, -1, -95, 0], [1502, 0, 0, -56], [0, 349, 304, 0], [0, -94, 556, 0], [72, 0, 0, 474], [274, 0, 0, -688], [364, 0, 0, 162], [0, -117, 635, 0], [-1142, 0, 0, -392], [0, -348, -314, 0], [1022, 0, 0, -148], [0, 320, -184, 0], [406, 0, 0, 88], [0, -67, 331, 0], [1126, 0, 0, -24], [0, -3, -294, 0], [-128, 0, 0, -246], [0, 393, 204, 0], [0, 77, 239, 0], [-1136, 0, 0, -14], [-510, 0, 0, 132], [0, 435, 82, 0], [514, 0, 0, 364], [-248, 0, 0, 18], [0, 63, 290, 0], [-1260, 0, 0, 54], [0, 242, 296, 0], [-314, 0, 0, -388], [0, 29, -142, 0], [0, -277, 149, 0], [-480, 0, 0, -138], [0, -11, 632, 0], [1014, 0, 0, 144], [-80, 0, 0, 506], [764, 0, 0, 326], [-610, 0, 0, -192], [0, 75, 298, 0], [-230, 0, 0, 36], [0, 10, 376, 0], [-920, 0, 0, 442], [298, 0, 0, 712], [0, 215, -685, 0], [1564, 0, 0, 362], [0, -40, 368, 0], [0, 77, 298, 0], [486, 0, 0, 72], [0, -371, -517, 0], [-314, 0, 0, -572], [64, 0, 0, -154], [0, 283, -296, 0], [0, 51, 718, 0], [0, 130, -362, 0], [-576, 0, 0, -6], [0, -63, 240, 0], [-642, 0, 0, -192], [0, -355, 190, 0], [-288, 0, 0, -834], [-96, 0, 0, 186], [0, -422, -194, 0], [1334, 0, 0, -616], [0, -121, 512, 0], [0, 97, -196, 0], [672, 0, 0, -486], [-998, 0, 0, -516], [0, -260, -356, 0], [0, -141, 22, 0], [0, 27, 661, 0], [-456, 0, 0, -438], [0, 231, -33, 0], [0, 6, -388, 0], [1840, 0, 0, 198], [0, -199, -628, 0], [0, -437, -644, 0], [92, 0, 0, -1122], [1864, 0, 0, 406], [0, -121, 71, 0], [0, -4, 758, 0], [0, -299, 278, 0], [0, 341, -313, 0], [0, 267, 420, 0], [638, 0, 0, -620], [-1354, 0, 0, -392], [0, 414, 30, 0], [0, 9, 176, 0], [0, 313, -833, 0], [0, -99, 201, 0], [0, -81, 618, 0], [2352, 0, 0, -30], [-954, 0, 0, -216], [0, -265, 464, 0], [-1492, 0, 0, 446], [260, 0, 0, 674], [0, -451, -91, 0], [58, 0, 0, -984], [0, 225, 370, 0], [760, 0, 0, 542], [1442, 0, 0, -320], [0, -271, 698, 0], [0, -325, 706, 0], [302, 0, 0, 820], [-8, 0, 0, 690], [2170, 0, 0, -196], [0, -441, 63, 0], [58, 0, 0, -236], [-1050, 0, 0, -552], [0, 503, 218, 0], [-452, 0, 0, -726], [-646, 0, 0, 264], [0, 9, -906, 0], [-574, 0, 0, -88], [0, -124, -244, 0], [-434, 0, 0, -76], [0, -125, 892, 0], [0, -495, -588, 0], [-890, 0, 0, -1156], [456, 0, 0, -606], [0, -235, 383, 0], [0, -389, -14, 0], [0, 416, 454, 0], [0, -15, 14, 0], [-766, 0, 0, -592], [0, 77, 178, 0], [0, 522, 744, 0], [-2058, 0, 0, -252], [1572, 0, 0, -246], [0, -658, -22, 0], [628, 0, 0, -590], [-2240, 0, 0, -42], [0, 69, -1192, 0], [258, 0, 0, -12], [0, -189, -447, 0], [-1316, 0, 0, -66], [-424, 0, 0, 414], [0, 266, 844, 0], [-204, 0, 0, -606], [0, -29, -965, 0], [0, -307, -46, 0], [-986, 0, 0, 444], [-1892, 0, 0, -582], [0, -236, -128, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1440_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1440_3_e_b();".
// 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_1440_3_e_b(:prec:=4)
    chi := MakeCharacter_1440_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_1440_3_e_b();".
// 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_1440_3_e_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1440_e();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<7,R![15376, 0, 252, 0, 1]>,<17,R![20, -20, 1]>],Snew);
    return Vf;
end function;