
// Make newform 260.6.a.a in Magma, downloaded from the LMFDB on 05 February 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_260_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_260_6_a_a();".
// 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_260_6_a_a();".
// 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_260_a();"
function MakeCharacter_260_a()
    N := 260;
    order := 1;
    char_gens := [131, 157, 41];
    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_260_a_Hecke(Kf)
    return MakeCharacter_260_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 := 6;
    raw_aps := [[0], [-14], [-25], [-212], [-402], [-169], [-1022], [-2090], [-1402], [-3022], [-5126], [5966], [-10038], [-21594], [10980], [8626], [-28806], [-2446], [-11596], [59882], [81834], [-27620], [116960], [-105614], [-306], [44158], [-95410], [-158250], [-88726], [-92638], [-147918], [-211948], [145422], [-140504], [251026], [-413018], [-584838], [439420], [-244508], [-222982], [-439892], [345370], [-609280], [-443058], [-478230], [-913184], [660108], [428052], [-1374948], [280826], [114106], [-1097658], [174314], [-654288], [818530], [-454686], [-671402], [1464670], [340050], [-1891302], [1977374], [588966], [-1963752], [2223444], [1722234], [994654], [604162], [628298], [3328598], [4210514], [3875554], [-2676006], [-3149858], [-1231870], [-889450], [-1936324], [2826790], [-128042], [-1236646], [-5097758], [-686112], [4763130], [-5476110], [-1634630], [-2283488], [981186], [-3410886], [4463382], [-1350550], [2333888], [-4021062], [-5528350], [6286528], [5247696], [-8605418], [4778482], [-742646], [-11086330], [-9126454], [-3167414], [12637830], [-12691434], [2171190], [1540710], [6865104], [4042898], [7388844], [-5388994], [-15659948], [1920490], [-12464258], [-259382], [-16761242], [9465026], [17587902], [-4879470], [17863984], [-14582454], [7530762], [4172760], [14319698], [8870914], [-10574230], [-987660], [12052010], [-23392458], [20370650], [11189584], [24861874], [8951762], [18937594], [-11374588], [3897868], [-21404062], [-4825902], [-23285398], [-11007506], [1167800], [-21904774], [-15321986], [17948554], [-6683230], [8153806], [32569536], [-8439886], [22128730], [-23769866], [22535570], [26443344], [-14240340], [-42169086], [1808646], [-19847274], [-26084554], [3685666], [4698448], [-15493724], [38671994], [9524370], [39281154], [5392984], [-47687694], [-51286192], [-7869276], [-53602654], [50518400], [-31390112], [-7574086], [-16708358], [-749310], [-44457474], [23227274], [-38121092], [-28853206], [54587944], [41087994], [51712118], [-19622462], [65566662], [33245766], [-52271372], [53614480], [43626090], [25270086], [18517312], [-15726054], [-36763750], [3770440], [-36115662], [-38201954], [-37021022], [33162888], [49756916], [-31269622], [-88046230], [14825834], [8957978], [-74445406], [858114], [-81934814], [70701506], [-38562896], [3130618], [11318262], [-67088790], [43997122], [86650734], [34095538], [56074906], [105834992], [45639434], [-37884550], [-44312326], [69303024], [-76267770], [33151042], [45431846], [-110481966], [24719352], [-75149134], [-74822230], [-62416086], [-115583870], [-62829788], [51228378], [-97022150], [-46412854], [8464364], [-112817782], [78336902], [-3991670], [-69574992], [106358882], [53515626], [-165368190], [-39995528], [48263986], [44400966], [79244676], [-66853032], [-20884776], [74533584], [-114814574], [-111327278], [-99235482], [-44229448], [-124404068], [-106721402], [-114939602], [69355942], [-73038890], [124610194], [-80715636], [103997290], [41881770], [24936594], [-19265990], [-21211780], [56587330], [184299994], [-110396242], [107602158], [-96489990], [-75539486], [-58040078], [-160105320], [-64858350], [-62849358], [-8759372], [76745234], [-47240042], [23176028], [150699766], [-118527600], [189779546], [37650692], [5851124], [-215294214], [84198434], [42736144], [49823434], [110605070], [-722434], [-28899598], [-203239088], [-182163420], [-118738542], [7114746], [136790706], [-61841890], [-287895390], [34909078], [-22252194], [-168215778], [217375146], [-212520210], [42581096], [136963458], [264814256], [229481552], [-175376806], [130520562], [-168611752], [-76856838], [-172332476], [-56142030], [-63802686], [137966246], [50440122], [298714570], [98255274], [-67086414], [29893262], [-211412510], [177633836], [49161646], [233543374], [-371444222], [-290935694], [137404722], [272148992], [74545930], [31218066], [183931784], [271939050], [-108091570], [393079778], [438167896], [-14988302], [71032602], [-446508030], [-388632366], [-285989836], [-313252028], [-112915310], [343189572], [-110187926], [258014430], [233124586], [-299229758], [-128685062], [-297744958], [320940154], [-1009444], [60091106], [-202553204], [163290470], [120441008], [456938550], [344541042], [-58034558], [132125790], [-536679838], [-161661906], [-228339354], [-314034958], [393794178], [426172298], [307843106], [-218368212], [483319430], [280367950], [66500478], [-469429194], [37939210], [-147735830], [398203858], [-465201920], [201888874], [-169692156], [-37506412], [-11304232], [558951066], [306861624], [-319650542], [-610880082], [467647476], [-205405610], [606807894], [137066890], [-526583246], [309778026], [605800532], [173251778], [-634105174], [-690738720], [-55710590], [-295829230], [-403143392], [-161429074], [-238098438], [-21510498], [318125402], [447244918], [-50411706], [359934266], [312475598], [-560250090], [263532020], [-269236406], [-459596782], [28323490], [147960164], [-484725702], [-732168222], [301452168], [-27584530], [-313292742], [-600075268], [434614122], [429292106], [-490558230], [802150362], [-173029776], [-33693326], [-271667426], [135643246], [567538174], [25667602], [-406982146], [190277298], [-699865558], [-103149232], [-119573048], [-337420194], [-181237986], [-536236874], [32754322], [-92925834], [256773804]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_260_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_260_6_a_a();".
// 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_260_6_a_a(:prec:=1)
    chi := MakeCharacter_260_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 6));
    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_260_6_a_a();".
// 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_260_6_a_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_260_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![14, 1]>],Snew);
    return Vf;
end function;