
// Make newform 1275.4.a.e in Magma, downloaded from the LMFDB on 16 March 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_1275_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_1275_4_a_e();".
// 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_1275_4_a_e();".
// 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_1275_a();"
function MakeCharacter_1275_a()
    N := 1275;
    order := 1;
    char_gens := [851, 52, 751];
    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;

function MakeCharacter_1275_a_Hecke( : Kf := Kf)
    return MakeCharacter_1275_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], [-3], [0], [2], [-48], [14], [17], [92], [122], [-36], [-182], [-76], [294], [428], [12], [234], [-540], [-820], [-700], [794], [1038], [858], [-1052], [1102], [-710], [-1210], [-644], [256], [-1248], [350], [328], [-1952], [-2634], [1864], [-286], [-1624], [-2542], [-684], [-542], [836], [-3444], [-3284], [-340], [1498], [1176], [-2450], [1064], [2244], [-516], [-2922], [-3114], [4124], [-2034], [996], [3246], [-932], [-3884], [-1936], [-872], [3198], [1936], [5718], [-684], [-290], [11050], [-992], [2860], [-6298], [3508], [-2406], [1842], [3264], [-7354], [-11322], [12796], [420], [6426], [13212], [-6242], [-5194], [15956], [-15254], [-5538], [-11342], [982], [2492], [-5498], [-4998], [-7586], [-5900], [19404], [2586], [-10106], [-76], [8096], [-15942], [-13742], [11942], [6012], [6420], [-1576], [-15318], [-13220], [2794], [-14756], [2846], [16820], [-13314], [2880], [-24854], [-6122], [-17398], [-2922], [9660], [2788], [-16290], [16588], [-22364], [19356], [-4220], [-12070], [5914], [27624], [-29132], [-20336], [17142], [22784], [58], [-712], [-23050], [-38708], [11034], [7502], [20954], [8186], [-5798], [39950], [-20656], [3722], [6518], [-33068], [-5328], [-25874], [-29184], [-9394], [-32062], [-9152], [19706], [28684], [6320], [-49272], [-16462], [-21300], [16590], [36184], [15626], [36672], [-15810], [-48646], [43872], [-38552], [52954], [46428], [-40980], [10206], [44934], [20526], [-29260], [6862], [-40944], [8172], [21194], [-50574], [6890], [-23384], [-37006], [-460], [15552], [24612], [-51962], [-43524], [-53496], [-10148], [-22986], [3484], [-4986], [-36940], [-67116], [-66122], [25830], [-17138], [14356], [27628], [46466], [-5628], [13918], [70762], [-55028], [-2802], [44336], [-60784], [52890], [-25934], [-28718], [-26948], [46150], [-28316], [25020], [-6390], [-44308], [-9494], [-42294], [53490], [-50244], [49378], [-12626], [-14524], [-36534], [76710], [-14758], [8078], [75354], [-66546], [-13322], [-7724], [-65270], [-78930], [27222], [-1832], [-27660], [-40106], [29900], [15428], [-50826], [12404], [-37928], [52454], [86128], [94512], [-1808], [74828], [57164], [33168], [-71010], [75486], [20782], [7438], [28492], [-93020], [-100560], [31922], [-11006], [2756], [-90526], [-88842], [63628], [-140], [10604], [39032], [69526], [-47010], [111444], [72700], [-29480], [-3430], [-112524], [40174], [-37226], [-23788], [-30162], [65832], [-26524], [127286], [-55820], [121682], [12772], [47412], [72706], [86326], [-7652], [-66132], [125298], [-75466], [90986], [66000], [-37224], [126042], [-145848], [22760], [147790], [-116076], [106884], [-106682], [58520], [-15492], [-42300], [-23076], [86274], [-29588], [30484], [-94182], [-154986], [118694], [127332], [66452], [89674], [-39508], [19444], [-52872], [161578], [-73750], [-138820], [72342], [108268], [123616], [-109850], [-14036], [138838], [-79642], [-173826], [-144892], [14154], [52514], [119324], [38274], [14250], [-31752], [34472], [186126], [149184], [-153400], [-12120], [93750], [-68124], [81668], [-85368], [-51206], [5118], [58234], [-16436], [-176562], [-48954], [102792], [44228], [86202], [-11052], [27772], [-25724], [-202026], [-137424], [-206316], [-131326], [8346], [23158], [-86002], [164742], [-206176], [-107972], [4050], [178764], [-203316], [57362], [74412], [63444], [53748], [-68262], [-166924], [230736], [175022], [150284], [36544], [87978], [195462], [-222672], [4144], [210444], [52898], [96686], [247790], [-206090], [7908], [-22518], [116954], [-3754], [-33596], [79734], [266960], [-116086], [173484], [-70616], [16610], [51880], [-49756], [-154524], [212700], [-84526], [-181040], [185606], [131504], [-2858], [-22148], [6398], [49932], [33002], [209026], [-64526], [-180326], [51954], [17820], [86100], [221286], [37134], [203068], [27680], [-150830], [93912], [248158], [2366], [-990], [-201180], [-194042], [177344], [223806], [-230780], [-59926], [288190], [-233112], [-64526], [-260228], [-47406]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1275_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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