
// Make newform 7448.2.a.b in Magma, downloaded from the LMFDB on 14 December 2025.
// 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_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_7448_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
        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 := 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]];
    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], [-1], [2], [-2], [1], [-3], [4], [4], [-10], [10], [1], [1], [-4], [8], [3], [-4], [-4], [-3], [14], [-9], [6], [-14], [-3], [10], [2], [16], [0], [2], [12], [13], [-1], [-15], [10], [5], [9], [0], [-16], [14], [-8], [-3], [-10], [3], [-19], [-8], [4], [22], [22], [-18], [-24], [-22], [19], [22], [-12], [-12], [-13], [-23], [12], [-7], [-14], [-26], [-4], [11], [12], [-2], [-36], [23], [-26], [-30], [-5], [-16], [4], [-26], [-6], [-6], [18], [-12], [-6], [15], [-20], [24], [4], [-20], [-12], [8], [3], [9], [-31], [-15], [-21], [-38], [15], [3], [21], [-18], [-30], [38], [-25], [0], [21], [6], [-46], [23], [-9], [12], [3], [44], [6], [-22], [14], [-43], [-25], [25], [-40], [-4], [-47], [30], [4], [14], [-12], [16], [-6], [28], [-23], [-23], [-36], [-29], [26], [-16], [-18], [8], [-21], [-3], [-1], [-50], [42], [-18], [-5], [-30], [-15], [-1], [36], [48], [-4], [-17], [-12], [-15], [52], [-6], [-2], [28], [-50], [-48], [-8], [27], [-1], [-23], [44], [-36], [-50], [32], [42], [-12], [-18], [4], [46], [52], [9], [56], [-4], [0], [19], [8], [59], [37], [-23], [20], [35], [-13], [-50], [12], [24], [32], [42], [14], [-64], [-6], [55], [64], [36], [-66], [-68], [-60], [44], [-19], [-53], [-21], [43], [16], [-42], [-42], [0], [20], [21], [1], [-24], [-6], [-60], [-1], [10], [-17], [-38], [0], [38], [-41], [16], [54], [63], [-26], [20], [12], [-40], [30], [59], [64], [-58], [-32], [25], [-9], [16], [34], [34], [-12], [-32], [41], [22], [49], [-48], [-66], [-1], [-11], [-46], [0], [69], [16], [4], [-46], [53], [43], [30], [52], [42], [31], [-63], [73], [62], [18], [-38], [6], [36], [38], [-4], [-53], [-34], [-50], [-33], [4], [-21], [-60], [-74], [-35], [-81], [-76], [-8], [-57], [34], [-54], [-27], [56], [64], [-51], [-56], [-68], [45], [-58], [24], [73], [40], [85], [-67], [12], [-10], [36], [-30], [-36], [74], [-84], [49], [65], [22], [-35], [26], [37], [-80], [60], [-58], [84], [39], [-35], [55], [90], [32], [-48], [-10], [-13], [26], [-2], [-55], [52], [-78], [-32], [10], [21], [-50], [-32], [-30], [22], [-26], [55], [-36], [20], [-29], [-32], [-57], [26], [-24], [-17], [-39], [36], [17], [56], [-74], [76], [6], [10], [-6], [68], [-7], [24], [8], [-65], [64], [-72], [12], [-51], [-41], [53], [-26], [-82], [-46], [-84], [-16], [-15], [-46], [-42], [10], [-66], [-12], [-50], [-81], [-80], [88], [34], [0], [-25], [11], [3], [78], [16], [-57], [28], [-21], [10], [-64], [-87], [-67], [-44], [-32], [40], [-52], [-75], [68], [40], [64], [-84], [54], [-64], [51], [-70], [-41], [22], [-98], [-60], [77], [-82], [92], [0], [20], [2], [-17], [-90], [8], [45], [45], [24], [28], [85], [102], [90], [20], [3], [80], [-32], [16], [62], [-45], [-11], [-7]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_7448_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_7448_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_7448_2_a_b(: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_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_7448_2_a_b( : 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![1, 1]>,<13,R![-2, 1]>,<17,R![2, 1]>],Snew);
    return Vf;
end function;