
// Make newform 6025.2.a.c in Magma, downloaded from the LMFDB on 23 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_6025_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_6025_2_a_c();".
// 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_6025_2_a_c();".
// 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;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    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_6025_a();"
function MakeCharacter_6025_a()
    N := 6025;
    order := 1;
    char_gens := [2652, 2176];
    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_6025_a_Hecke(Kf)
    return MakeCharacter_6025_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 := 2;
    raw_aps := [[1, -2], [1, 1], [0, 0], [0, -2], [-1, 1], [1, -3], [-2, 5], [-6, -1], [-2, 4], [-4, 5], [0, -4], [-2, 4], [3, 1], [4, 4], [-4, -1], [-8, 4], [4, -6], [11, -3], [4, -5], [2, -9], [-6, -1], [10, -10], [4, 5], [-10, 8], [6, -2], [0, 10], [-6, -6], [7, -9], [8, -8], [18, -2], [-2, 0], [-14, 11], [-15, -3], [-11, -1], [-4, -12], [-2, -12], [-14, 13], [-4, -4], [-2, 6], [-9, -1], [-4, 0], [-1, -3], [-10, 10], [18, -4], [10, 0], [-11, 7], [8, -18], [-8, -11], [6, -18], [1, -5], [-6, 8], [8, -4], [1, 0], [-28, 2], [22, -2], [-16, 0], [10, -14], [16, 2], [0, -8], [-25, 5], [0, -2], [-14, 1], [-14, 18], [2, -9], [-8, -2], [11, 3], [-12, 14], [-10, 6], [-20, 13], [12, 1], [-1, 15], [-26, -2], [12, -14], [-14, 5], [7, 17], [18, -4], [4, -18], [-26, 4], [0, 17], [4, 12], [9, -29], [-26, 4], [-17, 21], [22, -6], [-19, -5], [14, 0], [0, -18], [24, -6], [16, -4], [28, -10], [-9, 3], [-6, 4], [31, -13], [-12, 28], [28, 4], [2, -10], [23, 9], [-6, 14], [-23, 17], [12, 17], [-26, 18], [24, -16], [5, 21], [-3, 31], [42, -3], [13, -23], [30, -16], [6, 16], [-2, 7], [-21, 13], [12, -20], [-10, -15], [-20, -4], [-38, 17], [-14, -7], [-8, 1], [-16, -16], [30, 6], [-46, 5], [-12, -18], [24, 6], [-26, -10], [3, -21], [-8, -4], [-10, -6], [-24, -6], [-4, -24], [-50, -2], [20, -21], [-8, -6], [6, -10], [5, 9], [27, 1], [-26, 7], [-26, 16], [-4, 24], [0, 18], [27, -1], [2, -15], [-12, 8], [-3, -17], [-7, -1], [4, -12], [14, -16], [-12, 27], [-6, 4], [33, -23], [36, 10], [26, 1], [10, -6], [-14, 2], [20, -5], [-11, -3], [23, 15], [-34, -2], [4, -26], [-18, 28], [2, -18], [-20, 0], [32, -14], [4, 10], [-19, 21], [8, 8], [-48, -8], [30, -16], [0, 18], [-28, 20], [29, -11], [10, -12], [0, -8], [-26, 53], [2, 12], [6, -12], [5, 5], [-44, 14], [20, -32], [-18, -6], [-33, 17], [-46, 10], [2, 4], [4, -20], [-15, 23], [-3, -7], [-28, 22], [-16, 42], [36, -35], [26, -7], [16, -7], [-10, -28], [-16, 32], [-46, 21], [34, 0], [23, -55], [-1, 25], [-4, 3], [26, -8], [40, -21], [-50, 18], [4, 16], [44, 0], [-8, 41], [2, 13], [28, -34], [-30, 0], [50, -6], [20, -28], [2, 17], [-36, 30], [-36, 10], [-3, -5], [-29, 59], [60, -5], [35, -21], [-24, -24], [24, -4], [-12, 29], [-1, 35], [22, -30], [5, 29], [33, -23], [58, -16], [20, -46], [30, -20], [-10, -10], [-26, 38], [-40, -8], [41, 5], [-17, 13], [9, -23], [-50, 18], [-22, 11], [32, 16], [0, -26], [36, -8], [26, -60], [-3, -7], [-16, -2], [20, -38], [20, -12], [7, 5], [-5, 27], [-34, -3], [36, -25], [-18, 26], [10, -18], [14, -16], [-31, 41], [-34, 38], [36, 12], [-36, -12], [-2, -30], [-20, 6], [33, -39], [-12, 10], [-70, 4], [-40, 8], [-18, 22], [0, 21], [-48, -2], [-56, 22], [-35, -7], [-20, 37], [8, -9], [-32, 32], [-42, -6], [14, 14], [-38, -12], [-6, 0], [7, -1], [21, -63], [40, -9], [-44, 17], [58, -23], [48, -2], [48, 0], [-23, -7], [63, -25], [16, -36], [18, -22], [10, 3], [56, -36], [-2, 6], [-16, 7], [42, -44], [-16, 49], [-26, 37], [2, 4], [10, -24], [2, 46], [52, 16], [25, -65], [-12, 26], [12, 46], [-36, 24], [12, -12], [6, 18], [-23, 67], [-6, -6], [-80, 12], [64, -20], [-50, -15], [-34, 37], [34, 21], [36, 17], [-22, 20], [27, -1], [-44, -16], [0, -2], [10, 13], [24, 24], [21, 17], [51, -11], [-32, -6], [-24, 60], [12, -37], [30, -52], [-34, 35], [26, 16], [42, -21], [-8, -11], [-69, -3], [-52, 10], [18, -6], [20, -54], [-38, 4], [36, 3], [32, 28], [60, 18], [68, -10], [10, -8], [-48, -10], [-1, 31], [-40, -28], [-20, -24], [16, 26], [-52, 39], [17, -29], [63, -13], [-6, -52], [-32, 9], [-21, -41], [2, -30], [14, 10], [-30, 7], [28, -6], [-87, 15], [-34, -20], [0, 30], [64, 2], [-10, 14], [-41, 61], [-6, 55], [-9, -11], [-16, 47], [8, 24], [42, -31], [-23, 27], [-40, 54], [25, -51], [-84, 10], [8, 2], [16, -62], [76, 12], [76, -30], [-56, -8], [-26, 40], [36, 2], [-50, 40], [-34, 52], [-46, 48], [21, -9], [39, -9], [-60, 30], [-30, 14], [-38, 72], [26, -10], [72, -24], [14, -50], [-42, 28], [38, -27], [52, 25], [74, 8], [32, -40], [-42, 42], [-62, 38], [0, -1], [20, -8], [46, -60], [80, -15], [31, 7], [14, -54], [38, -25], [-18, 16], [8, 28], [-22, -26], [41, 13], [-86, 15], [22, 10], [-2, 42], [-20, 51], [8, -1], [1, 33], [-43, -19], [38, 35], [26, 10], [9, 47], [-74, 45], [-4, 13], [-6, 54], [51, -63], [-38, -26], [2, -17], [48, -48], [14, 18], [50, 4], [24, -16], [-43, -25], [-39, 81], [-14, 42], [-20, 14], [-16, 12], [-2, -16], [4, -8], [2, 18], [-30, -14], [10, 13], [66, -44], [26, -40], [-46, 78], [30, -46]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_6025_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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