
// Make newform 275.3.q.c in Magma, downloaded from the LMFDB on 02 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_275_q();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_275_q_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_275_3_q_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_275_3_q_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 := [1, 0, -1, 0, 1, 0, -1, 0, 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_275_q();"
function MakeCharacter_275_q()
    N := 275;
    order := 10;
    char_gens := [177, 101];
    v := [5, 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_275_q_Hecke();"
function MakeCharacter_275_q_Hecke( : Kf := false)
    N := 275;
    order := 10;
    char_gens := [177, 101];
    char_values := [[-1, 0, 0, 0, 0, 0, 0, 0], [0, 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, -2, 0, 0, 0, -2, 0, 1], [0, 4, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 3, 0, 3, 0, 2], [-4, 0, -2, 0, -7, 0, 10, 0], [0, 7, 0, 9, 0, -2, 0, 1], [0, -12, 0, 14, 0, -16, 0, 28], [-1, 0, -19, 0, 18, 0, -9, 0], [0, 0, 0, -1, 0, 27, 0, -1], [-36, 0, 16, 0, -18, 0, 20, 0], [20, 0, -22, 0, 20, 0, 0, 0], [0, 11, 0, 4, 0, -4, 0, -11], [37, 0, -3, 0, 40, 0, -20, 0], [0, 12, 0, 16, 0, 6, 0, -28], [0, 75, 0, 0, 0, 17, 0, -17], [0, 43, 0, -43, 0, 0, 0, -28], [0, 0, 19, 0, -90, 0, 19, 0], [28, 0, 2, 0, 2, 0, 28, 0], [0, 0, 0, -10, 0, 34, 0, -10], [-12, 0, 22, 0, -22, 0, 12, 0], [0, -50, 0, 4, 0, 4, 0, -50], [-2, 0, 44, 0, -86, 0, 88, 0], [0, -108, 0, 26, 0, 56, 0, 52], [68, 0, 0, 0, 97, 0, -97, 0], [0, -62, 0, 62, 0, 0, 0, 52], [72, 0, -32, 0, -8, 0, -64, 0], [0, 21, 0, -86, 0, 86, 0, -21], [0, 56, 0, -112, 0, 40, 0, -72], [60, 0, -120, 0, 86, 0, -34, 0], [0, -16, 0, 0, 0, -90, 0, 90], [0, 39, 0, 26, 0, -91, 0, 52], [-28, 0, 56, 0, -92, 0, -36, 0], [0, 26, 0, 78, 0, 26, 0, 0], [-110, 0, 141, 0, -55, 0, -31, 0], [8, 0, -54, 0, -54, 0, 8, 0], [50, 0, 58, 0, -8, 0, 4, 0], [0, -184, 0, 0, 0, 19, 0, -19], [0, -154, 0, 154, 0, 0, 0, 158], [0, 53, 0, -17, 0, 70, 0, -35], [0, 84, 0, -168, 0, 77, 0, -91], [17, 0, -17, 0, 0, 0, -198, 0], [-12, 0, -98, 0, 98, 0, 12, 0], [0, 0, -44, 0, -16, 0, -44, 0], [0, 134, 0, -42, 0, -50, 0, -84], [0, -162, 0, 221, 0, -81, 0, -59], [-80, 0, 0, 0, 116, 0, -116, 0], [-80, 0, -24, 0, 128, 0, -48, 0], [0, -162, 0, 0, 0, 73, 0, -73], [0, 58, 0, 168, 0, 168, 0, 58], [14, 0, 116, 0, 14, 0, 0, 0], [0, 134, 0, -54, 0, 188, 0, -94], [94, 0, 82, 0, 12, 0, -6, 0], [64, 0, -128, 0, -17, 0, -145, 0], [-13, 0, 127, 0, -13, 0, 0, 0], [0, 254, 0, -248, 0, 248, 0, -254], [0, 220, 0, -41, 0, 110, 0, -179], [-290, 0, 224, 0, -224, 0, 290, 0], [404, 0, -344, 0, 202, 0, -60, 0], [0, -271, 0, -87, 0, -184, 0, 92], [-108, 0, 116, 0, 116, 0, -108, 0], [0, -226, 0, 452, 0, -212, 0, 240], [0, -8, 0, -177, 0, -177, 0, -8], [0, -20, 0, 180, 0, -10, 0, -160], [-264, 0, 264, 0, 0, 0, 210, 0], [0, -124, 0, 518, 0, -124, 0, 0], [0, 155, 0, -155, 0, 0, 0, -179], [217, 0, 0, 0, 315, 0, -315, 0], [0, -258, 0, -84, 0, -84, 0, -258], [0, 96, 0, -80, 0, 64, 0, -160], [142, 0, -126, 0, 268, 0, -134, 0], [0, 0, 0, 318, 0, -20, 0, 318], [204, 0, -398, 0, 102, 0, 194, 0], [0, 114, 0, 2, 0, -2, 0, -114], [0, -232, 0, 75, 0, -116, 0, 157], [-270, 0, 219, 0, -219, 0, 270, 0], [0, 215, 0, -215, 0, 0, 0, -354], [0, 0, -272, 0, 58, 0, -272, 0], [0, 0, 0, 395, 0, 29, 0, 395], [-111, 0, -292, 0, 292, 0, 111, 0], [-31, 0, -100, 0, 231, 0, -200, 0], [261, 0, 0, 0, 263, 0, -263, 0], [252, 0, -252, 0, 0, 0, -528, 0], [158, 0, 78, 0, -314, 0, 156, 0], [0, -340, 0, -2, 0, 2, 0, 340], [122, 0, -244, 0, -50, 0, -294, 0], [0, -56, 0, 0, 0, -70, 0, 70], [-205, 0, 468, 0, -205, 0, 0, 0], [0, 88, 0, 100, 0, -288, 0, 200], [-144, 0, 288, 0, -158, 0, 130, 0], [0, 0, 0, -181, 0, -198, 0, -181], [0, 440, 0, 46, 0, 440, 0, 0], [114, 0, 256, 0, 256, 0, 114, 0], [0, -102, 0, 0, 0, -472, 0, 472], [-844, 0, 553, 0, -422, 0, 291, 0], [0, 0, 445, 0, -3, 0, 445, 0], [0, 45, 0, -90, 0, -257, 0, -347], [350, 0, -350, 0, 0, 0, -42, 0], [0, 0, 305, 0, -193, 0, 305, 0], [0, 352, 0, -10, 0, -332, 0, -20], [136, 0, -44, 0, -48, 0, -88, 0], [0, -176, 0, 352, 0, -180, 0, 172], [0, 379, 0, 164, 0, 164, 0, 379], [0, -56, 0, -180, 0, 124, 0, -62], [-505, 0, -281, 0, -224, 0, 112, 0], [-226, 0, 452, 0, -195, 0, 257, 0], [0, 344, 0, -36, 0, 344, 0, 0], [0, 822, 0, -550, 0, 550, 0, -822], [0, -440, 0, 330, 0, -220, 0, 110], [764, 0, -652, 0, 652, 0, -764, 0], [280, 0, -447, 0, 140, 0, 167, 0], [0, -240, 0, 432, 0, -672, 0, 336], [0, 196, 0, -392, 0, 732, 0, 340], [0, 0, 0, -114, 0, 366, 0, -114], [73, 0, -73, 0, 0, 0, 9, 0], [0, 0, 552, 0, 116, 0, 552, 0], [423, 0, -423, 0, 0, 0, 369, 0], [0, 364, 0, -616, 0, 364, 0, 0], [0, -528, 0, 528, 0, 0, 0, 790], [0, -1087, 0, 1076, 0, -1076, 0, 1087], [246, 0, -492, 0, 89, 0, -403, 0], [48, 0, 0, 0, 552, 0, -552, 0], [0, -566, 0, -422, 0, -144, 0, 72], [0, -292, 0, -132, 0, 556, 0, -264], [0, 0, 0, 220, 0, 624, 0, 220], [75, 0, 543, 0, 75, 0, 0, 0], [-710, 0, 158, 0, -868, 0, 434, 0], [-892, 0, 342, 0, -342, 0, 892, 0], [0, 0, -18, 0, -714, 0, -18, 0], [0, 0, 0, -525, 0, 839, 0, -525], [0, 260, 0, -692, 0, -692, 0, 260], [521, 0, 49, 0, -619, 0, 98, 0], [0, 627, 0, -573, 0, 519, 0, -1146], [922, 0, -922, 0, 0, 0, -878, 0], [0, 601, 0, -601, 0, 0, 0, -157], [60, 0, -204, 0, 348, 0, -408, 0], [-229, 0, 458, 0, -285, 0, 173, 0], [0, -112, 0, 0, 0, -347, 0, 347], [0, -322, 0, 12, 0, 298, 0, 24], [0, 21, 0, -12, 0, 21, 0, 0], [45, 0, -564, 0, -564, 0, 45, 0], [-643, 0, 1, 0, -644, 0, 322, 0], [-656, 0, 206, 0, -328, 0, 450, 0], [0, 205, 0, -205, 0, 0, 0, 961], [0, -254, 0, -466, 0, 212, 0, -106], [0, 0, -122, 0, 1398, 0, -122, 0], [-834, 0, 834, 0, 0, 0, 10, 0], [0, 759, 0, -91, 0, -577, 0, -182], [0, -460, 0, 650, 0, -230, 0, -190], [822, 0, 0, 0, 1125, 0, -1125, 0], [0, -805, 0, 206, 0, -805, 0, 0], [0, 139, 0, -278, 0, -373, 0, -651], [336, 0, 0, 0, 833, 0, -833, 0], [0, -458, 0, 0, 0, -84, 0, 84], [0, 146, 0, -397, 0, -397, 0, 146], [0, -538, 0, 230, 0, -538, 0, 0], [458, 0, 354, 0, 458, 0, 0, 0], [266, 0, 488, 0, 488, 0, 266, 0], [1092, 0, -1189, 0, 1189, 0, -1092, 0], [0, 110, 0, 378, 0, -268, 0, 134], [-220, 0, 146, 0, 146, 0, -220, 0], [0, 0, 0, -124, 0, -604, 0, -124], [0, 1108, 0, 290, 0, 290, 0, 1108], [0, 1188, 0, -993, 0, 594, 0, -195], [-325, 0, 325, 0, 0, 0, 338, 0], [0, -698, 0, 698, 0, 0, 0, -130], [0, -846, 0, 967, 0, -967, 0, 846], [-98, 0, 0, 0, 350, 0, -350, 0], [0, 84, 0, -32, 0, -32, 0, 84]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_275_q_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_275_3_q_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_275_3_q_c(:prec:=8)
    chi := MakeCharacter_275_q();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 3));
    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_275_3_q_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_275_3_q_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_275_q();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<2,R![25, 0, 75, 0, 85, 0, -5, 0, 1]>,<3,R![65536, 0, -4096, 0, 256, 0, -16, 0, 1]>],Snew);
    return Vf;
end function;