
// Make newform 1800.3.v.i in Magma, downloaded from the LMFDB on 02 October 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1800_v();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1800_v_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_1800_3_v_i();".
// 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_1800_3_v_i();".
// 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, 0, 0, 0, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]];
    Rf_basisdens := [1, 1, 3, 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_1800_v();"
function MakeCharacter_1800_v()
    N := 1800;
    order := 4;
    char_gens := [1351, 901, 1001, 577];
    v := [4, 4, 4, 3];
    // 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_1800_v_Hecke();"
function MakeCharacter_1800_v_Hecke( : Kf := false)
    N := 1800;
    order := 4;
    char_gens := [1351, 901, 1001, 577];
    char_values := [[1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [0, 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 := 3;
    raw_aps := [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [-4, 0, 4, 3], [2, -4, 0, 4], [0, 3, 0, 0], [4, 0, -4, 6], [0, -12, 1, -12], [12, 2, 12, 0], [0, 12, 14, 12], [-31, -4, 0, 4], [-8, 0, 8, 4], [-28, -4, 0, 4], [-28, -7, -28, 0], [40, 0, -40, -10], [52, -4, 52, 0], [0, 0, -82, 0], [75, -8, 0, 8], [36, 0, -36, -19], [68, -4, 0, 4], [-56, 28, -56, 0], [0, -40, 6, -40], [40, 14, 40, 0], [0, -8, 140, -8], [80, 0, -80, -19], [-56, -4, 0, 4], [24, -96, 24, 0], [36, 0, -36, 64], [0, -56, 23, -56], [-80, -48, -80, 0], [88, 0, -88, 20], [76, -28, 0, 28], [72, 0, -72, -46], [0, -16, 58, -16], [0, -96, -58, -96], [5, -44, 0, 44], [88, 0, -88, 53], [148, -7, 148, 0], [-92, 0, 92, 72], [12, 138, 12, 0], [0, -64, -170, -64], [41, -80, 0, 80], [34, 4, 0, -4], [136, 59, 136, 0], [-72, 0, 72, -142], [0, 4, -93, 4], [-173, -68, 0, 68], [-12, -37, -12, 0], [4, 0, -4, 56], [0, -24, 237, -24], [44, 68, 44, 0], [0, -84, -116, -84], [-161, -64, 0, 64], [-64, 96, 0, -96], [48, 0, -48, 148], [36, -140, 36, 0], [0, -76, -86, -76], [286, 48, 0, -48], [80, 0, -80, 47], [186, -28, 0, 28], [-108, 11, -108, 0], [-160, 158, -160, 0], [4, 0, -4, 113], [166, -128, 0, 128], [-72, -15, -72, 0], [64, 0, -64, -116], [238, 48, 0, -48], [-168, 0, 168, -245], [40, 0, -40, 126], [0, -48, 482, -48], [52, 162, 52, 0], [0, 100, -208, 100], [-108, 0, 108, -93], [-208, 29, -208, 0], [0, -76, -351, -76], [24, -352, 24, 0], [0, 204, -120, 204], [-240, 0, 240, 107], [324, -36, 0, 36], [0, -136, -339, -136], [0, 84, -312, 84], [-398, 152, 0, -152], [-214, 188, 0, -188], [-216, -81, -216, 0], [0, 116, 151, 116], [56, 12, 56, 0], [0, -64, 268, -64], [-544, 0, 544, -8], [-236, -92, 0, 92], [-264, 140, -264, 0], [-20, 0, 20, 298], [0, 88, -134, 88], [-396, 0, 396, 41], [-572, 16, 0, -16], [0, 212, -197, 212], [180, -264, 180, 0], [0, 216, -282, 216], [630, 156, 0, -156], [-252, 185, -252, 0], [91, -176, 0, 176], [-72, 0, 72, -64], [-24, 0, 24, -14], [-172, 378, -172, 0], [0, -252, 158, -252], [191, 140, 0, -140], [176, 0, -176, -391], [-460, 0, 460, 292], [60, -96, 60, 0], [0, 232, 320, 232], [-19, 184, 0, -184], [-224, 0, 224, -132], [192, -268, 192, 0], [36, 0, -36, -128], [0, 316, -21, 316], [-217, 252, 0, -252], [-212, 264, 0, -264], [136, -236, 136, 0], [-600, 0, 600, -104], [-672, -90, -672, 0], [0, -12, -708, -12], [386, 256, 0, -256], [24, 52, 24, 0], [84, 0, -84, -302], [-24, 128, -24, 0], [-618, -144, 0, 144], [-754, 252, 0, -252], [0, -56, -351, -56], [0, -508, -142, -508], [276, 0, -276, -323], [192, -12, 192, 0], [0, 136, 154, 136], [-392, 484, -392, 0], [226, -48, 0, 48], [-408, 0, 408, -145], [-208, -280, 0, 280], [0, 88, -901, 88], [140, -192, 140, 0], [340, 0, -340, 179], [-624, 0, 624, 152], [0, -68, 44, -68], [-947, -36, 0, 36], [50, -240, 0, 240], [60, -471, 60, 0], [-372, 0, 372, 268], [0, -176, -106, -176], [0, -12, 250, -12], [-200, 415, -200, 0], [-456, 0, 456, 436], [0, -320, 154, -320], [1144, 0, 1144, 0], [-264, 0, 264, 59], [-184, 456, 0, -456], [68, -203, 68, 0], [640, 0, -640, -174], [-528, 0, 528, -52], [-242, -496, 0, 496], [0, 60, 373, 60], [0, 284, -466, 284], [552, 0, -552, 307], [354, -280, 0, 280], [804, 0, -804, 326], [792, -172, 792, 0], [-64, 0, 64, -260], [-1418, -72, 0, 72], [1104, 0, -1104, 42], [128, 580, 128, 0], [499, -516, 0, 516], [112, 0, -112, 508], [0, -496, -409, -496], [-248, -6, -248, 0], [0, -156, 266, -156], [-109, 416, 0, -416], [1190, -160, 0, 160], [216, 327, 216, 0], [0, -572, -387, -572], [0, 384, -464, 384], [1617, 60, 0, -60], [430, 460, 0, -460], [-180, 31, -180, 0], [0, -104, -1717, -104], [220, 0, -220, -621], [-428, 0, 0, 0], [-560, -351, -560, 0], [600, 0, -600, -578], [-904, -306, -904, 0], [0, 488, -118, 488], [-48, 0, 48, -599], [-884, 91, -884, 0], [0, -696, 529, -696], [126, 236, 0, -236], [-312, -761, -312, 0], [244, -460, 244, 0], [-1275, 220, 0, -220], [566, -172, 0, 172], [356, 0, -356, 466], [-496, -650, -496, 0], [-674, -680, 0, 680], [688, -428, 688, 0], [32, 0, -32, -630], [60, -54, 60, 0], [0, 28, -616, 28], [1774, -144, 0, 144], [400, 0, -400, -296], [0, 104, 746, 104], [0, 8, 1548, 8], [420, 0, -420, 882], [0, 52, -745, 52], [-804, 750, -804, 0], [0, -552, -696, -552], [1061, -228, 0, 228], [-576, 0, 576, 421], [814, -224, 0, 224], [-516, -459, -516, 0], [-144, 0, 144, 112], [0, -392, 274, -392], [-590, -408, 0, 408], [84, 0, -84, 887], [-14, -676, 0, 676], [-156, 0, 156, -76], [-1068, -90, -1068, 0], [-137, -272, 0, 272], [0, 252, -863, 252], [0, 88, -2386, 88], [264, 916, 264, 0], [-724, 0, 724, 628], [0, -336, -941, -336], [-1116, 614, -1116, 0], [0, -352, 1794, -352], [-548, 0, 548, -1195], [-2346, -204, 0, 204], [160, -341, 160, 0], [0, -208, -154, -208], [1347, 252, 0, -252], [-882, 8, 0, -8], [984, 268, 984, 0], [-528, 0, 528, -1132], [0, 24, 214, 24], [212, -196, 212, 0], [0, -416, -786, -416], [848, -212, 0, 212], [-1004, 758, -1004, 0], [-759, -716, 0, 716], [548, -615, 548, 0], [0, -88, -1245, -88], [-1248, -274, -1248, 0], [0, 160, -110, 160], [572, 0, -572, -927], [-762, -852, 0, 852], [0, -188, -1577, -188], [440, -534, 440, 0], [-448, 0, 448, 540], [-238, 572, 0, -572], [-400, 0, 400, -904], [0, 296, 1471, 296], [404, 74, 404, 0], [0, -880, -516, -880], [761, 728, 0, -728], [792, 0, -792, 188], [-356, 0, 356, 128], [-1408, 0, 1408, -660], [1852, 41, 1852, 0], [-20, 0, 20, 370], [0, 1120, 106, 1120], [-816, 97, -816, 0], [-536, 0, 536, -306], [0, 48, 506, 48], [0, 576, 1802, 576], [-728, -872, 0, 872], [-816, 1212, -816, 0], [-1776, -214, -1776, 0], [809, -496, 0, 496], [-1896, 0, 1896, 296], [-816, -20, -816, 0], [0, -244, -1219, -244], [1776, 0, -1776, 321], [-1348, -325, -1348, 0], [1248, 0, -1248, 190], [0, -432, -1951, -432], [1663, -72, 0, 72], [1620, 216, 0, -216], [-244, -1028, -244, 0], [138, -408, 0, 408], [-252, 0, 252, 598], [-963, 520, 0, -520], [-964, 0, 964, -241], [-478, 1088, 0, -1088], [560, -55, 560, 0], [-460, 0, 460, 1044], [0, -320, 902, -320], [0, -268, -1644, -268], [-842, 592, 0, -592], [-912, 0, 912, -292], [632, 632, 632, 0], [-1220, -912, 0, 912], [-824, 939, -824, 0], [0, -100, 1292, -100], [779, -476, 0, 476], [-500, 376, -500, 0], [0, 564, -1610, 564], [-816, 0, 816, -476], [-1104, 956, -1104, 0], [-1016, 0, 1016, -704], [0, -44, 461, -44]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1800_v_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1800_3_v_i();".
// 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_1800_3_v_i(:prec:=4)
    chi := MakeCharacter_1800_v();
    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_1800_3_v_i();".
// 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_1800_3_v_i( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1800_v();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<7,R![25, 80, 128, 16, 1]>,<11,R![-92, -4, 1]>,<17,R![5776, 1216, 128, -16, 1]>],Snew);
    return Vf;
end function;