
// Make newform 6025.2.a.d in Magma, downloaded from the LMFDB on 24 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_d();".
// 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_d();".
// 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, 0], [-1, 1], [0, 0], [0, 2], [3, -1], [-1, -1], [-2, 3], [0, -1], [6, -4], [-4, 5], [-4, -4], [2, -4], [-1, 5], [4, -4], [6, -3], [-4, 0], [-4, -2], [3, -3], [6, -11], [-8, 11], [2, 5], [6, -14], [-14, -1], [14, -4], [-14, -2], [4, 2], [10, -14], [5, -5], [-12, 4], [-10, 18], [-10, 0], [-16, -1], [-5, -5], [5, 5], [0, 8], [-6, 8], [-6, 7], [-12, 16], [14, -6], [5, -7], [-8, 8], [-5, 1], [2, -14], [6, -4], [-2, -8], [-19, -3], [-12, -2], [6, -1], [-14, 22], [17, -13], [10, -8], [-8, 4], [1, 0], [4, -6], [-2, -18], [-12, 4], [-2, -6], [-12, -10], [-8, 0], [-1, 13], [8, 2], [10, 7], [26, -6], [-16, 23], [16, 6], [-7, 13], [-8, 10], [-18, 14], [-6, 11], [-4, 17], [-19, -7], [14, -6], [0, -10], [10, 3], [-25, 19], [-18, -4], [-20, 6], [-14, 28], [0, -11], [20, 8], [21, -11], [22, -20], [7, -25], [-10, 14], [9, -3], [-10, 8], [-12, 2], [-16, 14], [-36, 0], [8, 6], [13, 7], [-34, 8], [-3, 7], [4, 12], [24, -28], [18, -14], [11, 13], [2, -2], [-1, 9], [28, -11], [-6, 6], [36, -16], [-17, -15], [13, -17], [-4, -7], [-21, 3], [18, -4], [26, -24], [4, -25], [27, -19], [-32, 20], [-10, 27], [24, 8], [20, 13], [20, 5], [-16, -3], [-12, 0], [10, 10], [-14, 7], [-16, -2], [-24, 26], [14, 14], [13, 1], [-4, 20], [-22, 10], [-28, 10], [-16, 4], [2, -22], [38, -11], [12, -10], [-6, 2], [-1, 29], [11, 3], [6, -3], [-10, 24], [4, 12], [-16, 34], [-15, -13], [26, -13], [-24, 16], [-15, 17], [-7, -25], [-32, 12], [-6, 8], [-4, 11], [-14, 16], [7, -21], [-24, -6], [36, -19], [-22, 2], [-14, 30], [12, 11], [23, 9], [29, -21], [22, -10], [24, -14], [-10, 8], [10, -2], [12, -20], [-16, 14], [8, 18], [27, -1], [-20, 8], [-12, 40], [18, -8], [36, -22], [32, 12], [23, 3], [-22, 44], [28, -44], [-16, 29], [-10, -32], [-26, 24], [-9, -29], [-28, 34], [20, 24], [22, -50], [27, 21], [34, 10], [-10, 36], [-8, -12], [-39, -3], [-1, -1], [-8, -2], [16, -30], [-36, -15], [2, -21], [-42, -5], [-2, -16], [28, -24], [-14, 15], [-42, 32], [19, 23], [43, -3], [30, 5], [14, 20], [-16, -13], [-46, 2], [-24, 32], [16, 24], [-24, -11], [-12, 1], [-16, -22], [42, -44], [-58, 2], [-40, 40], [44, -3], [48, -14], [16, -34], [-19, -7], [-27, 9], [-36, 15], [-23, -1], [-4, 8], [-52, 12], [-4, 29], [41, 11], [30, 18], [-21, 21], [-29, 23], [30, 0], [4, -22], [22, 8], [-6, -10], [22, -30], [-16, 28], [3, 19], [-13, 43], [-45, -11], [30, -10], [2, -27], [4, -8], [44, -22], [-4, 36], [-34, -12], [-21, 33], [-24, -18], [-12, 6], [4, -32], [47, -41], [-7, 15], [0, -35], [6, -43], [-50, 14], [-30, -18], [-46, -16], [-25, 25], [-2, -34], [48, -48], [-28, 8], [-50, 10], [-12, -6], [39, -23], [-32, -6], [6, 4], [-12, -16], [54, 6], [30, 11], [20, 6], [4, 26], [3, -15], [-38, -17], [16, 3], [28, -36], [30, -26], [-22, 10], [-46, 44], [26, -16], [49, -33], [27, 3], [64, -5], [-14, 47], [-54, -9], [8, 38], [-28, -4], [-25, 49], [-19, 27], [-4, 20], [14, 14], [-48, -21], [-56, 4], [18, -14], [10, -23], [-22, -20], [38, -53], [-48, 29], [-34, 20], [-18, 40], [-6, 30], [44, 0], [-67, 19], [12, 2], [20, -22], [32, 8], [12, 36], [6, -10], [-59, -3], [6, -30], [12, 4], [-60, -4], [14, 15], [14, 23], [-20, -31], [-38, 23], [-2, -16], [-31, 33], [-12, 28], [-8, 38], [-20, 49], [12, -52], [19, -7], [3, -3], [-4, -34], [32, -40], [-66, 37], [-18, 20], [-36, -5], [-30, -24], [-22, 29], [-56, 45], [11, 39], [-36, 6], [10, -10], [-12, 6], [-10, -28], [12, -33], [72, -4], [4, 42], [8, 26], [-26, 24], [40, -10], [-39, -3], [28, -60], [56, -28], [0, -26], [6, 29], [53, -49], [-67, 45], [-14, -24], [-18, -5], [33, 1], [6, -6], [6, 2], [-48, -1], [-48, 30], [41, -27], [-18, 64], [16, -2], [-72, 18], [-6, -42], [-29, -21], [42, -3], [-33, 13], [-14, 25], [-4, -48], [50, -45], [-23, 33], [24, -42], [-53, -5], [16, -18], [56, 18], [80, -10], [32, 16], [-32, 42], [-24, -8], [-62, 8], [-4, -18], [-30, 8], [-14, -4], [-58, 52], [25, -47], [65, -17], [-8, -46], [-6, 6], [-10, -24], [10, -34], [-52, 28], [-70, 10], [-58, 16], [-10, 39], [-20, -35], [18, -56], [-44, 24], [54, -70], [-2, 2], [-38, 41], [-40, -12], [2, 12], [62, -57], [-23, 15], [38, 14], [38, -7], [-30, 36], [-4, -28], [42, -2], [-25, 23], [0, -57], [-10, -10], [42, -22], [-52, 15], [16, 39], [27, -17], [-37, -19], [-50, 49], [46, -62], [17, -35], [22, -33], [-52, 25], [38, 10], [-13, 51], [6, -62], [-14, -23], [84, 0], [-74, 6], [-34, 76], [20, -48], [-47, -31], [23, 25], [-58, 14], [-12, 26], [8, -44], [-62, 36], [56, -8], [-62, 10], [34, 30], [-22, 43], [78, -16], [-38, 48], [14, 2], [14, -2]];
    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_d();".
// 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_d(: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_d();".
// 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_d( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_6025_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-1, 1]>,<3,R![-1, 1, 1]>],Snew);
    return Vf;
end function;