
// Make newform 720.4.a.bb in Magma, downloaded from the LMFDB on 30 May 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_720_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_720_4_a_bb();".
// 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_720_4_a_bb();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_720_a();"
function MakeCharacter_720_a()
    N := 720;
    order := 1;
    char_gens := [271, 181, 641, 577];
    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_720_a_Hecke( : Kf := Kf)
    return MakeCharacter_720_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], [5], [28], [-24], [-70], [-102], [-20], [-72], [-306], [136], [-214], [150], [292], [-72], [414], [-744], [-418], [-188], [480], [434], [-1352], [-612], [30], [-286], [1542], [-1172], [1956], [-1858], [-174], [2068], [312], [-2646], [1276], [3198], [760], [-166], [-3020], [-984], [-1962], [576], [-1210], [3384], [-2038], [-4098], [2248], [-3260], [2980], [-3180], [3374], [-1950], [2232], [-1822], [1488], [2994], [-2472], [-3954], [2176], [1034], [6654], [1756], [-3234], [-2036], [-96], [1202], [3798], [5668], [-454], [-5604], [-11266], [6426], [6936], [388], [-8062], [3388], [6984], [2526], [6146], [-9786], [-886], [-11352], [10190], [2448], [-7078], [18088], [3852], [-6522], [2090], [9894], [-3044], [10236], [11496], [15316], [-11616], [-14996], [-21648], [-3378], [16158], [76], [9278], [-14564], [-2154], [-8700], [-4194], [8020], [-2686], [3012], [15522], [19224], [-6502], [-29396], [-10006], [-23118], [-14036], [4288], [-1314], [628], [-10944], [-1098], [312], [8678], [-14470], [11838], [-25548], [18412], [8814], [-17314], [-768], [18196], [-18142], [13660], [-12768], [-22952], [15818], [18558], [14978], [-8946], [18436], [-16314], [25446], [-42740], [-29946], [32596], [3804], [3278], [-5784], [17306], [-31134], [10780], [3456], [2618], [26550], [-27596], [-37848], [4804], [28608], [40768], [-27642], [28106], [-14730], [-9564], [53898], [-15140], [23808], [-23094], [7584], [26752], [7778], [-9886], [-39858], [37032], [54902], [19512], [-9694], [-38936], [-57762], [63676], [36750], [-36380], [30326], [43132], [34536], [-30886], [-65142], [29640], [-15330], [58778], [45796], [-45718], [-12456], [-59542], [-2388], [-32876], [30246], [-38244], [32202], [-51118], [59690], [59778], [-18720], [-47754], [-56504], [33554], [50834], [31224], [14118], [1384], [-72252], [23214], [-22748], [-70294], [-52530], [-73988], [69612], [14784], [-67030], [-48524], [-14586], [-93216], [35622], [51662], [16504], [86910], [-12692], [-10260], [-79234], [4074], [91008], [-27644], [-14280], [-109702], [-21260], [15520], [-24738], [-77924], [-94752], [-101230], [-40818], [-34392], [-87408], [3252], [65332], [10084], [-13618], [22458], [72192], [-33500], [-34224], [-7820], [-36336], [-88414], [-95682], [17784], [-41878], [-15834], [-101832], [-28138], [-74612], [-64530], [68978], [-33788], [5844], [88958], [-36910], [-46062], [-13412], [75942], [-68538], [29932], [54174], [-109594], [18412], [102242], [-73304], [-42310], [-21956], [-32052], [26990], [34298], [-99048], [-9168], [-102872], [-41952], [108782], [88372], [3048], [20882], [-40722], [52936], [3294], [55494], [124956], [9330], [-164184], [109874], [8886], [107800], [91470], [22776], [157948], [99074], [30966], [-6512], [133308], [-98876], [9266], [107268], [152150], [-1824], [-66094], [82992], [61110], [-165930], [17260], [-159072], [-144598], [-174336], [-62712], [12410], [-99234], [66220], [36146], [25566], [24508], [-161166], [97634], [161044], [-59276], [-34680], [70206], [-58906], [-102522], [100984], [-141780], [73852], [-63948], [-119578], [-129078], [-56038], [-98156], [-89998], [159810], [-11322], [-177272], [-204042], [-2112], [79742], [-190508], [150600], [135534], [63460], [-35638], [92574], [219796], [136070], [-80526], [216048], [-156072], [-18270], [72936], [-49534], [58086], [-121320], [-204072], [-23420], [-156070], [151206], [-62084], [49610], [-240000], [5356], [-152328], [-152538], [-36632], [-37150], [194976], [-76032], [-234286], [-100170], [-118390], [-33834], [-188118], [150748], [-15414], [-2396], [-39384], [137032], [121898], [13444], [-227904], [386], [-34722], [5640], [6196], [90360], [72986], [-70880], [-77946], [80788], [-75282], [131222], [92130], [208324], [22170], [-264426], [213136], [167906], [-208698], [-139724], [-231816], [-160606], [-65298], [-167388], [-193940], [-277390], [-77010], [8736], [-57764], [131346], [77496], [112086], [260258], [220488], [-298512], [-166318], [90294], [-264996], [-28842], [135700], [-198600]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_720_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_720_4_a_bb();".
// 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_720_4_a_bb(:prec:=1)
    chi := MakeCharacter_720_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_720_4_a_bb();".
// 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_720_4_a_bb( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_720_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![-28, 1]>,<11,R![24, 1]>],Snew);
    return Vf;
end function;