
// Make newform 672.4.a.o in Magma, downloaded from the LMFDB on 09 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_672_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_672_4_a_o();".
// 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_672_4_a_o();".
// 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 := [12, -28, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0], [17, 7, -1], [-19, 1, 1]];
    Rf_basisdens := [1, 1, 1];
    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_672_a();"
function MakeCharacter_672_a()
    N := 672;
    order := 1;
    char_gens := [127, 421, 449, 577];
    v := [1, 1, 1, 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;

function MakeCharacter_672_a_Hecke( : Kf := Kf)
    return MakeCharacter_672_a();
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], [-3, 0, -1], [7, 0, 0], [-1, 1, 2], [-16, -1, -1], [9, -1, 4], [-48, -1, 5], [-17, -5, 0], [98, 5, -1], [24, 7, 1], [8, -3, -11], [127, -5, 14], [-264, 0, 8], [-82, 0, -2], [0, -11, 21], [-494, -4, -14], [-258, 5, -41], [-422, 0, -6], [-63, 25, 4], [-384, -20, 2], [-278, 8, -14], [-520, 10, -14], [-53, 5, -24], [-36, 24, -46], [-241, 20, 69], [-140, 5, -49], [-421, 5, 50], [-786, 20, 68], [114, -6, -106], [-94, -30, 40], [180, -8, 48], [2016, -14, -4], [-1572, 10, 46], [312, 25, 89], [-1032, 22, -46], [-1598, 27, 77], [-114, -80, -42], [-1470, 20, 78], [-37, 32, -171], [593, -9, -130], [-2380, 5, -11], [1793, 45, -64], [1360, -67, 137], [172, -35, -151], [-852, -16, -228], [2500, 2, -102], [60, -30, 34], [3870, 20, 22], [-412, -5, 143], [2684, 6, -28], [-209, -49, -244], [-420, -30, -40], [-298, -34, 108], [3843, -31, 12], [-133, 55, 40], [-4259, 20, 107], [4380, -57, -3], [660, -3, -7], [-1504, -160, -18], [-1104, -155, 271], [99, 142, 191], [-1564, 145, -425], [-3466, 32, -354], [-5670, 76, 124], [-2256, -49, 67], [884, 38, -130], [-1634, 40, 292], [253, -25, -446], [-7986, -35, 55], [-3495, -85, 80], [-1075, -187, -308], [3464, 80, 0], [-1370, 112, -32], [3436, 50, 42], [3072, 140, -372], [6450, -155, -265], [4410, -189, 509], [5988, -150, -320], [-8540, 90, -240], [450, -330, 160], [3876, 25, -3], [-4183, 17, -228], [-4554, -4, -144], [4992, 118, -174], [-5147, -205, -298], [-1666, 340, 248], [274, -192, 200], [2547, 150, 423], [-3346, 110, 464], [-3998, 130, 652], [-6598, -130, -36], [-4132, -270, -342], [4833, 243, -302], [-6916, 156, -88], [-3236, 330, 754], [8601, -90, -555], [-10883, -245, -300], [-6580, -280, 504], [124, 125, -1223], [-5286, -690, -60], [10868, 189, -23], [3166, -300, -434], [-2028, 480, -526], [-3298, 194, 340], [-4530, 504, -204], [8610, 480, -138], [-2955, -111, 6], [-10531, -99, -308], [-11674, 420, 1192], [2872, 250, -394], [17846, -58, -30], [-16524, 232, -310], [1792, -94, -622], [-10510, 86, -916], [14528, 180, 306], [-2120, 475, 9], [-7810, 220, -878], [-7006, -327, 795], [6231, -415, -1478], [5402, -125, 1709], [-7580, 471, 179], [13355, 232, -667], [7281, -545, 278], [-5504, 160, -1388], [-802, 725, -309], [15998, -460, -1156], [-1892, -20, -424], [23332, -315, -833], [4880, -337, 7], [2334, 112, 1206], [-19259, 245, -124], [-14128, -764, -132], [12310, -268, -172], [7867, -15, -860], [4966, -380, -520], [-11821, 364, 1009], [-11096, -470, 210], [-8237, 260, 281], [-1050, -350, 1338], [5680, -788, 568], [5028, -495, 2141], [-3186, 380, -1678], [10903, -395, 2254], [6772, 625, -71], [21270, 214, 736], [3590, 521, -261], [-7765, 269, 1576], [20084, 83, 845], [9599, -165, -8], [5702, 382, -78], [21337, 1105, -246], [17796, 780, -544], [1858, -220, 974], [13944, 120, -1064], [-23207, 265, 996], [19020, 154, -1414], [-61, -285, -862], [-11810, -1022, 1042], [-23839, -230, -319], [1911, 45, -1170], [-17198, -468, -788], [-5022, -950, 368], [-8740, -382, -98], [37408, 90, -564], [-9196, -950, 1474], [-5212, 1126, 1110], [14834, -173, 1381], [31756, -305, -301], [13043, 730, -229], [29015, 733, -698], [-23446, -1065, -391], [12485, 705, -1440], [6724, 533, -275], [-4820, 236, 864], [-4659, -335, -90], [29546, -154, 116], [-14978, -1035, -1325], [14224, -525, 3317], [-17358, 455, 1929], [2870, -80, 3102], [-29312, -740, -224], [5948, 1089, 1237], [-3847, -483, -26], [3635, -1305, -136], [-27945, 630, -1373], [-4598, 30, 1534], [-3444, 1220, 396], [4412, -175, 649], [-13184, -666, 1378], [-14036, -1774, 832], [-2953, -1375, 2290], [-30448, 262, 882], [-32333, 910, -161], [16083, 745, 2038], [6989, 897, -154], [17228, -1205, -2169], [-12996, -723, -319], [-2965, -1085, -750], [-29614, 700, -1602], [45540, 315, -1653], [-16404, 1270, 742], [-33136, -1639, 997], [116, 660, -2026], [-35704, 144, 2268], [-34473, -1242, 531], [69612, -350, -6], [-22497, -1195, 510], [-1526, 510, 50], [6524, -1269, -1523], [24906, 400, 312], [25661, -410, -983], [-25132, 110, -618], [-73836, 400, 680], [-14018, 674, -2300], [31422, 490, 914], [-46628, 650, 922], [35585, -1275, -1866], [347, 55, -4408], [44626, -1171, 1703], [2734, 1020, -1852], [9004, -235, 223], [-2510, 680, 968], [-28744, 100, -3292], [-31500, 1490, -938], [-13824, -675, 1597], [1127, -381, 2870], [46763, -693, 1004], [40540, -245, 2377], [-29735, 1143, -1618], [-14634, -136, -2952], [1068, -1147, 3843], [-55212, 298, 2178], [-9122, 740, -544], [-21508, 725, 3323], [1464, -860, 1236], [3628, 1940, -1434], [-600, -103, -2807], [-22047, 463, 1958], [-40772, -1438, -1686], [-13999, -1065, -1162], [15808, -1652, 3528], [-60140, 1250, 74], [-51324, -2395, 985], [40783, -1015, 4176], [32714, -618, 4116], [7400, -1125, 1413], [56382, -1396, 2590], [15038, 694, 992], [-4573, 1315, 2820], [-36006, 674, -5366], [-13939, 1185, 2398], [7313, 585, 1268], [-45960, -1020, 1890], [40747, 2592, 1197], [9647, -1083, 3062], [-77468, 345, 613], [-49940, -685, -747], [14783, 1866, 2015], [-17938, -606, -470], [-51638, -440, 1738], [16861, 715, -2946], [33932, 2315, 511], [54022, -735, 4419], [60529, -423, -494], [50288, -958, -3926], [28344, -1815, -2975], [-41379, 495, -1432], [64778, -130, 2252], [38718, -779, 1715], [-29674, 1815, -2667], [-63304, 1630, 2330], [-9984, 4, 4938], [3492, -236, -5440], [58800, -1174, -4356], [77020, -335, -141], [-53497, -2695, -1406], [-45732, 1105, 3813], [-6848, 1465, 4229], [12662, 3628, 1926], [15324, 3730, -1558], [-78550, -178, 3068], [45268, -30, -1782], [-47406, -1025, 4217], [96020, -1480, -2528], [52401, -1067, 2864], [-17630, 368, 4912], [64120, -521, -5269], [3876, -1525, -4903], [-17093, 1025, -2316], [-53284, 1155, -1573], [42740, -40, -1728], [88764, 132, -2394], [-24914, 852, 4230], [21110, -2040, -7360], [106595, -360, 725], [53580, 1624, 876], [33233, -1396, -273], [-35026, 880, 2578], [28020, -2830, 4638], [-66110, 882, 3438], [634, 1995, -2607], [86206, 1102, 2000], [-25101, -1655, 1182], [46798, 2330, -1284], [-19042, 788, -232], [61869, -1285, 2206], [60684, -1465, -1349], [10197, -1419, 6468], [13388, -1827, 5073], [300, -490, 934], [-10950, 3335, 4157], [-104792, -760, -1130], [-50252, -3060, -1960], [-55925, 155, -892], [-3728, 940, 1106], [79248, -1606, -638], [55311, 1075, -2928], [-43472, 1992, -1266], [8688, -1180, -2654], [15472, -1111, -2845], [4020, -2617, 1787], [76947, -1330, -2601], [-68748, 790, 5190], [-93686, -296, 4824], [-87024, -410, -488], [-86926, 2056, -8318], [38672, -1545, -9475], [44721, -155, -96], [88806, 2187, 1045], [-56958, 130, -2126], [-26326, -2803, -289], [92644, -1741, 769], [-29790, -1410, -2344], [-24286, 524, 10054], [-57990, -2510, -348], [21214, 1330, -4362], [-60829, 2537, 340], [27716, -1620, 5862], [87700, 815, 3653], [-110074, 1908, 5964], [-32840, 3272, 2238], [34097, -1180, 2119], [-8676, -3328, 596], [-95190, 1999, 1741], [-25621, -1063, 486], [-9720, 1705, 965], [-56432, -4860, 924], [-97796, -2492, -1480], [-57441, 2528, 3945], [33836, 3479, -2527], [-19724, -2193, 7475], [90292, 4275, -1261], [-115956, 1850, 3874], [-102626, -1140, 1900], [-6243, -3367, 7246], [33876, -2340, -3168], [-97868, 954, -50], [121202, -774, -5882], [-143043, 985, -5112], [-4378, -3760, 3824], [-45173, 2375, 8150], [64601, 485, -5576], [14151, -623, 9090], [-141496, 1520, -2900], [39164, 2723, -7225], [-36559, -3540, 2807], [-2182, 2760, 6042], [59448, -3155, -11639], [-100495, -325, 3930], [68404, 1049, -6441], [-44787, 705, 1032], [2264, -3655, -3447], [-68468, 91, 313], [61844, 2693, 1225], [139388, 4532, -996], [-89981, -149, -2828], [-570, -1928, -1572], [37013, -1995, 506], [207920, -360, 1550], [-118313, 1920, 3025], [34750, -4982, 3242], [155564, 2660, -80], [-146618, 820, -1056], [128988, -992, 2248], [-101032, -2770, 1690], [-98792, 2510, -4894], [36552, -3693, -1613], [-100054, -1130, -5052], [-66430, 390, -4308], [-54564, -2295, 9097], [-35475, 2252, 6083], [95707, -1939, 7178], [-29852, -935, -10201], [40393, 4521, 6740], [96078, -1104, 3060], [-11572, -2412, 9688], [-38251, 2985, -4594], [-103558, -1250, -4036], [-43570, 1185, 9415], [-19346, -405, 9153], [-96982, -2818, 5514], [-14598, 5390, 1356], [41743, -2097, -1862], [-101011, 2480, 4183], [49224, -4860, -1772], [-14404, 3369, -5907], [11858, 2710, -4998], [-91380, -2150, -6754], [60762, 3286, 4408], [9610, -5990, 830], [-205574, 957, -1545], [-93723, -2125, -5522], [30192, 5896, 3728], [52436, -1119, -2159], [-106967, -5220, -1585], [119771, -2673, 3360], [32608, -2015, -10961], [9681, 1813, 6534], [-162762, -3770, -2840], [-55574, 4915, -7063], [63178, 3057, -2401], [74221, -455, -6256], [-39076, 2852, -11484], [-66798, 1058, -1714], [-207209, 794, -1697], [103489, -3445, 6962], [90624, 6530, -1332], [-57068, -704, 10688], [21018, 2088, -1662]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_672_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_672_4_a_o();".
// 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_672_4_a_o(:prec:=3)
    chi := MakeCharacter_672_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 4));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(2999) - 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_672_4_a_o();".
// 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_672_4_a_o( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_672_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,4,sign)));
    Vf := Kernel([<5,R![-1400, -300, 10, 1]>,<11,R![-45280, -2840, 0, 1]>],Snew);
    return Vf;
end function;