
// Make newform 900.6.a.o in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_900_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_900_6_a_o();".
// 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_900_6_a_o();".
// 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
        poly := [-15, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-2, 4]];
    Rf_basisdens := [1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_900_a();"
function MakeCharacter_900_a()
    N := 900;
    order := 1;
    char_gens := [451, 101, 577];
    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_900_a_Hecke(Kf)
    return MakeCharacter_900_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+1)]];
    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, 0], [0, 0], [0, 0], [0, -8], [-80, 0], [0, 24], [0, 35], [-12, 0], [0, -130], [4560, 0], [-344, 0], [0, 280], [-14240, 0], [0, 1216], [0, 1570], [0, -1755], [38000, 0], [-8206, 0], [0, 848], [-48480, 0], [0, -2720], [-9264, 0], [0, -2140], [-24320, 0], [0, -8752], [105200, 0], [0, -4360], [0, -1380], [-41438, 0], [0, 13725], [0, 15640], [124560, 0], [0, -23295], [-89036, 0], [-438640, 0], [-351704, 0], [0, -5272], [0, 33296], [0, 8130], [0, 20695], [495920, 0], [-683014, 0], [-625440, 0], [0, -4496], [0, 11515], [-295728, 0], [-1048236, 0], [0, -51176], [0, 64220], [-593002, 0], [0, -40385], [1002400, 0], [-1586366, 0], [-1625520, 0], [0, -42795], [0, -70210], [562800, 0], [-1876448, 0], [0, -49208], [687360, 0], [0, -38896], [0, 119715], [0, 55968], [1020960, 0], [0, -34064], [0, -112375], [-2243948, 0], [0, 59392], [0, -264120], [-1637486, 0], [0, 126955], [1147200, 0], [0, -262088], [0, 191496], [98228, 0], [0, 173470], [-1030640, 0], [0, 390712], [2421920, 0], [-1328122, 0], [-4659440, 0], [-1391402, 0], [-4760960, 0], [0, -329456], [1301712, 0], [0, 193380], [8075040, 0], [0, -306320], [-5021040, 0], [0, -157560], [0, 152520], [2795680, 0], [0, -255672], [5045520, 0], [4800132, 0], [0, -591990], [1718160, 0], [-12078880, 0], [0, -332464], [4687474, 0], [0, 401920], [0, 569385], [0, 756280], [2897440, 0], [10183444, 0], [0, 115168], [0, -826980], [0, -328995], [-5622720, 0], [7488326, 0], [0, 450440], [0, 989080], [0, -503665], [8698052, 0], [15025184, 0], [6880480, 0], [0, 761520], [0, 322230], [0, 720665], [-18498160, 0], [11314298, 0], [0, -1311600], [0, -404515], [0, 902840], [14977948, 0], [-1931120, 0], [-7554282, 0], [9206080, 0], [0, 1299048], [0, -1238200], [14594164, 0], [0, -1170870], [19854248, 0], [0, -837848], [5173920, 0], [-3024978, 0], [0, -202875], [0, -1098128], [0, 281735], [1613280, 0], [11850076, 0], [-5222320, 0], [0, -766584], [0, 149960], [-16264686, 0], [37268480, 0], [0, 2405144], [0, 862455], [27591236, 0], [0, -1864470], [0, 1661672], [4367040, 0], [0, -1308624], [0, 2808450], [0, -62880], [-31484160, 0], [18442728, 0], [-12032160, 0], [0, -1489888], [4159120, 0], [0, -996900], [0, 1266505], [0, -2459560], [33718800, 0], [0, -2126685], [0, -1097870], [-9280736, 0], [0, 2375880], [-38080078, 0], [0, 1981635], [-48176400, 0], [-34447026, 0], [-32256320, 0], [0, -1485376], [36054208, 0], [-11484480, 0], [-35734564, 0], [71258640, 0], [0, -2558936], [-59830018, 0], [0, -1949048], [33481040, 0], [0, -1577944], [0, -2968575], [0, -1206050], [7467120, 0], [0, -950312], [0, -3606256], [-25114042, 0], [10641440, 0], [0, 4202784], [0, 782180], [-45950924, 0], [-28211280, 0], [0, -4388280], [0, -3306255], [-47274498, 0], [0, -2061000], [0, 4620885], [0, 1712050], [33188400, 0], [-25950552, 0], [0, -4563240], [-84040286, 0], [-29421200, 0], [0, 3678735], [18643152, 0], [0, -3316720], [97591040, 0], [-17313164, 0], [0, 2247728], [-68991120, 0], [0, 4501976], [0, -2708880], [74483360, 0], [-61563002, 0], [0, 6077432], [-77195680, 0], [0, -4136330], [0, -3115015], [5847414, 0], [102155968, 0], [-16405920, 0], [0, -3139960], [0, 2576880], [-90357978, 0], [0, -3641335], [-135603520, 0], [0, -6171832], [104317360, 0], [0, -7507336], [31799836, 0], [81073184, 0], [84178560, 0], [0, -2894480], [0, -3807250], [45794286, 0], [0, 3481675], [28231920, 0], [52843680, 0], [0, 11308560], [41297396, 0], [0, -5737304], [-17964638, 0], [0, 3386195], [-139167840, 0], [0, 795768], [-46208400, 0], [118600412, 0], [0, 4769450], [0, -6883800], [63872320, 0], [0, -6060350], [-57841898, 0], [0, -5941295], [-8565360, 0], [47270266, 0], [0, -6606640], [0, 458005], [0, 7723760], [0, -2397384], [0, 1851740], [142382614, 0], [0, 6842936], [0, -5216235], [-62413564, 0], [128945520, 0], [-121771520, 0], [0, 631120], [0, 13636485], [154363646, 0], [0, 1873760], [0, 3735680], [224874688, 0], [0, -2237312], [0, 85784], [0, 8508400], [-87581422, 0], [86641574, 0], [-87730800, 0], [0, -11685270], [242526248, 0], [0, 2523790], [94450006, 0], [0, -12818368], [-56768480, 0], [0, 11135856], [0, -6126155], [-121647664, 0], [161860480, 0], [78298480, 0], [0, 17111880], [0, 11547735], [-300619920, 0], [0, -10357736], [-85728240, 0], [46868424, 0], [0, -2941245], [164222320, 0], [0, 13031520], [0, -17478640], [0, 7033905], [-41907352, 0], [0, -12353460], [36095252, 0], [0, 2864752], [0, -6470540], [223273982, 0], [-169446880, 0], [0, -16116120], [0, 18970770], [-318985200, 0], [179297760, 0], [0, 7772064], [0, 2735030], [-38280502, 0], [1109360, 0], [337076960, 0], [0, 6058816], [-347700480, 0], [-251760148, 0], [0, -3580912], [-231096240, 0], [0, 6490984], [0, 11809215], [-10833598, 0], [-255051108, 0], [0, -19923744], [0, -16829470], [0, -4263445], [-200468354, 0], [0, -26740015], [-430545472, 0], [0, -12909620], [-383423316, 0], [0, 27688860], [78697198, 0], [0, 21620715], [18644746, 0], [0, 28318840], [0, 21642984], [0, 27667255], [6202480, 0], [-120544696, 0], [0, -12450055], [284288880, 0], [-211853706, 0], [0, -7666048], [-179606560, 0], [0, -816165], [-432765004, 0], [0, -32177520], [-240298800, 0], [0, 29410584], [274397498, 0], [0, -33152745], [-179573760, 0], [-324042960, 0], [0, 3575405], [0, -1139050], [0, 16721032], [-272501760, 0], [0, -34426230], [144243760, 0], [0, 2034960], [0, -5757824], [0, 30872745], [0, -29219400], [-345320634, 0], [399192560, 0], [-512029132, 0], [0, 14096990], [238021680, 0], [-7931352, 0], [0, -1704792], [245450800, 0], [53476160, 0], [0, -36760704], [-501947040, 0], [0, -2949808], [-625279920, 0], [0, -27400655], [0, -17885800], [0, -31488965], [71527836, 0], [0, 25805910], [-295421496, 0], [0, -21954040], [0, 38112960], [0, 17797910], [-211151698, 0], [0, 24585165], [-552610320, 0], [0, 3870608], [649742720, 0], [0, 13923856], [-124400008, 0], [677939360, 0], [-157474156, 0], [683367600, 0], [588130414, 0], [0, 10262405], [0, 9024728], [0, -29740695], [-152863440, 0], [173944352, 0], [0, -720408], [88223520, 0], [0, 3731984], [-624287280, 0], [0, -19322944], [0, -1472685], [0, 24621240], [-625013396, 0], [0, 24273088], [-8922320, 0], [-612397760, 0], [0, 9935352], [0, -23159635], [0, -4655490], [-273761520, 0], [0, 20914568], [0, 13012490], [57832080, 0], [0, 16493360], [0, 44863335], [0, 30630820], [320611520, 0], [-446625804, 0], [939076480, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_900_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_900_6_a_o();".
// 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_900_6_a_o(:prec:=2)
    chi := MakeCharacter_900_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_900_6_a_o();".
// 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_900_6_a_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_900_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<7,R![-15616, 0, 1]>,<11,R![80, 1]>],Snew);
    return Vf;
end function;