
// Make newform 560.6.a.f in Magma, downloaded from the LMFDB on 21 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_560_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_560_6_a_f();".
// 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_560_6_a_f();".
// 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_560_a();"
function MakeCharacter_560_a()
    N := 560;
    order := 1;
    char_gens := [351, 421, 337, 241];
    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_560_a_Hecke( : Kf := Kf)
    return MakeCharacter_560_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], [11], [-25], [-49], [267], [-1087], [-513], [802], [1290], [1779], [2584], [13862], [-11904], [598], [17019], [27852], [-30912], [-1780], [-25052], [51984], [47690], [102121], [83676], [-32400], [-148645], [-41310], [-108785], [106098], [-124111], [192834], [-99248], [276810], [237744], [-160478], [-99678], [206017], [581150], [-346610], [448887], [-262509], [111012], [112772], [731991], [-186040], [121356], [-648584], [149773], [1100959], [695127], [463736], [-1576536], [512037], [989330], [61230], [1338870], [1656186], [-750606], [557908], [1772558], [-1098933], [320569], [-1623369], [-995087], [-1343982], [1919705], [-1913658], [2256940], [-1450162], [-856386], [-347602], [-2218605], [-2943384], [-2329997], [1692464], [1500748], [-3485220], [-3605979], [4743803], [5265393], [1370150], [-6164292], [2453585], [-7667709], [-5002846], [-1863626], [-2607474], [-4780065], [-7967572], [1776648], [998548], [5084781], [-3719358], [9120346], [7837737], [96103], [2375769], [5914842], [1460994], [2906908], [5280923], [-13199900], [-13991976], [5126892], [-8291022], [-6213716], [11481797], [-641856], [-2805723], [-7744149], [2888678], [-12209471], [15166658], [15392658], [14084338], [-15617837], [4041570], [17103475], [8835456], [9361254], [366111], [20516360], [7481888], [12145905], [11523228], [17118484], [9727575], [-673813], [-2777190], [-11638544], [-13201315], [-3254765], [7615956], [-655199], [18511064], [-18529134], [-14841442], [3930417], [-11782409], [-5409525], [-7122639], [30304486], [28218069], [26453416], [-4444806], [-2803864], [-25980354], [11839190], [-2992830], [-28098044], [-11583252], [41253758], [-13254096], [31920832], [-17430264], [31506586], [49121424], [45123829], [-36819588], [17190371], [-8103516], [-18333708], [6030348], [30922846], [2479236], [-2097582], [44549097], [19510360], [-20067817], [1905293], [34679106], [37773528], [-55864198], [-54387945], [27926906], [5515882], [29805252], [15546343], [20500917], [-50512580], [-61843036], [61354552], [-22526928], [7787186], [6720918], [-31825224], [-32995434], [67293320], [25631995], [-54992431], [55117620], [-64810414], [-4662090], [-64779383], [-72979956], [-30029628], [-50538939], [37490375], [-65772040], [-28939857], [-56610249], [40163166], [51466102], [17610362], [20607638], [-19464354], [353271], [1576894], [59040672], [94018230], [87533092], [25379984], [63679410], [81925336], [110034783], [-31098906], [108258416], [62364994], [73742160], [-87257622], [111780726], [-102125854], [-59045786], [-20960955], [9761398], [-42234513], [124799294], [6367659], [24274539], [114847303], [72850788], [-125013304], [82973554], [100263808], [-82234191], [88551751], [-73103409], [-39734116], [121324776], [151909281], [-32442702], [-55472520], [23874928], [41060779], [42048230], [41006877], [144625806], [-109529552], [76474278], [-8752739], [96147078], [-153453754], [-141227742], [9978444], [131214656], [-39713874], [-75293697], [-135448162], [-141526772], [-178301295], [112973933], [-54250778], [146380038], [-104711164], [53782157], [7541130], [-23882606], [46221], [153323898], [34602868], [-46531554], [139613876], [106316512], [61302059], [-90611276], [123870110], [-156166541], [-192562620], [116534930], [-127744303], [-169694970], [268931727], [18668185], [14535552], [172252334], [233661895], [-47847213], [98623778], [-79815834], [-196087076], [124935180], [-146381115], [-125169243], [-158961612], [-116898216], [-79883842], [-170309148], [-123949346], [-99995967], [-65239044], [-197242157], [4534847], [59765502], [-166145225], [-238726944], [1286497], [-42700906], [14546958], [343454960], [265022328], [-40376200], [-41394816], [-232466193], [-81376098], [104215210], [-7416378], [85292408], [-293223186], [-327636837], [26804663], [-61087995], [-131662694], [-340451164], [-124117806], [46152400], [-215847810], [-132302788], [-328909943], [310705708], [-249040812], [26150808], [99494102], [353444520], [387107626], [-417973791], [307044628], [366785739], [222464033], [-337080366], [-211167910], [221065171], [168958058], [-234566304], [-258208554], [-164342345], [-275790846], [255391596], [192779822], [372116584], [288494826], [-13384917], [125349904], [-28628332], [255126069], [-292232669], [-178472587], [352029558], [-57113550], [-365288610], [437181822], [-124889466], [87980732], [-120444720], [-198077268], [265762167], [100588564], [17940614], [195973659], [-324444014], [186505901], [-230808921], [-156654380], [119390784], [-91650273], [314657674], [179727122], [-181490640], [21072231], [-286027435], [404889078], [130666409], [101369550], [-518071194], [-85638908], [132542358], [-236109284], [187603047], [-313808045], [-336145663], [259354084], [163472493], [-136615735], [-162453201], [161527605], [463665892], [-283138005], [171293072], [395131264], [-280059948], [198161707], [-258361038], [-173748448], [-51332820], [393150802], [687619035], [-452305188], [450882694], [-195128902], [-628862865], [-284606852], [186316500], [-99523429], [-509495130], [369173118], [-576404612], [157525730], [706575288], [452393547], [-792076412], [338954802], [-762589113], [289130193], [-282743818], [717816318], [-394202172], [-282377239], [-75156285], [324682848], [-695942958], [-720319628], [-652187604]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_560_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_560_6_a_f();".
// 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_560_6_a_f(:prec:=1)
    chi := MakeCharacter_560_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_560_6_a_f();".
// 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_560_6_a_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_560_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<3,R![-11, 1]>],Snew);
    return Vf;
end function;