
// Make newform 75.4.a.c in Magma, downloaded from the LMFDB on 02 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_75_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_75_4_a_c();".
// 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_75_4_a_c();".
// 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_75_a();"
function MakeCharacter_75_a()
    N := 75;
    order := 1;
    char_gens := [26, 52];
    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_75_a_Hecke( : Kf := Kf)
    return MakeCharacter_75_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 := 4;
    raw_aps := [[-1, -1], [-3, 0], [0, 0], [-6, 6], [-18, -6], [-42, 6], [-46, -10], [40, -24], [28, -8], [-180, 42], [32, -12], [-126, -54], [-198, -12], [-12, -96], [-136, 92], [-242, 82], [-90, -6], [122, 96], [-336, -60], [-108, 180], [-612, -108], [40, 300], [388, 208], [630, -144], [264, 240], [-468, -186], [1578, -66], [1124, -88], [-230, -204], [118, -542], [954, -90], [-1278, -354], [494, 314], [-20, -36], [-360, 498], [272, -180], [294, -546], [1368, 180], [44, -64], [-1862, 838], [-2970, 90], [3362, -12], [-2268, 444], [-852, 348], [-2386, -262], [3400, 108], [-1588, 1068], [2418, 246], [764, -64], [-410, 804], [-3662, -506], [-900, 516], [-1498, -696], [-558, 630], [-226, -118], [28, -200], [3060, -1674], [3632, -1596], [-6126, 258], [2862, -168], [-3912, 996], [-3842, 730], [2484, -2088], [2052, -1956], [1068, -420], [-4006, 2222], [-1888, 2520], [7044, -132], [-5356, 920], [-3470, 552], [10018, -794], [720, -1656], [1434, -1722], [678, -3666], [2740, -3300], [-1232, 1900], [9360, 1194], [-4446, 1962], [4302, 2076], [-3650, 84], [-8550, 2766], [-5818, 852], [1872, 2808], [2988, 3420], [4360, 3180], [-7892, -584], [-2250, 2628], [4944, -1704], [5832, -150], [-6162, 114], [-6796, 152], [-14580, -1380], [-5706, 2610], [-9918, -1074], [12280, 336], [-2312, -2924], [8460, -2886], [9342, -3852], [-2952, -3996], [-1078, -3132], [-276, -1344], [-22906, -790], [-5012, 808], [10350, -444], [-4288, -2136], [15264, 0], [2564, 1592], [7318, -1646], [-12240, -1032], [2282, 2004], [-23106, -150], [-13302, 5778], [7874, 854], [-4700, -3276], [-3928, 60], [-8118, -4452], [-8592, 8124], [-4096, -6220], [-15182, -890], [5490, -6690], [8282, 4680], [1428, -2508], [-13366, 5438], [-4652, -2960], [10112, -1056], [-16308, -54], [-19010, -1764], [-19080, 3168], [10614, 2994], [4818, -1326], [-5360, 5304], [6328, -5996], [31352, -1236], [-16686, -3726], [-4698, 9132], [20650, -4452], [23698, -1610], [14424, -2868], [3914, -7498], [8010, -2700], [-19708, 2700], [6372, -6918], [19758, -1902], [14444, -2080], [-6590, 2700], [-16920, -1200], [-12702, 6330], [5354, 10142], [34420, 300], [-21932, 4384], [-28506, -5874], [-15138, -3168], [21168, -10836], [10124, 4112], [-27276, 6072], [-16848, -2400], [1240, -3780], [-9450, 6756], [13464, 2808], [-12528, 6018], [22724, 7784], [-16082, 5866], [24594, 5070], [9522, 918], [26234, -4210], [35488, 3772], [-20128, 7980], [-14946, 3894]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_75_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_75_4_a_c();".
// 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_75_4_a_c(:prec:=2)
    chi := MakeCharacter_75_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 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_75_4_a_c();".
// 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_75_4_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_75_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<2,R![-8, 3, 1]>],Snew);
    return Vf;
end function;