
// Make newform 2088.2.a.b in Magma, downloaded from the LMFDB on 14 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_2088_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_2088_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_2088_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_2088_a();"
function MakeCharacter_2088_a()
    N := 2088;
    order := 1;
    char_gens := [1567, 1045, 929, 1945];
    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_2088_a_Hecke( : Kf := Kf)
    return MakeCharacter_2088_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], [-2], [-4], [0], [2], [-6], [0], [4], [-1], [6], [4], [-6], [4], [0], [2], [-2], [0], [12], [0], [14], [10], [6], [6], [2], [10], [16], [-6], [-2], [-6], [2], [4], [-18], [4], [-10], [-8], [4], [-12], [20], [22], [-18], [-22], [-8], [14], [-22], [16], [12], [20], [18], [4], [-8], [8], [-10], [-12], [12], [32], [-18], [2], [14], [16], [12], [-2], [-28], [8], [6], [2], [-8], [6], [-2], [10], [-32], [16], [-34], [6], [-32], [32], [6], [-34], [28], [-14], [2], [-20], [20], [-2], [-4], [-32], [34], [38], [30], [-24], [36], [24], [-8], [-36], [4], [-16], [-38], [36], [12], [32], [28], [30], [0], [-10], [-4], [10], [-42], [-32], [0], [-22], [6], [10], [26], [44], [-12], [30], [28], [20], [14], [-44], [-30], [30], [34], [14], [28], [-14], [-6], [-36], [14], [24], [20], [24], [14], [-52], [40], [14], [-18], [36], [-6], [10], [-36], [-6], [-22], [44], [32], [32], [-32], [24], [-28], [-12], [2], [-42], [4], [-24], [16], [16], [0], [16], [30], [38], [-48], [-4], [34], [-24], [-8], [-16], [-20], [-8], [22], [26], [30], [-22], [12], [-26], [40], [0], [20], [38], [14], [6], [46], [-28], [-46], [-12], [-36], [14], [56], [28], [66], [20], [30], [-24], [-24], [18], [20], [60], [42], [26], [-36], [20], [-50], [-24], [60], [6], [52], [34], [6], [-30], [0], [4], [-42], [14], [-58], [-60], [-24], [6], [-44], [-2], [-60], [66], [68], [28], [26], [18], [-10], [-44], [30], [-16], [22], [-22], [-24], [4], [-2], [14], [-28], [32], [-6], [-54], [70], [64], [44], [36], [-4], [-20], [-72], [-16], [12], [-38], [-44], [72], [64], [8], [48], [-34], [46], [-10], [-4], [48], [-62], [6], [-58], [-60], [74], [-44], [-10], [-36], [-6], [54], [68], [-66], [-70], [-68], [70], [-38], [-10], [-2], [52], [-50], [-6], [-10], [72], [-12], [-32], [-10], [12], [56], [58], [-78], [64], [-12], [-10], [-78], [-36], [60], [-64], [-18], [-2], [2], [66], [-16], [-34], [54], [82], [24], [-84], [-42], [20], [-70], [-84], [-34], [-24], [-86], [-56], [-12], [-40], [-46], [-24], [4], [-62], [30], [8], [50], [-70], [-70], [-12], [50], [68], [-76], [-16], [-90], [-32], [22], [20], [40], [32], [-22], [30], [-90], [-90], [-68], [44], [72], [-58], [-36], [18], [-36], [24], [-52], [32], [62], [-76], [42], [30], [-4], [-40], [6], [40], [66], [50], [-48], [54], [12], [0], [-74], [72], [-30], [38], [-52], [-50], [-4], [-28], [64], [-34], [-36], [78], [72], [-80], [42], [76], [58], [-46], [0], [-10], [46], [-4], [-92], [-86], [18], [52], [72], [-74], [-18], [60], [-64], [0], [-38], [8], [38], [4], [-42], [-14], [54], [58], [-32], [-78], [40], [22], [-26], [52], [26], [-50], [30], [58], [76], [-2], [-18], [24], [-100], [38], [40], [-90], [40], [-88], [72], [70], [-14], [-14], [18], [-52], [72]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_2088_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_2088_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_2088_2_a_b(:prec:=1)
    chi := MakeCharacter_2088_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_2088_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_2088_2_a_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_2088_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<5,R![2, 1]>,<7,R![4, 1]>,<11,R![0, 1]>,<17,R![6, 1]>],Snew);
    return Vf;
end function;