
// Make newform 1200.3.bg.q in Magma, downloaded from the LMFDB on 18 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_1200_bg();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_1200_bg_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_3_bg_q();".
// 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_3_bg_q();".
// 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 := [100, 680, 2312, -1116, 269, 0, 8, -4, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0], [2940830, 10010942, -4737945, 876904, 15150, 34598, -17905, 3096], [-838660, -6107718, 2966245, -663785, 2900, -21142, 10455, -2465], [-227650, 9748972, -5631403, 1286695, -24410, 31148, -20987, 4775], [17361370, 25503006, -29697223, 9466346, -216230, 1294, -107007, 40034], [-5575940, -40601862, 15152828, -4251625, 20500, -167078, 50772, -17425], [-3461150, 213729396, -85711093, 19259897, -140510, 737284, -305517, 71513], [-19230750, -69713302, 33775373, -8904504, 20050, -241278, 119837, -33016]];
    Rf_basisdens := [1, 1277880, 958410, 1277880, 3833640, 1277880, 3833640, 1277880];
    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_1200_bg();"
function MakeCharacter_1200_bg()
    N := 1200;
    order := 4;
    char_gens := [751, 901, 401, 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_1200_bg_Hecke();"
function MakeCharacter_1200_bg_Hecke(Kf)
    N := 1200;
    order := 4;
    char_gens := [751, 901, 401, 577];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+1)]];
    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, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, -1, 0], [-4, -3, 0, 2, 1, 0, 0, 0], [0, -3, -1, 0, 0, 0, 0, 1], [-7, 0, -7, -7, 0, 0, -1, 0], [1, -1, 8, -1, 0, 0, 1, -1], [-6, 4, 4, 1, -1, 1, 0, 2], [1, -10, 0, -10, 0, 1, 1, -1], [-12, -10, 0, 12, -2, 0, 0, 0], [7, 0, 7, -27, 0, 0, -1, 0], [-19, 3, 0, -3, 0, 0, 3, 3], [-10, 6, 12, -2, 2, -2, 0, -2], [0, 0, 0, 11, -1, -1, 4, 0], [-14, -21, 13, -1, 1, -1, 0, 1], [0, -7, -12, -7, 0, -1, 0, 0], [33, 7, 0, -3, -4, 0, -1, -1], [-28, 0, -28, 8, 2, 2, -2, 0], [30, -18, 0, 18, 0, 0, 2, 2], [29, -34, -23, -2, 2, -2, 0, -6], [-2, -16, -36, -16, 0, -2, -2, 2], [44, -6, -40, -1, 1, -1, 0, -4], [-5, -17, -48, -17, 0, -2, -5, 5], [23, 0, 23, -12, 6, 6, -6, 0], [-50, 3, 0, -6, 3, 0, -8, -8], [-37, -7, 28, 4, -4, 4, 0, 9], [-36, 0, -36, -27, 1, 1, -4, 0], [0, -22, 46, -22, 0, 6, 0, 0], [16, -19, -17, 6, -6, 6, 0, 1], [52, 0, 52, -55, 4, 4, 3, 0], [-22, -5, 0, 8, -3, 0, -6, -6], [-49, 0, -49, 27, -2, -2, -13, 0], [1, -23, -56, -23, 0, 6, 1, -1], [8, -29, -134, -29, 0, -3, 8, -8], [-55, 1, 0, -11, 10, 0, -5, -5], [81, 0, 81, 3, -6, -6, 3, 0], [-64, -48, 72, -2, 2, -2, 0, -8], [-16, 0, -16, -75, -1, -1, -14, 0], [28, 55, -19, -4, 4, -4, 0, -9], [-2, -47, -92, -47, 0, -7, -2, 2], [192, 16, 0, -22, 6, 0, 2, 2], [2, 24, 0, -22, -2, 0, 6, 6], [-31, -24, 23, 0, 0, 0, 0, 8], [-109, 0, -109, 40, 5, 5, -7, 0], [17, -27, -60, -27, 0, -14, 17, -17], [-19, 45, 0, -43, -2, 0, 11, 11], [-125, -43, 132, 2, -2, 2, 0, -7], [-60, 0, -60, -42, 2, 2, 16, 0], [-15, 5, 80, 5, 0, -2, -15, 15], [22, -29, -25, -12, 12, -12, 0, 3], [-4, 32, 32, 32, 0, -4, -4, 4], [48, -40, 0, 40, 0, 0, -16, -16], [-54, 7, 0, -16, 9, 0, -6, -6], [-143, 0, -143, 65, 6, 6, 5, 0], [-26, -8, 48, -5, 5, -5, 0, -22], [6, -51, 154, -51, 0, -3, 6, -6], [-49, 59, 0, -53, -6, 0, -19, -19], [81, 0, 81, -7, 10, 10, -19, 0], [-77, -19, 0, 35, -16, 0, 13, 13], [-126, 30, 124, -8, 8, -8, 0, 2], [126, 137, -125, 11, -11, 11, 0, -1], [-64, 0, -64, 66, 8, 8, 10, 0], [-258, 22, 0, -22, 0, 0, -14, -14], [23, -98, -25, 6, -6, 6, 0, 2], [-187, 0, -187, -23, -2, -2, -3, 0], [223, 13, 0, -21, 8, 0, 9, 9], [-41, 0, -41, 32, 4, 4, -20, 0], [124, 0, 124, 156, 4, 4, -12, 0], [3, -59, -16, -59, 0, -20, 3, -3], [-34, -123, 17, -6, 6, -6, 0, 17], [6, -12, -56, -12, 0, 6, 6, -6], [176, 0, 176, 239, -2, -2, 7, 0], [50, 57, -55, -8, 8, -8, 0, 5], [35, 67, 280, 67, 0, -6, 35, -35], [-92, 222, 68, 7, -7, 7, 0, 24], [-2, -41, -250, -41, 0, 11, -2, 2], [-121, 0, -121, -47, -2, -2, 17, 0], [12, -6, 0, -22, 28, 0, -26, -26], [-5, 195, -118, 195, 0, 22, -5, 5], [18, 95, -60, 95, 0, -17, 18, -18], [-199, 97, 0, -71, -26, 0, 23, 23], [-76, 14, 0, -4, -10, 0, 28, 28], [-105, -20, 105, -6, 6, -6, 0, 0], [23, 67, -172, 67, 0, 14, 23, -23], [200, 156, -180, -14, 14, -14, 0, -20], [8, 62, 190, 62, 0, -6, 8, -8], [217, 0, 217, -44, 4, 4, -8, 0], [180, 107, 0, -116, 9, 0, 18, 18], [319, 13, -328, -2, 2, -2, 0, 9], [-88, 0, -88, 55, -5, -5, 12, 0], [-26, 50, -40, 50, 0, 32, -26, 26], [44, 0, 44, -47, 16, 16, -9, 0], [-144, -101, 0, 82, 19, 0, -28, -28], [-1, 9, 312, 9, 0, -16, -1, 1], [12, -50, -16, -3, 3, -3, 0, 4], [-21, 32, -160, 32, 0, -19, -21, 21], [-168, -180, 0, 182, -2, 0, -10, -10], [-122, 58, 120, -10, 10, -10, 0, 2], [-414, 154, 0, -168, 14, 0, -36, -36], [132, 0, 132, -54, 12, 12, 6, 0], [147, 0, 147, 16, 9, 9, -35, 0], [-28, -252, 28, 20, -20, 20, 0, 0], [-12, -104, 94, -104, 0, 20, -12, 12], [141, 227, 0, -199, -28, 0, 19, 19], [-295, 0, -295, 42, 8, 8, -26, 0], [12, 0, 12, 11, 3, 3, -40, 0], [-136, -5, 209, -6, 6, -6, 0, -73], [0, -18, 288, -18, 0, -38, 0, 0], [-85, -65, 0, 51, 14, 0, 13, 13], [-112, 0, -112, -239, -12, -12, -5, 0], [-206, -73, 207, -14, 14, -14, 0, -1], [-263, 0, -263, 189, 40, 40, -29, 0], [-5, 83, 448, 83, 0, -14, -5, 5], [254, -84, 0, 86, -2, 0, 30, 30], [377, -55, 0, 77, -22, 0, 23, 23], [-120, -140, 88, 4, -4, 4, 0, 32], [-256, 0, -256, -169, -1, -1, -32, 0], [-108, 47, 29, -16, 16, -16, 0, 79], [-12, -395, 4, -395, 0, 15, -12, 12], [37, -133, 0, 161, -28, 0, -37, -37], [121, -82, -95, 0, 0, 0, 0, -26], [-197, 0, -197, 71, -10, -10, 39, 0], [124, 130, -72, 15, -15, 15, 0, -52], [-35, -233, 0, 209, 24, 0, 11, 11], [-219, -52, 0, 83, -31, 0, 11, 11], [39, 79, -368, 79, 0, 22, 39, -39], [54, 170, 96, 170, 0, -16, 54, -54], [172, 0, 172, -271, 0, 0, -9, 0], [-316, 115, 329, 26, -26, 26, 0, -13], [19, -111, 200, -111, 0, 12, 19, -19], [-496, -238, 516, 7, -7, 7, 0, -20], [284, 18, 0, -36, 18, 0, -32, -32], [97, 0, 97, -165, 4, 4, 13, 0], [160, -344, 0, 330, 14, 0, -14, -14], [17, -283, 376, -283, 0, -26, 17, -17], [-216, 61, 179, 4, -4, 4, 0, 37], [-112, 0, -112, -250, 4, 4, 2, 0], [13, 0, 13, -33, 8, 8, -95, 0], [47, 7, 784, 7, 0, -6, 47, -47], [-193, 195, 0, -233, 38, 0, -7, -7], [-15, -258, 0, 227, 31, 0, 31, 31], [-169, -15, 244, 6, -6, 6, 0, -75], [-176, 0, -176, -12, -28, -28, 4, 0], [-14, 152, 98, 152, 0, 30, -14, 14], [-26, -280, 336, -280, 0, 2, -26, 26], [410, 99, -401, 0, 0, 0, 0, -9], [159, 0, 159, -493, -8, -8, -3, 0], [-11, -47, -480, -47, 0, 2, -11, 11], [-122, 72, 56, -13, 13, -13, 0, 66], [-255, 0, -255, -233, -22, -22, -1, 0], [45, 229, 0, -231, 2, 0, 3, 3], [-148, -68, 176, 54, -54, 54, 0, -28], [272, 0, 272, -333, 41, 41, -2, 0], [-188, 0, -188, -136, 28, 28, 8, 0], [340, 14, 0, -44, 30, 0, 52, 52], [-56, 50, -92, 50, 0, 58, -56, 56], [2, -56, -46, -56, 0, 14, 2, -2], [-111, 0, -111, -344, 22, 22, -2, 0], [422, 223, 0, -210, -13, 0, -12, -12], [392, 0, 392, 154, 18, 18, -116, 0], [-148, 1, 47, 30, -30, 30, 0, 101], [-20, 0, -20, 331, -2, -2, 27, 0], [714, 289, 0, -276, -13, 0, -6, -6], [247, 0, 247, -207, 18, 18, 81, 0], [-688, -6, 692, -5, 5, -5, 0, -4], [-367, -123, 0, 93, 30, 0, 27, 27], [225, 0, 225, -27, -18, -18, 29, 0], [42, 186, 624, 186, 0, -36, 42, -42], [180, -751, -149, -12, 12, -12, 0, -31], [-28, 587, 356, 587, 0, 17, -28, 28], [290, -104, 0, 96, 8, 0, -48, -48], [106, -226, 0, 246, -20, 0, -34, -34], [287, -300, -191, -22, 22, -22, 0, -96], [2, 376, -276, 376, 0, 58, 2, -2], [-31, -87, -976, -87, 0, 30, -31, 31], [-895, -159, 0, 225, -66, 0, -9, -9], [-344, -295, 0, 272, 23, 0, 34, 34], [-181, -467, 184, -56, 56, -56, 0, -3], [-20, -304, -254, -304, 0, 36, -20, 20], [692, 0, 692, 259, 14, 14, 11, 0], [264, -433, 0, 466, -33, 0, 4, 4], [662, 61, -583, -8, 8, -8, 0, -79], [151, 0, 151, -25, -6, -6, -45, 0], [-936, 366, 868, 25, -25, 25, 0, 68], [-11, 406, -192, 406, 0, -3, -11, 11], [-25, 0, -25, 419, 4, 4, -59, 0], [-144, -324, 36, -30, 30, -30, 0, 108], [74, -14, -34, -14, 0, -52, 74, -74], [1100, 6, 0, -4, -2, 0, -28, -28], [469, -8, -489, -38, 38, -38, 0, 20], [276, -276, -112, -10, 10, -10, 0, -164], [-943, 177, 0, -159, -18, 0, 39, 39], [287, -16, 0, 9, 7, 0, -15, -15], [124, 0, 124, -313, -61, -61, 84, 0], [92, 521, -73, -42, 42, -42, 0, -19], [102, 226, 0, -162, -64, 0, 42, 42], [200, -417, -271, 38, -38, 38, 0, 71], [335, 0, 335, 73, -60, -60, 3, 0], [140, -30, -156, 45, -45, 45, 0, 16], [67, 274, 256, 274, 0, -13, 67, -67], [-364, -130, 0, 148, -18, 0, 32, 32], [-231, 0, -231, 141, 42, 42, -119, 0], [26, 18, -112, 18, 0, 68, 26, -26], [-26, 13, -1476, 13, 0, -19, -26, 26], [1189, 0, 1189, -22, 9, 9, 43, 0], [-22, 4, -436, 4, 0, 62, -22, 22], [-192, 128, 84, -16, 16, -16, 0, 108], [15, 135, -192, 135, 0, -54, 15, -15], [-1337, -147, 0, 147, 0, 0, 9, 9], [97, 0, 97, 136, 66, 66, -38, 0], [897, 108, 0, -97, -11, 0, 15, 15], [665, -133, -676, 36, -36, 36, 0, 11], [760, 0, 760, -92, 60, 60, -84, 0], [-96, 222, 1136, 222, 0, 58, -96, 96], [136, -28, 0, -32, 60, 0, -104, -104], [176, 0, 176, 49, 26, 26, -87, 0], [290, -20, 0, 4, 16, 0, -68, -68], [-612, 0, -612, -179, 45, 45, -48, 0], [-470, -211, 547, -17, 17, -17, 0, -77], [-321, -329, 0, 319, 10, 0, -79, -79], [53, -351, -884, -351, 0, -38, 53, -53], [-89, 301, -560, 301, 0, 36, -89, 89], [-639, 123, 560, 82, -82, 82, 0, 79], [352, 0, 352, -427, -7, -7, -84, 0], [-2, 662, -2, 662, 0, 4, -2, 2], [-28, 567, -103, 18, -18, 18, 0, 131], [32, 384, -440, 384, 0, 0, 32, -32], [-424, 0, -424, -273, 22, 22, 71, 0], [766, 301, 0, -168, -133, 0, 54, 54], [484, -671, -385, -36, 36, -36, 0, -99], [9, -503, 1096, -503, 0, 38, 9, -9], [-441, 431, 0, -501, 70, 0, -59, -59], [193, 75, 0, -119, 44, 0, 95, 95], [762, 158, -648, -2, 2, -2, 0, -114], [60, 0, 60, 15, -75, -75, 102, 0], [151, -9, 86, -9, 0, 22, 151, -151], [-570, -69, 613, 13, -13, 13, 0, -43], [-158, 419, 892, 419, 0, 83, -158, 158], [124, 364, 0, -208, -156, 0, 100, 100], [932, 124, -988, 8, -8, 8, 0, 56], [345, 551, 0, -595, 44, 0, -25, -25], [-421, -707, 420, -54, 54, -54, 0, 1], [-85, 61, -624, 61, 0, -36, -85, 85], [270, 841, -175, 8, -8, 8, 0, -95], [-18, -508, 984, -508, 0, -50, -18, 18], [-632, 0, -632, 661, 42, 42, -27, 0], [92, 91, 0, -50, -41, 0, -32, -32], [-55, 359, 632, 359, 0, 16, -55, 55], [-66, -100, 144, -111, 111, -111, 0, -78], [495, 0, 495, 1089, -42, -42, 145, 0], [384, 278, 0, -354, 76, 0, 82, 82], [-4, 0, -4, -723, 15, 15, -134, 0], [-25, 243, -598, 243, 0, -118, -25, 25], [518, -405, -635, 49, -49, 49, 0, 117], [-56, -109, -1452, -109, 0, -19, -56, 56], [580, -656, 0, 658, -2, 0, -38, -38], [1116, 0, 1116, 466, -30, -30, 164, 0], [-291, 0, -291, -170, -3, -3, 107, 0], [113, 0, 113, -414, -86, -86, -16, 0], [1285, 267, -1284, 18, -18, 18, 0, -1], [456, 0, 456, 146, 50, 50, 76, 0], [-45, 175, 224, 175, 0, 90, -45, 45], [-352, 73, 335, -58, 58, -58, 0, 17], [25, 0, 25, 167, 40, 40, 41, 0], [-151, -125, -920, -125, 0, 164, -151, 151], [73, 686, 672, 686, 0, -79, 73, -73], [-996, 356, 0, -318, -38, 0, 18, 18], [-242, -602, 256, 24, -24, 24, 0, -14], [760, -323, -821, -24, 24, -24, 0, 61], [-480, 46, 0, -34, -12, 0, -126, -126], [320, 0, 320, -26, -64, -64, 22, 0], [557, -296, -337, -14, 14, -14, 0, -220], [122, -188, 548, -188, 0, -98, 122, -122], [-591, 0, -591, -638, 24, 24, -26, 0], [1243, 753, -1244, 16, -16, 16, 0, 1], [636, 0, 636, 108, -44, -44, -100, 0], [89, -521, -1040, -521, 0, -36, 89, -89], [-736, 292, 0, -360, 68, 0, -96, -96], [-1686, 17, 0, 12, -29, 0, 10, 10], [262, 100, -316, -37, 37, -37, 0, 54], [651, -501, 0, 463, 38, 0, -63, -63], [-664, 0, -664, 515, 27, 27, 56, 0], [-904, -358, 0, 270, 88, 0, -38, -38], [-1260, 0, -1260, 620, -60, -60, -76, 0], [-1068, -194, 0, 172, 22, 0, -28, -28], [-195, -1008, 207, 30, -30, 30, 0, -12], [-693, 0, -693, -929, 22, 22, -161, 0], [-23, -583, -804, -583, 0, 70, -23, 23], [40, -446, 1090, -446, 0, 6, 40, -40], [679, -362, 0, 413, -51, 0, 41, 41], [556, 0, 556, -91, -7, -7, -28, 0], [1026, -451, -791, -16, 16, -16, 0, -235], [-1090, -5, 0, -4, 9, 0, -26, -26], [-300, 323, 145, 66, -66, 66, 0, 155], [-4, -75, 502, -75, 0, 87, -4, 4], [1292, 402, 0, -524, 122, 0, 8, 8], [-220, -11, 115, 30, -30, 30, 0, 105], [-50, 249, -1084, 249, 0, -111, -50, 50], [972, 0, 972, -92, -74, -74, 14, 0], [-939, 558, 713, 22, -22, 22, 0, 226], [573, 0, 573, 527, -4, -4, -195, 0], [79, 955, 724, 955, 0, -10, 79, -79]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1200_bg_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1200_3_bg_q();".
// 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_3_bg_q(:prec:=8)
    chi := MakeCharacter_1200_bg();
    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_1200_3_bg_q();".
// 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_3_bg_q( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1200_bg();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([<7,R![16000000, 3200000, 320000, -120000, 20900, -120, 8, -4, 1]>],Snew);
    return Vf;
end function;