
// Make newform 1904.2.a.k in Magma, downloaded from the LMFDB on 25 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1904_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_1904_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_1904_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 := [-3, -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_1904_a();"
function MakeCharacter_1904_a()
    N := 1904;
    order := 1;
    char_gens := [239, 1429, 1361, 785];
    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_1904_a_Hecke( : Kf := Kf)
    return MakeCharacter_1904_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], [0, 1], [1, -1], [1, 0], [-4, 0], [0, -2], [-1, 0], [-4, -2], [-4, 0], [0, 4], [-5, -1], [-4, 6], [0, -5], [2, 1], [-2, 2], [3, -1], [8, 0], [4, 5], [-5, 1], [8, -2], [-4, 5], [-2, 2], [6, -4], [-6, 6], [-11, -1], [-8, -2], [-14, 0], [0, 2], [14, -4], [-14, 2], [-3, -5], [0, 4], [2, 7], [3, -5], [-2, -1], [-14, 1], [2, 0], [-6, 2], [4, -7], [0, 9], [2, -5], [-6, 0], [-9, 9], [8, -10], [-2, -2], [-12, 1], [-20, 6], [0, -6], [-9, 3], [8, -4], [22, 2], [-2, -7], [-15, -5], [16, -6], [14, -8], [0, 8], [22, -4], [-8, 8], [20, -8], [-3, -7], [5, -11], [-2, -4], [-4, 0], [-3, 9], [-3, 3], [-6, -12], [17, -9], [4, -8], [10, -16], [0, 8], [-16, 0], [13, -5], [0, -3], [10, -11], [-28, 8], [20, -8], [-9, -9], [-19, 3], [-2, 2], [8, -6], [-3, 5], [18, -3], [-8, 16], [-12, 2], [-28, 3], [24, 4], [18, -10], [-7, -3], [28, -2], [-14, 9], [12, 2], [-24, 3], [28, 0], [11, 5], [20, 4], [15, 7], [2, 2], [-12, 5], [8, -20], [4, 0], [-2, 0], [-30, 4], [-4, 0], [6, 7], [4, 18], [-22, 6], [16, -2], [36, -6], [-6, -9], [-10, 24], [25, -11], [-1, -9], [-20, 12], [-28, -4], [7, -7], [16, 12], [-24, 7], [8, 12], [22, 8], [-5, -7], [18, -10], [16, -10], [-6, 0], [-18, 2], [-28, 13], [-30, 8], [28, -14], [-12, 1], [-4, 8], [-16, 14], [-2, 11], [30, 2], [-8, 2], [-10, 1], [-18, -14], [10, -20], [-6, 10], [-32, -8], [2, 20], [-6, -6], [16, -5], [24, -14], [34, 2], [-36, -4], [16, -14], [0, -8], [-10, 0], [7, -23], [50, 2], [25, -21], [-6, 2], [3, -7], [-19, 3], [11, -29], [-18, -4], [2, 6], [22, -21], [43, -3], [-28, -4], [-36, 1], [12, -16], [27, -21], [-2, 5], [-12, 4], [-11, 1], [19, -29], [2, 4], [-48, 1], [-28, -4], [-36, 3], [8, 24], [-8, 4], [-8, -2], [-11, 25], [-8, 10], [-27, 15], [-36, 10], [-24, 26], [0, 14], [8, -4], [-20, 4], [-24, 1], [-30, 22], [30, -12], [37, -1], [-16, -16], [46, -10], [50, -10], [-48, -8], [-16, 12], [-24, 9], [-8, 26], [8, 16], [-6, 14], [-16, 10], [-1, 13], [-18, -8], [-8, 6], [-12, -5], [-22, 22], [20, -26], [-13, 7], [38, 12], [2, 2], [16, -6], [-10, -2], [-10, 10], [-26, 7], [-12, 32], [-58, 4], [-8, 28], [18, -12], [-6, 4], [-26, -10], [52, -7], [-36, 11], [40, -8], [-8, 16], [-26, 2], [21, -27], [19, -9], [8, 5], [-26, 9], [-32, 16], [-12, 14], [17, 1], [-22, 0], [-42, -2], [-8, -14], [-42, 10], [6, -9], [-12, 16], [-12, -4], [-18, -21], [64, -2], [2, 2], [10, -8], [-14, 14], [-14, -4], [26, 20], [-32, -4], [14, -16], [38, -10], [-30, 19], [31, -27], [51, -9], [-52, 15], [32, 7], [-37, 5], [30, -13], [58, 7], [15, -23], [-15, 27], [-41, -3], [22, -8], [-30, -11], [42, -26], [-3, 1], [-40, -7], [58, -12], [-22, 6], [-25, 1], [19, 9], [49, -17], [-12, 13], [2, 18], [7, 23], [-6, -24], [22, -8], [-22, 1], [-1, -19], [-28, 12], [-20, -4], [25, -29], [24, 12], [-10, 10], [18, -21], [63, 7], [18, -19], [14, 8], [42, -8], [-4, -22], [-60, 0], [-38, 10], [-3, 37], [34, -13], [-10, -24], [-12, 30], [-52, 2], [4, 12], [-68, 2], [-13, 11], [66, 8], [37, -19], [-2, -24], [-12, 1], [-38, 16], [40, -14], [-53, 11], [-26, -12], [-60, 20], [-58, 0], [-16, -24], [36, 2], [-28, 32], [32, -18], [-9, 9], [-76, 5], [33, -33], [10, 15], [-17, -13], [38, -4], [0, 36], [6, -23], [18, -9], [-32, 20], [42, 4], [-6, -18], [-8, -3], [-10, 4], [-72, -7], [38, -6], [-40, 22], [-35, 35], [78, 0], [50, -26], [-34, 24], [67, 7], [-26, 28], [-2, -2], [36, -22], [-24, 12], [32, -39], [8, 14], [8, -38], [40, -16], [26, 3], [-72, 13], [24, -7], [14, -4], [34, 5], [57, -11], [-58, 4], [-59, 19], [-38, 11], [50, 6], [41, 15], [-19, 23], [-21, 3], [40, -23], [-48, -8], [20, 18], [-46, -13], [-7, -19], [-39, 29], [-42, 10], [30, -24], [-28, 19], [-6, 8], [52, -4], [6, -2], [-19, 19], [-27, 7], [46, 4], [-26, 50], [33, 5], [36, 9], [10, 29], [-26, -14], [42, -13], [64, -5], [-42, 30], [22, -31], [-10, 44], [-4, 20], [-48, 39], [-6, -30], [-64, 22], [-40, 36], [-58, -4], [4, 13], [18, 4], [32, -2], [20, 10], [-64, 11], [0, 8], [52, 16], [4, 18], [10, -18], [-14, 8], [-48, -4], [42, -40], [57, -29], [68, 12], [-73, 13], [-20, -8], [22, -24], [-24, 16], [-64, 4], [-79, -7], [-22, 8], [-49, -5], [-18, 39], [-4, -3], [72, 6], [60, 16], [-11, 9], [-26, 41], [26, 28], [20, 25], [-15, 31], [-41, 43], [9, 11], [-20, -28], [30, -7], [-24, -29], [24, -20], [-3, 1], [-15, 15], [30, 28], [54, -33], [12, 19], [18, -24], [24, 0], [-50, -8], [54, -8], [-12, -24], [-24, -24], [8, -30], [-29, -21]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1904_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1904_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_1904_2_a_k(:prec:=2)
    chi := MakeCharacter_1904_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_1904_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_1904_2_a_k( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1904_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-3, -1, 1]>,<5,R![-3, -1, 1]>],Snew);
    return Vf;
end function;