
// Make newform 75.5.c.f in Magma, downloaded from the LMFDB on 29 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_75_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_75_c_Hecke();"
// 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_5_c_f();".
// 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_5_c_f();".
// 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 := [9, -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_c();"
function MakeCharacter_75_c()
    N := 75;
    order := 2;
    char_gens := [26, 52];
    v := [1, 2];
    // 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_75_c_Hecke();"
function MakeCharacter_75_c_Hecke( : Kf := false)
    N := 75;
    order := 2;
    char_gens := [26, 52];
    char_values := [[-1, 0], [1, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := ISA(Type(Kf), Fld), Kf := Kf); // the value of chi on the gens as elements in the Hecke field
    F := Universe(values);// the Hecke field
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),values);
    return chi;
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 := 5;
    raw_aps := [[1, -2], [0, 3], [0, 0], [-72, 0], [-31, 62], [-202, 0], [13, -26], [367, 0], [6, -12], [-62, 124], [-318, 0], [-752, 0], [271, -542], [-982, 0], [202, -404], [-398, 796], [-4, 8], [-3728, 0], [7443, 0], [1138, -2276], [-397, 0], [-6108, 0], [-2247, 4494], [-801, 1602], [-8042, 0], [-1800, 3600], [6598, 0], [-2175, 4350], [-4048, 0], [379, -758], [-13222, 0], [-2148, 4296], [849, -1698], [30197, 0], [-5930, 11860], [-6428, 0], [-15902, 0], [-32147, 0], [2178, -4356], [-8004, 16008], [9383, -18766], [-13858, 0], [-794, 1588], [12673, 0], [-7278, 14556], [22972, 0], [-63043, 0], [-43532, 0], [-6784, 13568], [-86748, 0], [5508, -11016], [16754, -33508], [55627, 0], [8535, -17070], [10860, -21720], [14774, -29548], [12332, -24664], [-2498, 0], [50178, 0], [-9708, 19416], [83463, 0], [-19560, 39120], [123443, 0], [19824, -39648], [-51542, 0], [23408, -46816], [-129483, 0], [-142417, 0], [-12773, 25546], [109132, 0], [-2388, 4776], [26256, -52512], [-138492, 0], [-225802, 0], [75067, 0], [-35952, 71904], [1614, -3228], [16148, 0], [13635, -27270], [-145483, 0], [8377, -16754], [-23108, 0], [-61188, 122376], [70943, 0], [-135818, 0], [42645, -85290], [-64405, 128810], [-256357, 0], [-32076, 64152], [339648, 0], [9668, -19336], [-35802, 71604], [149278, 0], [-17624, 35248], [251002, 0], [-21628, 43256], [-1234, 2468], [-78527, 157054], [371153, 0], [-317328, 0], [321473, 0], [51210, -102420], [-51876, 103752], [102147, -204294], [-207958, 0], [-384857, 0], [-8001, 16002], [67265, -134530], [14380, -28760], [411977, 0], [329228, 0], [109658, 0], [22008, -44016], [-497458, 0], [45142, 0], [-53604, 107208], [-283422, 0], [76012, -152024], [29852, -59704], [8921, -17842], [549022, 0], [-150702, 0], [-90744, 181488], [-92217, 184434], [-789233, 0], [83290, -166580], [-461528, 0], [-126708, 253416], [639178, 0], [-488162, 0], [315082, 0], [-22970, 45940], [424882, 0], [44528, 0], [-43851, 87702], [-791593, 0], [42966, -85932], [-662422, 0], [179282, -358564], [56836, -113672], [-605298, 0], [134418, -268836], [550468, 0], [-162989, 325978], [558402, 0], [-124856, 249712], [347058, 0], [-8645, 17290], [-181733, 0], [20474, -40948], [-310152, 0], [-141748, 283496], [434533, 0], [-52416, 104832], [-465582, 0], [69044, -138088], [1019782, 0], [-218732, 437464], [141573, 0], [284206, -568412], [85812, -171624], [121057, -242114], [-1049432, 0], [-133407, 266814], [-83489, 166978], [61488, -122976], [-1700548, 0], [-1617852, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_75_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_75_5_c_f();".
// 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_5_c_f(:prec:=2)
    chi := MakeCharacter_75_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 5));
    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_5_c_f();".
// 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_5_c_f( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_75_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,5,sign)));
    Vf := Kernel([<2,R![35, 0, 1]>,<7,R![72, 1]>],Snew);
    return Vf;
end function;