
// Make newform 1452.3.e.g in Magma, downloaded from the LMFDB on 04 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1452_e();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1452_e_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_1452_3_e_g();".
// 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_1452_3_e_g();".
// 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, -3, -2, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [-7, 0, 2, 1], [21, 10, -4, -5], [-15, 1, -1, 4]];
    Rf_basisdens := [1, 2, 6, 3];
    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_1452_e();"
function MakeCharacter_1452_e()
    N := 1452;
    order := 2;
    char_gens := [727, 485, 1333];
    v := [2, 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_1452_e_Hecke();"
function MakeCharacter_1452_e_Hecke( : Kf := false)
    N := 1452;
    order := 2;
    char_gens := [727, 485, 1333];
    char_values := [[1, 0, 0, 0], [-1, 0, 0, 0], [1, 0, 0, 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 := 3;
    raw_aps := [[0, 0, 0, 0], [-1, 0, 1, 0], [0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -6, 6, 5], [0, 0, 0, 0], [-26, -15, -15, 0], [-2, 21, 21, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 3, -3, 15], [0, 3, -3, 15], [0, 21, -21, -2], [0, 0, 0, 0], [-2, -39, -39, 0], [0, 24, -24, -13], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -21, 21, -8], [-22, 51, 51, 0], [0, 0, 0, 0], [-190, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 39, -39, -20], [0, 0, 0, 0], [0, 0, 0, 0], [0, 51, -51, -10], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [142, 69, 69, 0], [-70, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -9, 9, 38], [-94, 75, 75, 0], [0, 36, -36, 23], [0, 0, 0, 0], [0, 0, 0, 0], [-2, 0, 0, 0], [0, 0, 0, 0], [218, -9, -9, 0], [0, 0, 0, 0], [-194, 45, 45, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -51, 51, -28], [0, -18, 18, -90], [0, 0, 0, 0], [0, 15, -15, 75], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -15, 15, -75], [-218, -171, -171, 0], [0, -6, 6, 65], [-334, -105, -105, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 111, -111, -70], [0, 0, 0, 0], [-262, 111, 111, 0], [0, 0, 0, 0], [-46, -225, -225, 0], [0, -144, 144, 35], [0, -114, 114, -17], [-790, 0, 0, 0], [0, -30, 30, -150], [0, 0, 0, 0], [0, 30, -30, 150], [742, 0, 0, 0], [0, 0, 0, 0], [-118, -261, -261, 0], [0, 0, 0, 0], [0, -69, 69, 100], [0, 129, -129, 22], [0, 0, 0, 0], [0, 0, 0, 0], [122, 279, 279, 0], [0, -171, 171, 70], [0, 0, 0, 0], [502, 129, 129, 0], [0, 0, 0, 0], [-602, 0, 0, 0], [0, 0, 0, 0], [0, -186, 186, 77], [0, -141, 141, 112], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [598, 141, 141, 0], [0, 12, -12, 60], [0, 0, 0, 0], [0, -45, 45, -225], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 42, -42, 210], [626, 15, 15, 0], [-554, 105, 105, 0], [0, 159, -159, 52], [-382, -369, -369, 0], [0, -84, 84, 145], [0, -246, 246, 65], [0, 0, 0, 0], [-674, -195, -195, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -42, 42, -210], [674, 255, 255, 0], [0, 0, 0, 0], [-386, 285, 285, 0], [0, 234, -234, 7], [598, -159, -159, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-314, 345, 345, 0], [70, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 27, -27, 135], [0, 0, 0, 0], [0, 294, -294, -115], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-598, -441, -441, 0], [0, 0, 0, 0], [626, 435, 435, 0], [0, -96, 96, -133], [0, 0, 0, 0], [0, 0, 0, 0], [146, -465, -465, 0], [0, 63, -63, 315], [0, 0, 0, 0], [0, -261, 261, 182], [-1370, 0, 0, 0], [0, 0, 0, 0], [-1750, 0, 0, 0], [0, 15, -15, 75], [0, 0, 0, 0], [0, 60, -60, 300], [0, 0, 0, 0], [0, 0, 0, 0], [0, -279, 279, -40], [0, 0, 0, 0], [0, 0, 0, 0], [0, 21, -21, 188], [0, 201, -201, -220], [0, -84, 84, 215], [1582, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -354, 354, 175], [0, 0, 0, 0], [458, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [506, 615, 615, 0], [0, 369, -369, -28], [0, 0, 0, 0], [0, 366, -366, -17], [0, 0, 0, 0], [0, 0, 0, 0], [1390, 0, 0, 0], [0, 0, 0, 0], [382, -531, -531, 0], [0, 0, 0, 0], [0, 306, -306, -235], [0, -15, 15, -75], [0, 0, 0, 0], [1850, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [982, 549, 549, 0], [0, 0, 0, 0], [286, 705, 705, 0], [0, -45, 45, -225], [0, 0, 0, 0], [0, -441, 441, 170], [0, 0, 0, 0], [1202, -21, -21, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [890, 0, 0, 0], [0, 0, 0, 0], [0, 399, -399, -248], [0, 84, -84, -275], [-1126, -585, -585, 0], [0, 0, 0, 0], [0, 0, 0, 0], [982, 0, 0, 0], [0, 0, 0, 0], [0, -156, 156, -203], [-1322, -399, -399, 0], [0, -18, 18, -90], [0, 0, 0, 0], [-314, -795, -795, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, -33, 33, -165], [0, -276, 276, -155], [0, 0, 0, 0], [0, 0, 0, 0], [0, 531, -531, -152], [698, -609, -609, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 108, -108, 540], [0, 105, -105, 525], [0, 0, 0, 0], [0, 0, 0, 0], [1298, 651, 651, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [718, -639, -639, 0], [0, 0, 0, 0], [694, 885, 885, 0], [0, 0, 0, 0], [0, -129, 129, 328], [0, -546, 546, 67], [0, -369, 369, -130], [0, 0, 0, 0], [-2690, 0, 0, 0], [-146, -915, -915, 0], [0, 0, 0, 0], [0, 0, 0, 0], [430, 0, 0, 0], [0, 90, -90, 450], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 54, -54, 305], [3118, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [1658, 0, 0, 0], [0, 0, 0, 0], [0, -516, 516, -35], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 78, -78, 390], [-3002, 0, 0, 0], [0, 564, -564, -323], [0, -639, 639, 238], [0, 0, 0, 0], [0, 0, 0, 0], [-1006, -1005, -1005, 0], [-1822, -249, -249, 0], [2830, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [982, -711, -711, 0], [0, 141, -141, 310], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [1654, -255, -255, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 414, -414, 187], [-2590, 0, 0, 0], [0, 0, 0, 0], [1174, 1065, 1065, 0], [0, 0, 0, 0], [0, -534, 534, 403], [0, -132, 132, -660], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [166, -1095, -1095, 0], [0, -546, 546, -115], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1452_e_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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