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