
// Make newform 560.6.a.i in Magma, downloaded from the LMFDB on 22 December 2024.
// 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_i();".
// 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_i();".
// 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)
    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], [23], [25], [-49], [-555], [-241], [-1491], [2038], [1230], [-5001], [-5696], [-5602], [-2424], [-602], [23163], [-25296], [-5724], [-36112], [-66104], [-16080], [-80482], [64147], [106284], [-71676], [151025], [-57150], [-115889], [137862], [88397], [205554], [-250916], [52122], [-135468], [349486], [176082], [-383333], [345914], [-91586], [-38097], [-541443], [-166188], [-197320], [337221], [260516], [-409212], [-300980], [1226179], [-621257], [-1297677], [-124264], [1087416], [545631], [811310], [897738], [-594678], [-1028370], [-1243902], [-737624], [-2200630], [173979], [551053], [-1675119], [-2330603], [-706266], [-183565], [2706654], [2143372], [655346], [4222746], [3017102], [2252577], [1839504], [1688323], [1812116], [4767076], [69996], [3988953], [-3059035], [4307937], [-239206], [-4634616], [-2101075], [-1654839], [-1840306], [-5836838], [-1197042], [-3425697], [5297420], [8877312], [2174752], [378969], [-1884894], [-3676886], [-9540153], [-4782431], [10839465], [-7641774], [6440106], [4779292], [-2056777], [12018928], [8699424], [7359420], [-7500294], [2228788], [-5109457], [-11064552], [9100431], [12861489], [1581626], [688297], [-6021502], [3361374], [-13176926], [-1262639], [-15885918], [-1808801], [-95712], [3067362], [1329609], [-7371880], [8484764], [-4358913], [15873168], [554956], [-7747197], [-18905521], [18392778], [13425904], [10847315], [-26432339], [-20312016], [3953875], [-26216512], [11432862], [23707634], [-12417969], [-30655277], [-15186963], [539721], [-13977182], [-17813679], [-19100960], [-3192246], [8568416], [-35675082], [30635546], [-4461882], [-26397404], [21753036], [-15838318], [19742736], [17289940], [44469264], [-2568866], [-11269248], [-31837841], [18855816], [11294633], [-29194104], [-10589196], [-39031716], [34339522], [18146436], [-10522314], [7913529], [-40155584], [-49347823], [17772701], [-22147434], [-2285016], [45943406], [4642125], [8485214], [-40077866], [-25447620], [42574081], [-48071895], [-11174276], [-5554072], [47535868], [-11901300], [-17451058], [-14504694], [-36638772], [-55179774], [2123444], [1617319], [-31836415], [76858272], [29282558], [-8529090], [-53625665], [32317500], [29584428], [-32952201], [-58606561], [-31585576], [2728701], [-25821609], [-17445930], [-6548522], [-14949010], [-12176914], [-7848678], [42064281], [52698130], [-43797540], [113762550], [43959808], [5609384], [88279602], [-89305592], [-38272413], [35856894], [-68673508], [102709342], [-71196528], [-20482494], [121754490], [-122460502], [-114409730], [-44782707], [-12531134], [3715995], [-30624394], [27523353], [108731601], [96743071], [-46566732], [-73116100], [-16909238], [20740408], [-69075351], [-6073901], [155207535], [-11833228], [61752840], [-109724433], [-83712270], [-41232672], [-117940592], [33755107], [-2601394], [-17914857], [82415802], [146027224], [-30693306], [185382235], [2172270], [-162449182], [-132747114], [84091248], [-148993024], [-45852318], [92422065], [44470814], [-106559540], [114416895], [165751679], [-799442], [106340598], [10034672], [-40286581], [-75550098], [-21637070], [-171702831], [-48517506], [-234838664], [-10994934], [-217526356], [190096], [106621361], [6692068], [-91650790], [5791579], [15718212], [140185490], [-137964319], [-61115082], [-220394889], [-119153765], [-75115248], [-24121642], [-248332085], [144352497], [4112438], [-246663798], [40291216], [78421008], [-85165863], [18361497], [137238276], [55679640], [-180668062], [163923444], [-152133086], [73253175], [-55068180], [217124023], [-60479299], [-310817862], [-215271659], [-204232488], [-342404345], [89417150], [357453318], [-292346248], [122408520], [213987332], [-133838736], [90920475], [93018222], [-313780418], [189670950], [7326500], [146508870], [-186354063], [-265996651], [-91819515], [-151781750], [-29238700], [321299778], [10700656], [-1804914], [-216488344], [-334882097], [374405644], [3552732], [430925664], [-111360370], [-63797352], [193071358], [255218469], [23918428], [-4057257], [-841003], [26691342], [59971898], [108369475], [98414822], [497283972], [95580498], [247198549], [-450411390], [-80027388], [126457790], [-259254140], [337292394], [-39567651], [87590476], [508549520], [429111729], [-139436933], [43882289], [-365248398], [-191563854], [-114830442], [482968122], [-385764882], [84215768], [477259020], [26988492], [163384065], [-66440468], [-511714390], [-139150779], [22775434], [446449493], [-462331191], [-441877376], [116307180], [-309985965], [584445250], [-46971838], [205094208], [-329997747], [-461882905], [-12266922], [-134095813], [117579186], [-409015206], [-93112544], [-168055878], [-120333644], [-158976321], [187342777], [-591464737], [-279429860], [-30624987], [-405705343], [160331313], [-468541005], [-111223820], [-260748639], [180161864], [-314128028], [641166468], [649190749], [-752747454], [-376205140], [-321282072], [-228078818], [211998393], [159120660], [-204563402], [501695078], [-374057625], [47118916], [-622178484], [270701969], [83411358], [-587346270], [175320796], [-307750078], [-536544168], [503184609], [555192244], [-262062354], [-543442185], [107070813], [282373754], [742626834], [-489294636], [540084107], [-98649459], [107734404], [231609906], [751534612], [11857344]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_560_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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