
// Make newform 6025.2.a.b in Magma, downloaded from the LMFDB on 25 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_b();".
// 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_b();".
// 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], [-2, 1], [0, 0], [2, -2], [0, -1], [2, -3], [-3, 5], [-7, 1], [-2, 4], [1, -5], [-4, 4], [-2, 4], [4, -1], [-8, 4], [5, -1], [4, 4], [-2, 6], [8, 3], [1, -5], [-7, 9], [7, -1], [0, 10], [-9, 5], [-2, -8], [-4, -2], [10, -10], [12, -6], [2, -9], [0, 8], [-16, -2], [2, 0], [-3, -11], [18, -3], [-12, 1], [-16, 12], [-14, 12], [1, 13], [8, -4], [-4, 6], [10, -1], [-4, 0], [-4, 3], [0, -10], [-14, -4], [-10, 0], [-4, -7], [-10, 18], [19, -11], [12, -18], [-4, 5], [-2, 8], [4, 4], [1, 0], [-26, -2], [-20, -2], [16, 0], [-4, 14], [18, -2], [8, -8], [-20, -5], [2, -2], [13, 1], [-4, 18], [-7, 9], [10, -2], [-14, 3], [2, -14], [4, 6], [7, 13], [13, -1], [-14, 15], [-28, 2], [2, -14], [9, 5], [24, -17], [-14, -4], [-14, 18], [22, 4], [17, -17], [16, -12], [-20, 29], [-22, -4], [4, -21], [-16, -6], [-24, 5], [-14, 0], [-18, 18], [-18, -6], [12, 4], [-18, -10], [6, 3], [-2, -4], [-18, -13], [16, -28], [32, -4], [8, -10], [32, -9], [8, -14], [6, 17], [29, -17], [8, 18], [-8, -16], [-26, 21], [28, -31], [39, 3], [10, -23], [-14, -16], [-22, 16], [5, -7], [-8, -13], [8, -20], [25, -15], [24, -4], [-21, -17], [-21, 7], [-7, -1], [32, -16], [-36, 6], [41, 5], [-30, 18], [30, -6], [36, -10], [18, -21], [12, -4], [-16, 6], [-30, 6], [-28, 24], [-52, 2], [1, -21], [14, -6], [-4, 10], [-14, 9], [28, -1], [19, 7], [-10, -16], [20, -24], [-18, 18], [-26, -1], [13, -15], [-4, -8], [-20, 17], [-8, 1], [8, -12], [2, -16], [15, -27], [-2, -4], [-10, -23], [-46, 10], [27, -1], [-4, -6], [12, 2], [15, 5], [14, -3], [-38, 15], [36, -2], [-22, 26], [10, -28], [-16, 18], [20, 0], [18, 14], [-14, 10], [-2, 21], [-16, 8], [-56, 8], [-14, -16], [-18, 18], [-8, -20], [-18, -11], [-2, 12], [8, -8], [27, -53], [14, -12], [-6, 12], [-10, 5], [-30, -14], [-12, 32], [-24, 6], [-16, -17], [36, 10], [6, -4], [16, -20], [8, -23], [10, -7], [6, 22], [-26, 42], [1, 35], [-19, -7], [-9, -7], [-38, 28], [16, -32], [25, 21], [-34, 0], [-32, 55], [24, -25], [1, 3], [-18, -8], [19, 21], [32, 18], [-20, 16], [-44, 0], [33, -41], [15, -13], [6, -34], [-30, 0], [44, 6], [8, -28], [19, -17], [6, 30], [-26, -10], [-8, 5], [-30, 59], [55, 5], [-14, -21], [48, -24], [20, 4], [17, -29], [-34, 35], [-8, 30], [-34, 29], [-10, -23], [42, 16], [-26, 46], [10, 20], [20, -10], [-12, 38], [-48, 8], [-46, 5], [-4, -13], [14, -23], [-32, -18], [11, 11], [48, -16], [-26, 26], [28, 8], [34, -60], [10, -7], [-18, 2], [18, -38], [8, 12], [12, -5], [-22, 27], [-37, 3], [-11, -25], [8, -26], [8, -18], [-2, 16], [-10, 41], [4, -38], [48, -12], [48, -12], [32, -30], [-14, -6], [6, -39], [-2, -10], [66, 4], [-32, -8], [4, -22], [-21, 21], [50, -2], [34, 22], [42, -7], [-17, 37], [-1, 9], [0, 32], [48, -6], [28, -14], [-50, 12], [-6, 0], [-6, -1], [42, -63], [31, 9], [27, 17], [-35, -23], [46, 2], [-48, 0], [30, -7], [-38, -25], [-20, 36], [-4, 22], [13, -3], [-20, -36], [4, -6], [9, 7], [-2, 44], [-33, 49], [11, -37], [-6, 4], [14, -24], [48, -46], [68, -16], [-40, 65], [-14, 26], [-58, 46], [-12, -24], [0, -12], [24, -18], [44, -67], [12, -6], [-68, -12], [-44, -20], [65, -15], [-3, 37], [55, -21], [-53, 17], [-2, -20], [-26, -1], [60, -16], [-2, 2], [23, -13], [-48, 24], [-38, 17], [40, 11], [-38, 6], [-36, 60], [25, -37], [-22, 52], [1, -35], [42, -16], [-21, -21], [-19, 11], [-72, 3], [42, 10], [12, 6], [34, -54], [34, 4], [39, -3], [60, -28], [-78, 18], [-58, -10], [-2, -8], [-58, 10], [-30, 31], [-68, 28], [44, -24], [42, -26], [13, 39], [-12, 29], [-50, -13], [-58, 52], [23, 9], [62, -41], [28, -30], [24, -10], [-23, -7], [-22, -6], [-72, -15], [-54, 20], [-30, 30], [66, -2], [-4, 14], [20, -61], [-49, 55], [-20, 11], [-31, 47], [32, -24], [-11, -31], [4, -27], [14, -54], [26, -51], [74, 10], [-10, 2], [-46, 62], [-88, 12], [46, 30], [64, -8], [-14, 40], [-38, 2], [10, 40], [18, -52], [2, -48], [12, 9], [-30, -9], [-30, -30], [-16, -14], [-34, 72], [16, 10], [48, 24], [36, -50], [-14, -28], [-11, -27], [77, -25], [-82, 8], [8, -40], [0, 42], [-24, -38], [1, -1], [12, 8], [14, -60], [-65, -15], [-38, 7], [-40, 54], [-13, -25], [-2, -16], [-36, 28], [-48, 26], [-54, 13], [-71, -15], [32, -10], [40, -42], [31, -51], [7, 1], [-34, 33], [62, -19], [-73, 35], [36, -10], [56, -47], [29, 45], [9, -13], [-48, 54], [-12, 63], [64, -26], [15, -17], [0, -48], [32, -18], [-54, 4], [8, 16], [-68, 25], [-42, 81], [-28, 42], [6, 14], [-4, -12], [18, -16], [4, -8], [20, -18], [44, -14], [-23, 13], [-22, -44], [-14, 40], [32, -78], [-16, 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_b();".
// 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_b(: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_b();".
// 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_b( : 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;