
// Make newform 1200.4.f.c in Magma, downloaded from the LMFDB on 23 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1200_f();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1200_f_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_1200_4_f_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_1200_4_f_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];
        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_1200_f();"
function MakeCharacter_1200_f()
    N := 1200;
    order := 2;
    char_gens := [751, 901, 401, 577];
    v := [2, 2, 2, 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_1200_f_Hecke();"
function MakeCharacter_1200_f_Hecke( : Kf := false)
    N := 1200;
    order := 2;
    char_gens := [751, 901, 401, 577];
    char_values := [[1, 0], [1, 0], [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 := 4;
    raw_aps := [[0, 0], [0, -3], [0, 0], [0, 1], [-42, 0], [0, 67], [0, 54], [-115, 0], [0, -162], [210, 0], [193, 0], [0, -286], [12, 0], [0, 263], [0, -414], [0, 192], [690, 0], [-733, 0], [0, -299], [228, 0], [0, -938], [-160, 0], [0, -462], [240, 0], [0, -511], [912, 0], [0, 668], [0, 1296], [1735, 0], [0, 1092], [0, 16], [-1992, 0], [0, -2346], [2900, 0], [2070, 0], [-2237, 0], [0, -241], [0, -3547], [0, -984], [0, -3618], [-150, 0], [197, 0], [-1302, 0], [0, -4163], [0, 3054], [3425, 0], [2443, 0], [0, 23], [0, 1956], [-1805, 0], [0, -3468], [2640, 0], [-5383, 0], [5028, 0], [0, 564], [0, -1812], [5190, 0], [-4592, 0], [0, -2191], [7842, 0], [0, -247], [0, 5442], [0, 3871], [5718, 0], [0, 3637], [0, -1296], [-5132, 0], [0, -6751], [0, 5226], [6190, 0], [0, -6618], [-3420, 0], [0, 871], [0, -6383], [-9865, 0], [0, 9828], [-12540, 0], [0, -1381], [14232, 0], [-2645, 0], [3000, 0], [-11338, 0], [3258, 0], [0, -1163], [6695, 0], [0, 16368], [-16380, 0], [0, -13786], [11832, 0], [0, 3008], [0, -4434], [7410, 0], [0, 8671], [19368, 0], [-8875, 0], [0, -10452], [19770, 0], [-11238, 0], [0, -7447], [-17623, 0], [0, 10096], [0, 14514], [0, -10242], [6750, 0], [-17117, 0], [0, -301], [0, 15456], [0, 9492], [1500, 0], [14627, 0], [0, -16184], [0, 18502], [0, -13896], [-9895, 0], [-467, 0], [30612, 0], [0, -1852], [0, 21156], [0, 9702], [1980, 0], [-20158, 0], [0, 16882], [0, 20934], [0, -8712], [14128, 0], [-28278, 0], [-8885, 0], [-7530, 0], [0, 1801], [0, 7882], [33860, 0], [0, -20652], [-7472, 0], [0, -32251], [16812, 0], [34645, 0], [0, 8412], [0, -18329], [0, 16044], [24000, 0], [-5117, 0], [13542, 0], [0, 1283], [0, -16344], [790, 0], [-9990, 0], [0, -24743], [0, -23556], [-34000, 0], [0, -37032], [0, 2519], [43992, 0], [0, -19177], [0, -44994], [0, 52396], [-7242, 0], [4085, 0], [3030, 0], [0, 5759], [-258, 0], [0, -1374], [0, -9288], [0, 21616], [19098, 0], [0, -18246], [0, -38772], [23053, 0], [0, -10366], [-5045, 0], [0, -30738], [42930, 0], [-1873, 0], [-13242, 0], [0, -28133], [-1615, 0], [-15480, 0], [43843, 0], [-56118, 0], [0, 6503], [39625, 0], [0, -34019], [19608, 0], [0, -12293], [0, -2166], [0, -41322], [-37470, 0], [0, 33149], [0, -70147], [-4565, 0], [-22002, 0], [0, -61193], [0, -6012], [-23507, 0], [-57438, 0], [0, -39594], [0, 5442], [25022, 0], [0, 76642], [0, 6594], [0, 46878], [2700, 0], [-10172, 0], [0, 73154], [-20450, 0], [-1020, 0], [0, -37026], [-39535, 0], [0, 52338], [39180, 0], [-17747, 0], [0, 5219], [-12558, 0], [0, -15757], [0, -47004], [-25410, 0], [26462, 0], [0, -15239], [17622, 0], [0, 35076], [0, -60378], [-36583, 0], [14165, 0], [3150, 0], [0, -13912], [0, -65364], [-86495, 0], [0, 5922], [-84690, 0], [0, -96929], [67398, 0], [0, -80513], [82460, 0], [-20477, 0], [-56058, 0], [0, 106508], [0, -39624], [31750, 0], [0, 20712], [-5130, 0], [-98832, 0], [0, 7818], [5533, 0], [0, 107753], [68965, 0], [0, 22602], [57690, 0], [0, 46051], [32958, 0], [-28525, 0], [0, 58338], [0, 38414], [-93498, 0], [0, -11964], [95875, 0], [0, 79962], [54540, 0], [55697, 0], [0, 88396], [0, -76776], [0, 16814], [0, 89363], [0, -67014], [-36830, 0], [0, -68543], [0, -111366], [-67840, 0], [-94170, 0], [-100368, 0], [0, -29932], [0, 17622], [86327, 0], [0, -17984], [0, 137302], [-142405, 0], [0, -5431], [0, -135157], [0, 64086], [-46175, 0], [-98113, 0], [8088, 0], [0, -121332], [90808, 0], [0, -34914], [26147, 0], [0, -101729], [-120462, 0], [0, 94927], [0, 35124], [63200, 0], [49980, 0], [-152718, 0], [0, -51204], [0, 42012], [61968, 0], [0, -72323], [2940, 0], [61873, 0], [0, -59388], [-133710, 0], [0, -58844], [0, -20198], [0, -65436], [24635, 0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1200_f_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1200_4_f_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_1200_4_f_c(:prec:=2)
    chi := MakeCharacter_1200_f();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    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_1200_4_f_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_1200_4_f_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1200_f();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<7,R![1, 0, 1]>,<11,R![42, 1]>],Snew);
    return Vf;
end function;