
// Make newform 3528.2.a.ba in Magma, downloaded from the LMFDB on 22 February 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_3528_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_3528_2_a_ba();".
// 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_3528_2_a_ba();".
// 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_3528_a();"
function MakeCharacter_3528_a()
    N := 3528;
    order := 1;
    char_gens := [2647, 1765, 785, 1081];
    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_3528_a_Hecke( : Kf := Kf)
    return MakeCharacter_3528_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], [4], [0], [0], [3], [-4], [-7], [-4], [8], [5], [3], [8], [11], [4], [-4], [12], [2], [-3], [-12], [-1], [1], [12], [8], [2], [0], [-3], [12], [-11], [12], [-1], [-8], [-16], [-15], [16], [-20], [18], [-8], [12], [4], [20], [-5], [4], [-9], [-12], [-20], [-16], [12], [-8], [-5], [-28], [8], [2], [20], [12], [-24], [0], [-20], [13], [-12], [1], [-24], [11], [-24], [13], [-24], [-7], [-19], [12], [34], [12], [24], [-17], [-1], [21], [12], [4], [-7], [36], [15], [16], [1], [12], [5], [12], [-4], [-20], [1], [0], [5], [-12], [-4], [-35], [-24], [-29], [-40], [-12], [-24], [-29], [-23], [-8], [-8], [20], [-24], [-25], [-27], [-16], [24], [16], [41], [35], [-26], [0], [-9], [-4], [28], [-7], [48], [-16], [-4], [-35], [-29], [0], [36], [-17], [-20], [-38], [0], [-5], [35], [19], [8], [11], [10], [12], [-31], [8], [-40], [12], [-12], [-24], [36], [-4], [-36], [19], [0], [17], [-48], [8], [8], [14], [-28], [-47], [-24], [53], [4], [-11], [-28], [45], [-36], [-8], [-20], [57], [20], [48], [12], [3], [29], [21], [8], [-32], [-30], [48], [-11], [21], [40], [-31], [-12], [-4], [-43], [-5], [-8], [61], [-28], [48], [24], [2], [43], [45], [24], [-41], [60], [32], [-60], [-20], [0], [-29], [-46], [-16], [-4], [-40], [51], [-26], [2], [24], [48], [28], [-24], [-16], [8], [-9], [-48], [-44], [36], [-44], [57], [-36], [-32], [12], [-20], [-39], [-19], [-28], [-12], [56], [-10], [24], [32], [71], [36], [-23], [-56], [13], [-56], [-19], [60], [43], [24], [-8], [-12], [-28], [-47], [25], [46], [0], [-28], [47], [-20], [0], [-16], [-43], [28], [64], [-45], [8], [-24], [-7], [7], [36], [6], [-43], [72], [-69], [-7], [72], [-59], [-32], [-4], [24], [-48], [5], [16], [19], [-15], [-30], [76], [-52], [-65], [-73], [-36], [48], [65], [48], [-3], [-8], [24], [81], [28], [-39], [-36], [-72], [32], [44], [-64], [35], [32], [-63], [52], [-12], [-17], [-74], [0], [60], [-72], [3], [-7], [12], [71], [88], [-1], [-44], [20], [-8], [40], [-16], [59], [-4], [-44], [59], [72], [-35], [-85], [-48], [73], [-16], [-29], [-23], [29], [-72], [12], [-3], [-12], [-55], [-40], [65], [52], [-50], [-64], [-65], [41], [3], [48], [-36], [35], [-4], [0], [23], [64], [-88], [64], [40], [70], [48], [-84], [3], [60], [84], [-68], [-12], [-96], [-10], [12], [0], [-24], [45], [26], [-72], [-33], [-86], [44], [-11], [36], [16], [11], [93], [92], [-60], [-50], [88], [11], [-76], [-88], [-20], [-36], [-56], [-24], [-55], [22], [89], [-52], [89], [-64], [72], [63], [64], [-10], [44], [-64], [-83], [-60], [66], [-100], [-60], [-48], [40], [1], [50], [88], [9], [-96], [78], [-96], [32], [40], [-87], [-48], [-56], [-31], [-48], [-52], [-12], [1], [-48], [36], [54], [12], [52], [72], [-56], [104]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3528_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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