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