
// Make newform 7448.2.a.v in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_7448_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_7448_2_a_v();".
// 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_7448_2_a_v();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_7448_a();"
function MakeCharacter_7448_a()
    N := 7448;
    order := 1;
    char_gens := [1863, 3725, 3041, 3137];
    v := [1, 1, 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_7448_a_Hecke(Kf)
    return MakeCharacter_7448_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 := [[0], [2], [1], [0], [4], [-2], [7], [1], [-3], [4], [-4], [10], [0], [-9], [4], [6], [12], [2], [16], [6], [-2], [4], [9], [4], [4], [3], [-10], [-8], [-14], [-10], [2], [13], [18], [16], [5], [-20], [-25], [-11], [0], [6], [14], [-22], [-13], [10], [23], [-11], [-18], [-4], [-12], [23], [27], [1], [-8], [31], [-12], [3], [-18], [-7], [22], [22], [-23], [4], [-14], [9], [-11], [12], [18], [4], [-7], [11], [-30], [0], [-24], [14], [34], [26], [-21], [-13], [28], [6], [-15], [-10], [-16], [16], [-40], [3], [8], [-2], [-14], [24], [20], [-39], [-38], [-5], [13], [-21], [18], [10], [-28], [15], [-40], [41], [24], [-6], [23], [-6], [-7], [-3], [-6], [-16], [-28], [-11], [17], [25], [-25], [-30], [19], [-3], [-15], [-6], [16], [38], [4], [4], [-23], [17], [17], [-49], [-1], [14], [9], [-8], [-12], [-46], [-37], [-39], [30], [-22], [-12], [-25], [0], [-10], [4], [6], [-28], [-6], [-43], [-18], [-35], [32], [4], [-33], [-27], [10], [12], [-58], [-13], [1], [23], [-24], [-36], [-50], [32], [8], [28], [-22], [-16], [19], [52], [-54], [-54], [-46], [20], [39], [22], [21], [17], [-23], [-40], [-10], [-43], [-60], [32], [56], [57], [63], [34], [-36], [14], [25], [6], [-59], [64], [38], [-20], [-24], [1], [27], [-19], [7], [46], [-8], [52], [-10], [20], [-46], [-16], [-14], [-51], [10], [-41], [70], [-72], [-12], [-70], [2], [-21], [-16], [54], [18], [4], [-50], [52], [35], [-60], [-1], [56], [-48], [52], [-45], [-49], [64], [44], [-6], [17], [-33], [19], [-13], [9], [-22], [-36], [31], [31], [-36], [30], [-64], [-51], [16], [14], [48], [3], [-15], [-48], [-42], [54], [-3], [-22], [8], [-38], [-2], [-14], [26], [-43], [-56], [53], [-36], [0], [-22], [74], [-81], [40], [-4], [-25], [24], [-64], [48], [-52], [-26], [16], [77], [54], [-16], [-4], [-64], [-77], [-25], [-53], [24], [77], [80], [25], [37], [-18], [-40], [26], [-50], [6], [21], [54], [-44], [-5], [12], [-5], [-24], [-28], [-60], [40], [18], [-51], [59], [5], [-5], [30], [-68], [-8], [50], [-57], [86], [57], [90], [-42], [-23], [72], [-30], [-19], [-50], [38], [10], [-78], [-91], [-70], [74], [-80], [44], [13], [7], [-54], [44], [42], [19], [36], [22], [34], [-34], [6], [-24], [-70], [-6], [-38], [-78], [-44], [18], [-50], [6], [78], [78], [51], [-39], [-27], [74], [53], [6], [46], [44], [60], [64], [-78], [-10], [74], [-52], [-50], [-51], [-50], [-33], [-71], [-60], [-65], [-86], [42], [-58], [34], [63], [23], [79], [-40], [24], [-7], [-73], [11], [2], [90], [-48], [-15], [17], [30], [-26], [74], [56], [-84], [51], [-10], [-26], [12], [-12], [70], [-72], [13], [102], [60], [-15], [-22], [18], [-60], [83], [85], [15], [44], [-38], [-5], [78], [-40], [-20], [-87], [40], [32], [-36], [72], [-85], [61], [32]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7448_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7448_2_a_v();".
// 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_7448_2_a_v(:prec:=1)
    chi := MakeCharacter_7448_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_7448_2_a_v();".
// 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_7448_2_a_v( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_7448_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-2, 1]>,<5,R![-1, 1]>,<11,R![-4, 1]>,<13,R![2, 1]>,<17,R![-7, 1]>],Snew);
    return Vf;
end function;