
// Make newform 225.6.a.q in Magma, downloaded from the LMFDB on 01 May 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_225_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_225_6_a_q();".
// 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_225_6_a_q();".
// 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 := [-1, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0], [-5, 10]];
    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_225_a();"
function MakeCharacter_225_a()
    N := 225;
    order := 1;
    char_gens := [101, 127];
    v := [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_225_a_Hecke(Kf)
    return MakeCharacter_225_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, -1], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, -58], [2164, 0], [0, 124], [0, 0], [-8152, 0], [0, 0], [0, 0], [0, 0], [0, -1084], [0, 3658], [0, 0], [34802, 0], [0, 0], [0, 0], [0, 0], [-70064, 0], [0, 6472], [0, 0], [0, 0], [0, 0], [0, 0], [0, 18488], [125986, 0], [0, 21178], [0, 0], [0, 0], [0, 2690], [342964, 0], [0, 0], [558248, 0], [0, 0], [0, 0], [0, 63236], [0, 65710], [0, 0], [879098, 0], [0, 0], [0, 0], [0, -69898], [141136, 0], [-283948, 0], [0, 0], [0, 5048], [1425814, 0], [0, 122110], [0, 0], [571202, 0], [0, 0], [0, -87766], [0, -197636], [0, 0], [904352, 0], [0, 0], [0, 0], [0, 0], [0, -128954], [0, 0], [0, 0], [0, 0], [0, -80110], [3781652, 0], [0, 0], [0, 62864], [-2443886, 0], [0, -409514], [0, 0], [0, 0], [0, 0], [2752564, 0], [0, -469316], [0, 0], [0, 0], [0, 0], [2315014, 0], [0, 0], [-2594602, 0], [0, 0], [0, 0], [7475536, 0], [0, 599752], [0, 0], [0, 0], [0, 0], [0, 0], [0, -831856], [0, 0], [0, 0], [0, 0], [-7162364, 0], [0, 940180], [0, 0], [0, 0], [0, 0], [2905202, 0], [0, 0], [0, 817490], [0, 1215856], [0, 0], [-183148, 0], [0, 0], [0, -1417672], [0, 679738], [0, 0], [-17027002, 0], [0, 0], [0, 0], [0, 1294238], [14432836, 0], [-6122848, 0], [0, 0], [0, 0], [0, 1507820], [0, -383438], [0, 0], [-18023302, 0], [0, 0], [0, 182714], [0, 1281136], [-18548452, 0], [0, 0], [-14922986, 0], [0, 0], [0, 0], [0, 0], [10686964, 0], [0, -2679020], [20670248, 0], [0, 0], [0, 0], [-32280914, 0], [0, 1164298], [0, 0], [0, -2689522], [0, 0], [18953948, 0], [0, 0], [0, 0], [0, -751216], [-648686, 0], [0, 0], [0, 0], [0, -3189394], [38615236, 0], [0, -3624620], [0, 0], [0, 0], [0, 0], [0, 2868356], [0, 0], [0, 0], [19746664, 0], [0, 0], [0, 0], [0, 0], [0, -4913992], [0, -729326], [0, 0], [0, 0], [0, -1870138], [0, -5213852], [28321952, 0], [0, 0], [-57960014, 0], [0, 3157126], [0, 0], [22625102, 0], [0, 0], [0, 0], [57350464, 0], [0, 0], [71494748, 0], [0, 0], [0, 0], [-51462914, 0], [0, 0], [0, 0], [0, 0], [0, 7049090], [0, -4518596], [0, 0], [0, 0], [0, 0], [-78368186, 0], [0, 0], [0, 0], [0, 8007112], [79156148, 0], [0, 0], [0, 3476624], [0, 6435682], [-67882498, 0], [0, 0], [0, -6727126], [0, 6304228], [0, 0], [57495848, 0], [0, 0], [65182114, 0], [0, 0], [0, 10416926], [105721936, 0], [0, 10240288], [0, 0], [-9053452, 0], [0, 0], [0, 0], [0, 0], [0, -8297248], [0, 0], [48363398, 0], [0, 0], [0, 0], [0, 1306220], [0, 5857522], [137814902, 0], [-133651136, 0], [0, 0], [0, 0], [0, 864992], [-79236314, 0], [0, -13134446], [0, 0], [0, 0], [0, 0], [0, 0], [142094236, 0], [138760352, 0], [0, 0], [0, 0], [0, -15248548], [-8765714, 0], [0, -9560426], [0, 0], [0, 0], [0, -7531232], [-156096652, 0], [0, 0], [-147243614, 0], [0, -3983066], [0, 0], [0, 0], [0, 0], [17241436, 0], [0, 2797780], [0, 0], [0, 0], [0, 9820676], [83134486, 0], [0, -14697566], [0, 0], [-207892102, 0], [0, 0], [0, -3413974], [0, 0], [0, 0], [0, -18127432], [-227332586, 0], [0, 0], [0, -19723606], [-76330364, 0], [0, 0], [0, 0], [0, 0], [0, 5937418], [-150483202, 0], [0, 0], [0, 0], [-241708736, 0], [0, 0], [0, 0], [0, 22822112], [237949714, 0], [159982502, 0], [0, 0], [0, 9546580], [129447848, 0], [0, -21155428], [226682198, 0], [0, 0], [0, 0], [0, 0], [0, -21904534], [245017936, 0], [0, 0], [0, 0], [0, 24373904], [0, 10388782], [0, 0], [0, 0], [0, 0], [-304376248, 0], [0, 30117766], [0, 0], [0, 0], [0, 0], [0, 176738], [85669864, 0], [0, -31520360], [-362659948, 0], [0, 0], [0, 27709160], [165362686, 0], [0, 0], [0, 0], [0, 21215908], [0, 0], [0, 0], [0, 0], [0, -19631380], [62848714, 0], [0, 0], [0, 0], [0, 0], [0, 0], [382828652, 0], [0, 0], [0, 0], [0, 0], [0, -36089090], [46612802, 0], [-442862564, 0], [0, 0], [0, 18782276], [0, 41211094], [393078398, 0], [0, 27409058], [-256761536, 0], [0, 4518040], [157502252, 0], [0, -35474632], [335794414, 0], [0, 43834966], [-456038902, 0], [0, 0], [0, 0], [0, 5272046], [0, 0], [247172552, 0], [0, -21302798], [0, 0], [38147702, 0], [0, 0], [0, 0], [0, -11016778], [-362299852, 0], [0, 0], [0, 0], [0, 0], [439270714, 0], [0, -42762578], [0, 0], [0, 0], [0, -49187494], [0, 50897836], [0, 0], [0, 0], [0, -45818476], [0, 0], [0, 0], [0, 0], [0, 49470290], [0, 0], [595107398, 0], [0, 0], [128118964, 0], [0, -25058756], [0, 0], [253806248, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, -38106398], [0, 0], [0, 61449974], [-613953764, 0], [0, 2385196], [684673352, 0], [0, 0], [0, 0], [0, -52919380], [560346286, 0], [0, -52789094], [0, 0], [0, 0], [0, 0], [0, 0], [-718342664, 0], [0, 0], [-761626348, 0], [0, 0], [-525546386, 0], [0, -38619254], [0, 0], [0, 72676178], [0, 0], [822625952, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, 19337894], [0, -76340624], [-770409748, 0], [0, 0], [0, 0], [0, 0], [0, 0], [0, -56792614], [0, -32785796], [0, 0], [0, 0], [0, 45124244], [0, 0], [0, 0], [0, 60702158], [0, 62813512], [0, 0], [-215827852, 0], [0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_225_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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