
// Make newform 3648.2.a.bn in Magma, downloaded from the LMFDB on 06 January 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_3648_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_3648_2_a_bn();".
// 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_3648_2_a_bn();".
// 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 := [-10, -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_3648_a();"
function MakeCharacter_3648_a()
    N := 3648;
    order := 1;
    char_gens := [2623, 2053, 1217, 1921];
    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_3648_a_Hecke( : Kf := Kf)
    return MakeCharacter_3648_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, 0], [-1, 0], [0, 1], [2, -1], [2, -1], [-6, 0], [0, 1], [1, 0], [-4, 0], [-2, 0], [-4, 2], [-2, -2], [2, 2], [2, -3], [-2, -1], [6, 0], [-4, 0], [-4, -1], [-12, 0], [0, 0], [4, -1], [0, -4], [0, 4], [-2, 4], [-6, 0], [-6, 4], [4, -2], [0, -2], [-2, -2], [-18, 0], [-4, 2], [-10, 1], [-8, 1], [18, 1], [-12, 3], [8, 4], [2, 0], [-4, 4], [-4, 6], [-2, -4], [0, 2], [-6, -4], [2, -7], [6, -2], [-22, 0], [-6, -1], [-4, -4], [-16, 4], [-16, -2], [8, 5], [-4, 3], [-6, -3], [-10, 2], [22, 1], [-14, 2], [-2, -1], [-10, 0], [0, 4], [0, 1], [-10, -4], [-6, 1], [18, -2], [-12, -4], [14, -5], [18, -4], [2, 2], [-20, 4], [2, -4], [-18, 1], [16, -3], [18, 4], [18, 5], [-8, 0], [-2, -2], [-16, 2], [-4, 6], [16, -7], [-16, 5], [-6, -6], [2, 0], [8, -4], [10, 4], [20, 2], [2, -8], [-12, -2], [6, 5], [-6, -2], [-24, -3], [-20, 3], [6, 5], [-26, -3], [-12, 4], [-16, -4], [-8, 0], [-2, 7], [28, -4], [22, -8], [18, 2], [0, 6], [4, 11], [8, 10], [36, -1], [-4, 0], [-10, -4], [12, 4], [16, 5], [6, 1], [2, 0], [0, -4], [6, -6], [-12, 6], [24, 5], [-16, 5], [12, 0], [-22, -5], [-2, 0], [-6, 5], [34, 1], [-20, 3], [24, 2], [22, -6], [-2, 2], [-2, 4], [-32, 6], [-2, -5], [-14, -4], [-6, 8], [-22, 1], [-2, 5], [10, -4], [26, 1], [8, 4], [-8, 8], [-28, -1], [8, -7], [0, 13], [-6, 10], [28, -4], [18, 2], [-20, 11], [-8, -2], [-28, -5], [-14, -9], [-12, 12], [6, -6], [4, -10], [-14, -4], [26, -10], [34, 1], [16, -4], [42, -4], [24, -3], [26, -7], [8, -8], [0, -10], [12, -6], [8, -8], [26, -4], [4, -1], [-10, 0], [8, -4], [2, -2], [-40, 0], [20, 0], [-18, 0], [0, 12], [48, 0], [-24, -3], [14, 6], [20, -5], [12, 0], [18, 8], [20, 4], [-30, 4], [-4, -6], [4, -9], [28, -8], [20, 3], [-16, 12], [36, 3], [30, 1], [32, -2], [10, -4], [-14, 6], [-46, 5], [36, 3], [18, -12], [-20, -12], [34, -8], [28, -12], [50, -4], [-14, -9], [-16, 14], [-54, 2], [8, -12], [46, -4], [-20, -1], [-38, 4], [-14, -8], [14, 7], [26, 10], [0, 8], [-18, 10], [10, -8], [32, 4], [-36, 11], [14, 1], [12, -4], [16, -3], [0, 18], [26, -12], [-38, 0], [-22, -1], [12, -8], [-36, -6], [-34, 6], [8, 0], [-22, 2], [-4, 2], [-48, 5], [14, -6], [0, 0], [-2, -8], [62, -3], [-36, 0], [-4, 3], [58, 2], [-8, -8], [-32, -4], [-6, 19], [-36, -9], [32, -2], [20, -2], [-14, 10], [-18, -5], [34, -3], [12, -17], [64, 1], [0, -12], [-16, 0], [-16, -6], [-50, 7], [8, 4], [-2, -14], [-2, 12], [-10, 3], [-18, 13], [-12, -12], [-36, 4], [6, -5], [-38, 4], [28, -1], [-36, -8], [-2, 2], [8, 9], [-24, -12], [0, 17], [8, -10], [26, 6], [-22, 0], [24, 8], [12, -8], [36, -9], [-14, 0], [-12, -5], [16, -6], [22, -12], [-20, -5], [20, 8], [56, 5], [26, 12], [28, 12], [-60, -1], [-54, 7], [22, 10], [40, -16], [-6, -1], [26, -12], [46, 6], [-22, 19], [8, 8], [-8, -8], [-10, 11], [-2, 6], [-6, -7], [-38, -7], [64, -3], [-18, 16], [-6, -5], [30, -12], [50, -12], [-46, -1], [14, -8], [36, 4], [-50, 10], [18, 8], [0, 4], [32, -7], [-32, 10], [22, 11], [-52, 3], [22, 12], [-14, -9], [0, -14], [-18, -13], [2, -20], [-36, -4], [10, -8], [-30, 1], [2, -4], [-38, 5], [10, -16], [-22, -14], [20, -12], [20, 4], [18, -8], [-58, 9], [-20, 18], [-16, 5], [-8, 13], [12, -12], [36, 7], [14, -16], [-12, -14], [-6, -20], [30, 6], [-32, -2], [-4, 8], [-40, -8], [28, 7], [-12, -21], [-26, 4], [-16, 8], [-22, 23], [50, -11], [-42, 1], [-6, 12], [14, 16], [16, 1], [-40, 0], [-26, 10], [24, -23], [38, 0], [0, 4], [-6, 10], [0, -10], [-14, 4], [16, -18], [-12, 14], [-52, -1], [32, -6], [-18, 18], [8, 1], [-36, 10], [-10, 18], [-58, 0], [20, 4], [-56, -4], [48, 9], [-76, -2], [-48, -7], [50, -8], [-16, -12], [-44, -4], [14, -9], [-46, 12], [-30, -12], [-52, 6], [-70, 0], [0, 4], [-64, -6], [-18, 7], [-30, -6], [-22, 7], [32, -19], [16, -18], [-20, 20], [-8, -23], [-4, 7], [-42, 6], [-18, 8], [12, 11], [-18, -3], [12, -17], [-32, 18], [28, -14], [88, 0], [2, -20], [-50, 19], [-20, -6], [-18, 6], [14, -4], [24, -8], [-50, -9], [-40, 12], [26, 12], [40, -20], [46, -16], [-48, 6], [-70, 8], [14, -30], [36, 3], [12, 6], [-34, 0], [42, -14], [30, 5], [-48, -3], [-14, 2], [-24, -14], [-50, 5], [-62, 0], [56, 5], [-40, -10], [-10, 23], [42, 0], [34, -4], [-28, 14], [-48, -4], [58, 8], [12, 18], [34, -10], [2, 4], [22, -29], [48, 2], [30, -18], [-74, 0], [32, -6], [-20, -21], [74, -3], [30, -13]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3648_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_3648_2_a_bn();".
// 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_3648_2_a_bn(:prec:=2)
    chi := MakeCharacter_3648_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_3648_2_a_bn();".
// 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_3648_2_a_bn( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_3648_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![-10, -1, 1]>,<7,R![-8, -3, 1]>,<11,R![-8, -3, 1]>,<23,R![4, 1]>,<31,R![-32, 6, 1]>],Snew);
    return Vf;
end function;