
// Make newform 1445.4.a.d in Magma, downloaded from the LMFDB on 27 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1445_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_1445_4_a_d();".
// 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_1445_4_a_d();".
// 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_1445_a();"
function MakeCharacter_1445_a()
    N := 1445;
    order := 1;
    char_gens := [1157, 581];
    v := [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_1445_a_Hecke( : Kf := Kf)
    return MakeCharacter_1445_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 := [[-1], [-8], [-5], [-14], [20], [-58], [0], [-80], [118], [-126], [-70], [134], [-100], [-272], [-464], [-642], [180], [110], [-924], [-90], [-828], [-1334], [-552], [1490], [-1376], [642], [-1248], [564], [-1214], [1388], [-1136], [2620], [1886], [4], [870], [1368], [-3374], [1048], [-1266], [362], [-1720], [1910], [-4208], [-2112], [-2074], [-4466], [2540], [-3832], [6096], [-2650], [-4228], [-80], [-5980], [312], [434], [-1752], [-1206], [5112], [3154], [-4702], [1388], [-7318], [216], [7170], [-1472], [1526], [2708], [-10516], [-2704], [-9670], [-7938], [-2240], [-6594], [-4258], [8984], [-2912], [7950], [-12634], [10740], [2950], [-5944], [13682], [410], [2558], [-5946], [10852], [-3284], [-4106], [-8462], [3992], [3164], [-4866], [2926], [15128], [-18684], [-8562], [16950], [-17820], [-13548], [-7970], [22044], [20166], [-1712], [7270], [26200], [-1794], [-27876], [-9362], [13600], [-5200], [21854], [-3558], [804], [-4344], [24488], [15500], [-10928], [12416], [-8782], [6020], [-6342], [-18632], [-21186], [-15408], [3940], [-14798], [-14926], [-7146], [19136], [-37922], [34480], [7062], [16630], [3314], [22902], [-22690], [2418], [8484], [-5346], [11236], [-28880], [21110], [33958], [8436], [-8210], [4126], [-20838], [-2864], [11980], [-13728], [8506], [-48600], [-24668], [-14086], [-52364], [-34570], [45480], [-1284], [-10166], [47310], [1284], [40602], [39624], [-8772], [17974], [-47558], [-5490], [45286], [-2964], [15318], [-19100], [-27398], [2110], [-278], [15800], [-58056], [23360], [1350], [20848], [-64330], [7856], [54900], [68982], [62694], [26088], [41490], [53694], [47272], [45316], [-29310], [32972], [57408], [4208], [2478], [46504], [58892], [-22640], [-45482], [-17284], [-52248], [31734], [-43270], [2626], [-55470], [9900], [56034], [-86080], [6028], [-2496], [-15068], [34064], [-32322], [18858], [36284], [7606], [7860], [-11944], [-37278], [-76294], [48262], [-12818], [10194], [64690], [31462], [93156], [-78110], [-34628], [-25054], [23944], [22640], [-81682], [25424], [31208], [46318], [7732], [-85176], [57596], [6102], [61684], [-2832], [-47952], [-26948], [-10728], [-46170], [96108], [-21166], [31534], [26080], [17660], [11448], [-58374], [-107320], [-111536], [103336], [36498], [39520], [-94290], [3704], [-65266], [-83086], [17342], [-36624], [53694], [-14102], [56664], [-100520], [60130], [56222], [-65792], [-71958], [50050], [-13384], [33638], [53040], [2114], [-36432], [-8376], [87490], [-86398], [-8972], [84352], [99010], [-8814], [-10782], [-24756], [-89808], [-3368], [-130434], [-25440], [-12490], [-101110], [104664], [-38742], [37260], [106702], [-22614], [-146728], [-53338], [-31544], [-17656], [-52838], [85434], [141206], [-44728], [-80960], [-13624], [26336], [-146874], [-147760], [-4718], [-8002], [-123846], [65380], [-84452], [-14384], [-69470], [-113640], [-151910], [-70988], [-168730], [-137320], [-122536], [147142], [34912], [-122752], [-8642], [83324], [-106332], [-165366], [-78138], [145770], [-93994], [-187066], [-48648], [151200], [91356], [-37710], [-5148], [40600], [121584], [48838], [1934], [108414], [-41368], [129342], [116936], [95790], [-159244], [66290], [-139114], [-189052], [102944], [-131578], [121502], [-14010], [56342], [-75600], [187560], [-126576], [178488], [-33074], [199560], [1056], [-89104], [-65476], [-85622], [-162606], [27992], [106700], [-65292], [-137524], [-39162], [71090], [-67528], [-157414], [217104], [38070], [-210302], [-83630], [-256014], [-142310], [-180822], [86314], [184044], [-87464], [-58902], [91368], [105754], [85912], [-68304], [-33016], [-102522], [85460], [-167264], [-174672], [-44112], [16000], [-223830], [115660], [64522], [-65786], [-3338], [147296], [91496], [78070], [127010], [-71926], [-82578], [165328], [69064], [15548], [-72486], [284952], [-184620], [206086], [288550], [176026], [86414], [303656], [70992], [37090], [-4454], [-75806], [29240], [42752], [-203814], [267732], [230136], [116112], [-28034]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1445_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1445_4_a_d();".
// 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_1445_4_a_d(:prec:=1)
    chi := MakeCharacter_1445_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_1445_4_a_d();".
// 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_1445_4_a_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1445_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![1, 1]>,<3,R![8, 1]>],Snew);
    return Vf;
end function;