
// Make newform 3750.2.a.k in Magma, downloaded from the LMFDB on 20 June 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_3750_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_3750_2_a_k();".
// 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_3750_2_a_k();".
// 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, 4, -4, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [-2, 0, 1, 0], [0, -3, 0, 1]];
    Rf_basisdens := [1, 1, 1, 1];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    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_3750_a();"
function MakeCharacter_3750_a()
    N := 3750;
    order := 1;
    char_gens := [2501, 3127];
    v := [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_3750_a_Hecke( : Kf := Kf)
    return MakeCharacter_3750_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 := [[-1, 0, 0, 0], [1, 0, 0, 0], [0, 0, 0, 0], [-2, 1, 1, 0], [-2, 2, 0, -3], [1, 0, -2, 2], [-3, -2, 1, -1], [4, -2, -1, 2], [0, -2, -1, 1], [-3, 0, 2, 2], [2, -4, 0, 1], [-3, 3, 2, 0], [3, -4, -4, -1], [0, -3, 3, 3], [-4, 0, -3, -2], [-1, -3, 4, 3], [-2, 1, 2, 5], [1, 1, 0, -5], [-7, 2, -5, -5], [-1, 5, -3, -1], [-11, 5, -5, -11], [1, 1, 6, 7], [-7, 5, -5, -8], [-2, 6, 1, 1], [0, 0, 5, 1], [-6, 0, 3, -4], [-5, -2, -1, -1], [-8, 3, 4, 4], [0, 9, 0, -3], [-10, 0, -3, 2], [0, -5, -2, 9], [-9, -1, 3, 3], [-8, 2, 7, -1], [14, 2, -1, 4], [-10, -5, 6, 0], [5, 0, 2, -5], [-1, 5, 9, 6], [-7, -4, 3, -4], [-1, -3, -9, 7], [-2, 4, 0, 7], [-1, 4, -6, -6], [-2, -2, 6, 10], [2, -11, -3, 5], [7, 2, 3, -7], [-8, 6, -13, -10], [-6, 3, 3, -5], [10, -1, -1, -6], [-13, 7, -5, -15], [7, 0, 11, 6], [-4, 7, -5, -2], [6, -2, -4, -5], [6, -4, 9, 9], [15, 0, 5, 1], [19, -8, 1, 20], [-5, -4, 10, -1], [-4, -1, -4, 2], [-18, 1, -6, -4], [-6, 5, -14, -17], [3, -4, -12, -16], [-2, -1, 6, 10], [6, -9, 8, 5], [2, 7, 4, 14], [14, -4, 8, 15], [-4, -3, 2, -6], [6, -7, -3, -7], [-17, 2, 2, -13], [-9, 3, -3, -22], [7, -4, -5, 10], [0, 0, -10, -19], [-7, 3, 9, 17], [13, -16, 1, 14], [6, -14, -1, 0], [-1, 2, 10, 10], [11, 5, -14, -2], [20, 4, -5, 15], [-19, 11, 9, 2], [-1, -1, 2, -2], [0, 4, 1, 9], [-18, -1, 3, -8], [-7, 9, -4, -11], [-13, 12, -7, -16], [-9, -14, 7, 6], [-9, 4, -4, 7], [3, -7, 9, 0], [-12, -3, 8, 10], [11, 0, -6, -5], [-22, 4, -5, -25], [-7, -7, 6, 6], [-12, 4, -9, -4], [7, -9, 4, 12], [26, -1, 1, 4], [-8, -7, 8, -10], [-16, -1, -5, -9], [-11, 7, -13, -13], [6, 4, 4, 9], [2, 17, 7, -2], [-35, -2, 2, 2], [-2, 6, 8, 12], [0, 7, -9, -6], [-17, 16, 4, -14], [-6, 11, 12, -7], [3, -4, 3, -3], [16, -14, -11, 1], [13, 11, 6, 6], [-8, -10, 0, -16], [1, -11, -14, 3], [0, 1, -8, -17], [-9, 24, -2, -12], [14, 5, -1, 23], [13, -2, -9, 22], [-1, -3, -1, -11], [9, 0, 2, 5], [4, 7, -12, -7], [-17, 9, 16, 18], [-9, -6, -6, -18], [17, 8, 0, 8], [-7, 9, 8, 0], [17, -7, -10, 15], [16, 1, 2, 5], [3, -6, -4, -5], [-15, -6, -2, -2], [2, -4, 6, 3], [13, 4, -11, -3], [-1, -2, 2, 7], [-21, 19, 0, -23], [-13, -11, -5, 8], [10, -1, -20, 1], [7, 11, 11, 5], [-15, 10, 4, -27], [8, -6, -5, -8], [25, -5, -11, -9], [15, -9, 4, 13], [23, -4, 16, 7], [-6, 7, -3, -14], [-14, -5, 21, 4], [11, -4, 9, -7], [28, -20, 4, 29], [32, -10, -1, 9], [23, 8, 5, 0], [4, -10, -11, -12], [-2, 16, 13, -9], [6, -9, 21, 12], [4, 0, 7, -6], [-16, 5, 20, 14], [-7, 3, -1, 6], [-9, -2, -4, 1], [3, 12, 1, -3], [0, 8, -9, -27], [19, -10, 4, 13], [34, -8, 12, 22], [-7, -7, -3, -13], [-1, 13, 2, 21], [-8, -8, -13, 14], [-5, 8, 18, 3], [-14, 1, -5, -28], [19, 8, 10, 18], [18, -3, -8, -5], [-8, 0, -5, 6], [30, -4, 1, 19], [-33, 0, 5, -12], [3, -6, 9, 3], [0, 3, -6, -21], [22, -2, 13, 30], [3, -18, -14, 2], [-6, 0, -14, -15], [33, 9, -4, -1], [14, -1, 15, 7], [8, 24, 12, -13], [12, 9, -18, 3], [-8, 5, 16, 5], [1, 6, 18, 13], [22, -8, -2, 31], [8, -7, -14, -5], [41, -16, 9, 46], [18, -5, -16, 11], [7, -14, 14, 23], [-10, 23, 1, -9], [28, -3, -12, 17], [-35, 7, -6, -11], [-12, 13, 16, 0], [-33, 9, -22, -26], [4, -16, -3, 15], [-37, -6, 1, -19], [-1, -13, 14, -6], [-20, 10, 1, -12], [-21, 22, 10, -29], [-19, -1, -11, 7], [28, -12, 9, 21], [17, 4, 21, 17], [5, 6, 15, -14], [9, -18, -4, 21], [16, -9, 23, 20], [31, -3, 1, 12], [6, 26, -18, -9], [17, -16, 2, 9], [22, 6, 7, 21], [-35, 13, -6, -9], [-18, 19, 16, 6], [16, -11, -22, -27], [3, 10, -7, 13], [-17, -3, -25, 6], [-16, 8, 18, -10], [-4, 2, 7, -22], [22, -11, -11, -10], [-14, 12, 6, 1], [-1, 23, -15, -13], [-7, 3, -4, -32], [1, 20, -6, -2], [-10, 1, -10, -42], [13, -10, -17, -14], [13, -9, -26, 5], [-3, -31, -1, 4], [7, 16, -11, 6], [7, 30, -11, -9], [36, -7, -11, -6], [4, 11, 18, -22], [-31, 14, -4, -7], [-19, 14, 0, -4], [-16, 17, 13, 10], [-23, 5, -8, -22], [-22, 14, 10, 3], [-4, 3, -28, -33], [-11, -5, 8, -18], [-11, 8, -17, -5], [38, -10, 21, 35], [18, -24, -15, 0], [-9, 0, -7, 4], [16, -25, 3, 21], [-10, -20, -5, 15], [37, -11, 24, 22], [-32, -28, 12, -1], [53, -20, 21, 34], [18, -11, -8, 36], [0, -22, -18, 19], [10, 4, -10, -22], [34, 1, -14, -23], [4, -5, -25, -37], [-11, 9, -11, -35], [-18, 13, -5, -13], [-23, 19, -19, -20], [-40, 25, 8, -8], [8, -4, 3, 23], [-6, -20, 3, 6], [-43, 10, -17, -18], [20, -26, 13, 29], [9, 12, 20, -15], [-27, -6, 11, -20], [-21, 10, -25, -30], [-18, 29, 10, -13], [17, -6, 9, 16], [-6, 0, -14, 10], [10, 5, -12, -8], [-2, -13, 34, 15], [-14, -2, -21, -44], [4, 19, 17, -1], [9, 11, -14, 15], [-55, 1, 11, 14], [-11, -4, 16, 0], [7, -14, -11, 25], [8, 14, -4, 17], [-15, 11, 22, -1], [3, 1, 24, 20], [-46, -14, 2, -7], [-27, 9, -20, -49], [-5, 1, -10, 19], [-17, 8, 3, -34], [10, 16, 10, 18], [-51, 11, 7, 8], [21, 2, -27, -21], [-11, -27, -2, -17], [37, -22, 4, 43], [10, -46, -3, 8], [-4, -3, 8, -26], [40, -31, 10, 37], [51, -27, 9, 41], [3, 23, -17, -22], [4, -2, -1, 26], [-31, 6, -25, -20], [36, -38, -1, 29], [5, 25, -4, -17], [-51, 20, -13, -50], [8, -16, -21, -10], [-2, 1, -35, -32], [-59, 7, -5, -2], [0, -4, 12, 32], [2, -22, -9, 28], [-32, 19, 6, -2], [1, -5, -14, -19], [-26, 12, 3, -8], [-3, -5, 8, -14], [30, -27, -18, -15], [29, 30, -25, -7], [33, -25, -17, 17], [20, -6, 39, 29], [6, -9, -30, -27], [-32, -11, 21, 5], [-36, -12, 11, -2], [24, 7, 6, 33], [2, -7, -15, -22], [6, 12, 28, -32], [0, 13, 14, 16], [-12, -19, 10, 0], [-34, -16, -5, -26], [15, 3, 24, 7], [-31, 26, 3, -11], [-22, -10, 1, 26], [-29, 8, -15, 0], [-23, -32, 17, -9], [15, 12, 27, 6], [11, -7, 30, 38], [-27, -6, 32, 5], [27, -19, 12, 46], [28, 8, -7, 7], [-26, 16, -13, -47], [-1, -1, 6, -23], [13, -33, 12, 21], [6, -33, -15, 12], [-38, 2, -4, -65], [32, 1, -28, -22], [-1, 30, 18, 7], [-45, 12, -10, -12], [-40, 20, -3, -3], [22, -21, 11, 32], [-4, -22, 6, -13], [-25, -1, -29, 7], [40, 19, -9, 16], [4, -7, 21, -5], [11, -5, -17, -12], [18, 22, -7, 15], [-18, -2, 11, -2], [-18, -14, 21, 16], [2, -14, -4, 28], [-2, 15, 1, -45], [-36, -2, 13, -44], [-3, 1, -18, -23], [6, -22, -5, 29], [-47, 25, -25, -61], [-33, -7, -1, -1], [8, 9, 17, 31], [-19, -10, 31, 20], [-15, 4, -3, 30], [48, -27, 12, 60], [-7, -7, -36, -22], [-22, 14, 39, 10], [-20, -17, -29, -9], [34, -21, 6, 35], [-17, -21, -34, 10], [29, -10, -3, 17], [30, 3, 33, 7], [-4, -15, 12, -11], [-8, 26, 19, 19], [-34, 13, 9, -2], [-35, -25, 1, 9], [25, 1, -10, 29], [27, 1, -3, 60], [-21, 12, -13, 7], [-3, 13, 15, 14], [8, -22, 1, 34], [-10, 14, -19, -33], [55, -5, 10, 6], [26, -6, 7, 50], [50, -23, 13, 26], [-34, 6, -8, 1], [72, 7, -8, 16], [18, 16, -15, 25], [-1, -43, 16, 16], [-33, 13, -4, 6], [4, -32, -24, 4], [38, -3, 4, 22], [7, 13, -38, 2], [12, -2, 0, 0], [8, 11, 30, 15], [38, -7, 5, 56], [-33, 13, -23, -36], [-2, -8, 29, 3], [14, 9, -20, 37], [8, 0, -12, -41], [8, -50, -13, 9], [33, -32, 11, 19], [44, 5, -2, 50], [27, -24, 6, 39], [-27, 22, 2, -9], [-41, -9, 2, -17], [-43, -5, 8, -8], [-23, -4, -9, -16], [8, -4, -36, -28], [11, 10, 39, 8], [31, 28, 13, -12], [11, -1, -26, -8], [29, -13, 15, 27], [-35, 2, -16, -21], [-8, -4, -17, 8], [7, -24, 0, 23], [3, -30, -20, -40], [30, 21, -5, 5], [13, 21, -25, 13], [4, -14, -2, 1], [20, -3, 9, -11], [5, -30, -10, -15], [-5, 17, 2, -20], [40, 20, 3, -4], [33, -16, -16, 35], [-7, 10, -18, -47], [-25, -8, -4, -29], [24, -6, -34, -47], [1, -8, -4, -22], [-38, 25, 18, -35], [-9, 26, 27, -17], [5, -6, -11, -23], [33, 15, 7, 23], [-13, 12, 16, -11], [-11, 9, 14, -30], [10, -26, 9, -11], [8, -21, -34, 18], [-12, 8, -8, -13], [-62, 3, -4, -60], [50, -3, -9, 41], [1, -5, -11, -35], [1, 26, 23, -7], [35, -1, -14, 48], [45, -36, 3, 42], [-17, -2, -5, -22], [-39, -13, -1, -49], [17, 2, 34, 46], [18, 24, 1, -13], [-25, -13, 32, -7], [15, -13, 18, 28], [19, 13, 2, -25], [-73, 20, -6, -44], [-46, 16, 22, -20]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_3750_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_3750_2_a_k();".
// 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_3750_2_a_k(:prec:=4)
    chi := MakeCharacter_3750_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_3750_2_a_k();".
// 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_3750_2_a_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_3750_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<7,R![-9, -9, 6, 6, 1]>],Snew);
    return Vf;
end function;