
// Make newform 105.3.h.a in Magma, downloaded from the LMFDB on 22 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_105_h();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_105_h_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_105_3_h_a();".
// 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_105_3_h_a();".
// 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 := [441, -1638, 4950, -5472, 5613, -1074, 1704, -372, 295, -26, 21, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2151653525805, -1028895680526, 2969181679896, 8663666606754, 1781364901824, 1552126862414, 213549867516, 315532034086, 16671982336, 20630949354, 179172244, 1163071964], [-326284936204626, 400451804827326, -600344866337340, -20039696712579, -189561780832470, 6962573059314, -30803759234464, -2869803299632, -2190651066536, -170812742885, -93424675980, -19075972200], [8249891025873, -41728255959096, 34182728232798, -45731806099632, 6857417738770, -13556067558780, 2597271123866, -2326556207056, 182952067062, -164611608580, 14497160068, -7830116016], [-10342332760284, 4393836770841, -12643415740656, -27659028800376, -7155359090394, -7205061506889, -348399189483, -1489720495401, -27516350446, -102990651177, 2605315656, -5593516534], [-794649726, 335831265, -966776562, -2082413232, -552012621, -544174569, -32874720, -112253475, -2597287, -7746906, 161001, -420436], [286407973908, -1506759017400, 927729741900, -1426181986128, 157533404673, -408590656806, 69330420871, -69652827574, 4884356215, -4898355887, 404122997, -233300876], [86851646987175, -442224670054734, 346171354438782, -472028460969018, 65772299304051, -139385258261016, 25973059454509, -23655237895132, 1834614270589, -1671226017089, 146272115177, -79026253784], [4306806, -18996579, 29629158, -30382920, 5419563, -9463719, 2055140, -1697439, 142983, -121362, 11357, -5888], [-2470563074763, 45520828453800, -57941854444554, 55017188023641, -11089514438346, 17185537551444, -4036087599626, 3036253477328, -281471772670, 217694819151, -21796565040, 10465136770], [-6309118974753, 16532688498102, -19858677257310, 25482799710645, -2916220839078, 7600600799214, -1347840842486, 1370545304570, -92976169234, 97232846541, -7993408932, 4771832146], [-46611711121164, 205290382805907, -321597481405422, 328824523408572, -57601814034902, 102461242347749, -22137707421633, 18330600604705, -1539020770436, 1310387571065, -122784179216, 63482984056]];
    Rf_basisdens := [1, 5604734688861, 16814204066583, 5604734688861, 2402029152369, 133884909, 66459304611, 16814204066583, 1130283, 1528564006053, 579800140227, 5604734688861];
    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_105_h();"
function MakeCharacter_105_h()
    N := 105;
    order := 2;
    char_gens := [71, 22, 31];
    v := [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_105_h_Hecke();"
function MakeCharacter_105_h_Hecke( : Kf := false)
    N := 105;
    order := 2;
    char_gens := [71, 22, 31];
    char_values := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 1, 0, 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, 1, 0, 0, 0], [-1, 0, 0, 1, 0, 0, 0, 0, -1, 1, 0, 0], [-1, -1, 2, -1, -2, 0, 0, 1, -1, 0, 0, -1], [0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 1, 2], [0, 0, 0, 1, 0, 0, -1, 1, -2, 1, 1, 2], [0, 0, 0, -6, 0, 0, 1, 2, -1, 2, 2, 1], [-3, -3, 0, 0, 0, 2, 0, 0, 0, -2, 2, 0], [5, 5, 0, 0, -2, -2, 0, 0, 0, 2, -2, 0], [0, 0, 0, 2, 0, 0, 0, 0, 10, -2, -2, 2], [5, -5, -4, 2, 2, 4, 0, -2, 2, -2, 2, 2], [0, 0, 0, -21, 0, 0, 0, -3, -3, 0, 0, -5], [13, 3, 4, -2, 6, 0, 0, 2, -2, 3, -3, -2], [0, 0, 0, -11, 0, 0, -7, 1, -2, 1, 1, -4], [15, -9, 0, 0, -12, -6, 0, 0, 0, -2, 2, 0], [0, 0, 0, -11, 0, 0, 2, 7, 7, 4, 4, -5], [0, 0, 0, 22, 0, 0, 9, 0, -1, 2, 2, 1], [17, -9, 4, -2, -6, -12, 0, 2, -2, -1, 1, -2], [2, -4, 2, -1, 4, -2, 0, 1, -1, 6, -6, -1], [0, 0, 0, 16, 0, 0, -2, -10, 14, 2, 2, -6], [12, 10, 4, -2, 20, -8, 0, 2, -2, 4, -4, -2], [0, 0, 0, -12, 0, 0, 0, -12, 8, -4, -4, 0], [0, 0, 0, -5, 0, 0, -4, 1, -31, -4, -4, 7], [0, 0, 0, 14, 0, 0, 6, 0, -4, -10, -10, 4], [0, 0, 0, 20, 0, 0, 4, 8, -6, -6, -6, -8], [0, 0, 0, -4, 0, 0, 0, -6, 20, 5, 5, -2], [29, 17, 4, -2, 0, -6, 0, 2, -2, 2, -2, -2], [-42, -4, -8, 4, -24, 12, 0, -4, 4, 2, -2, 4], [-41, 19, -8, 4, -4, 6, 0, -4, 4, -4, 4, 4], [-8, 2, -8, 4, -16, 4, 0, -4, 4, -1, 1, 4], [0, 0, 0, -7, 0, 0, 10, -13, 7, -2, -2, 15], [15, 3, 8, -4, -20, 14, 0, 4, -4, -8, 8, -4], [0, 0, 0, 56, 0, 0, -9, 12, -17, 4, 4, -3], [-63, 9, -12, 6, 10, -30, 0, -6, 6, 6, -6, 6], [66, -16, 12, -6, 8, 4, 0, 6, -6, -8, 8, -6], [0, 0, 0, -44, 0, 0, 18, 0, -42, 3, 3, 24], [-41, -7, -4, 2, -10, -20, 0, -2, 2, 7, -7, 2], [0, 0, 0, -19, 0, 0, 7, 5, 0, 9, 9, 10], [0, 0, 0, 26, 0, 0, -8, -22, -36, -6, -6, -10], [41, 5, -6, 3, -2, -4, 0, -3, 3, -4, 4, 3], [0, 0, 0, 2, 0, 0, 13, -16, 11, 8, 8, -3], [44, -22, 18, -9, 4, -22, 0, 9, -9, 2, -2, -9], [-58, 4, -24, 12, 44, 4, 0, -12, 12, -6, 6, 12], [-19, 17, 12, -6, 24, 10, 0, 6, -6, 12, -12, -6], [0, 0, 0, -38, 0, 0, 8, -20, -2, 22, 22, -22], [-32, 30, 16, -8, 20, 52, 0, 8, -8, 10, -10, -8], [0, 0, 0, -96, 0, 0, -2, -10, 10, -5, -5, 24], [0, 0, 0, 14, 0, 0, 4, 2, -38, 4, 4, 30], [0, 0, 0, 50, 0, 0, 11, -20, 33, 18, 18, 11], [-105, 3, 4, -2, 8, -46, 0, 2, -2, -8, 8, -2], [142, -8, 14, -7, 0, 42, 0, 7, -7, 6, -6, -7], [0, 0, 0, 50, 0, 0, -2, 2, -44, 16, 16, -4], [0, 0, 0, 27, 0, 0, 30, 9, -67, 2, 2, -35], [0, 0, 0, 71, 0, 0, 19, -13, -28, -7, -7, -12], [99, -9, 4, -2, 40, -6, 0, 2, -2, 2, -2, -2], [0, 0, 0, -110, 0, 0, 8, 10, 56, -34, -34, -22], [0, 0, 0, -126, 0, 0, -14, 20, 12, 12, 12, 12], [177, -5, -12, 6, -10, 40, 0, -6, 6, -4, 4, 6], [212, -10, -8, 4, 32, -36, 0, -4, 4, 0, 0, 4], [0, 0, 0, 36, 0, 0, -10, 4, -14, -26, -26, -34], [0, 0, 0, -14, 0, 0, 8, 10, 0, 24, 24, 50], [0, 0, 0, -104, 0, 0, -32, -4, 0, -18, -18, -24], [0, 0, 0, 44, 0, 0, -8, 32, -12, 24, 24, 36], [0, 0, 0, -4, 0, 0, 4, 26, 28, 10, 10, -32], [39, 3, 16, -8, -52, -34, 0, 8, -8, -2, 2, -8], [-146, 48, 4, -2, -64, -80, 0, 2, -2, 10, -10, -2], [-114, -16, 32, -16, -100, -20, 0, 16, -16, -16, 16, -16], [-151, -31, -32, 16, -40, -30, 0, -16, 16, 12, -12, 16], [0, 0, 0, 30, 0, 0, -25, -20, 69, 6, 6, 3], [0, 0, 0, -17, 0, 0, -1, 31, -84, 45, 45, -8], [80, -58, 10, -5, -68, -14, 0, 5, -5, -2, 2, -5], [0, 0, 0, -22, 0, 0, -44, 8, 50, -25, -25, 0], [83, 33, 28, -14, 66, -48, 0, 14, -14, 14, -14, -14], [162, 8, 32, -16, -48, 60, 0, 16, -16, -32, 32, -16], [0, 0, 0, -57, 0, 0, 21, 3, 40, 25, 25, -62], [-13, 23, -4, 2, -10, -10, 0, -2, 2, 14, -14, 2], [0, 0, 0, 32, 0, 0, 8, 28, -40, 11, 11, 54], [-6, 0, -4, 2, 32, 36, 0, -2, 2, 0, 0, 2], [0, 0, 0, -4, 0, 0, -8, -40, -72, -18, -18, 48], [0, 0, 0, 47, 0, 0, 16, 29, -25, 2, 2, -9], [-12, -74, -8, 4, 60, 24, 0, -4, 4, -30, 30, 4], [140, 50, -6, 3, -8, -46, 0, -3, 3, -10, 10, 3], [0, 0, 0, -74, 0, 0, 24, -60, 74, -4, -4, 22], [0, 0, 0, 58, 0, 0, 0, 36, -10, -22, -22, -54], [157, 13, -56, 28, -32, 50, 0, -28, 28, -12, 12, 28], [-4, -58, -24, 12, -52, -52, 0, -12, 12, -8, 8, 12], [40, -30, -24, 12, 88, 44, 0, -12, 12, -6, 6, 12], [0, 0, 0, 28, 0, 0, -22, 16, 32, -16, -16, -30], [-86, -28, 40, -20, -36, 60, 0, 20, -20, 1, -1, -20], [0, 0, 0, 102, 0, 0, -6, -66, -72, 6, 6, 48], [0, 0, 0, -150, 0, 0, 48, -6, -26, 4, 4, 42], [68, 34, 0, 0, 4, -88, 0, 0, 0, -5, 5, 0], [-73, -1, -2, 1, -126, 92, 0, -1, 1, -28, 28, 1], [-212, 54, -20, 10, 44, 64, 0, -10, 10, -8, 8, 10], [0, 0, 0, -47, 0, 0, 47, 13, -224, -5, -5, 2], [0, 0, 0, 34, 0, 0, -34, -26, 6, 18, 18, -44], [0, 0, 0, 237, 0, 0, -30, 15, 153, 6, 6, 27], [0, 0, 0, 24, 0, 0, 2, -20, -42, -30, -30, -130], [110, -48, -56, 28, -104, -40, 0, -28, 28, -14, 14, 28], [-11, 35, -60, 30, -54, -12, 0, -30, 30, -19, 19, 30], [-255, -15, 60, -30, 52, 22, 0, 30, -30, 24, -24, -30], [0, 0, 0, 148, 0, 0, -4, 16, -52, -52, -52, -4], [-190, -40, -8, 4, 16, 16, 0, -4, 4, 16, -16, 4], [-136, 18, -12, 6, -36, -108, 0, -6, 6, 24, -24, 6], [0, 0, 0, -152, 0, 0, 24, 6, -84, 12, 12, -68], [0, 0, 0, 76, 0, 0, 2, -68, 106, -62, -62, -18], [0, 0, 0, 1, 0, 0, -13, -11, -86, -11, -11, -106], [28, 82, 34, -17, -4, -22, 0, 17, -17, 62, -62, -17], [0, 0, 0, -126, 0, 0, -32, 38, 122, 26, 26, -26], [0, 0, 0, -28, 0, 0, -58, -50, -50, -41, -41, 100], [199, -115, 4, -2, 58, 128, 0, 2, -2, -6, 6, -2], [-103, -31, 48, -24, 76, -110, 0, 24, -24, -28, 28, -24], [0, 0, 0, -188, 0, 0, 43, -16, -185, 16, 16, 21], [-2, -52, -16, 8, 8, 16, 0, -8, 8, 22, -22, 8], [-94, -40, -36, 18, -28, 68, 0, -18, 18, 4, -4, 18], [0, 0, 0, 148, 0, 0, 44, 28, 200, -4, -4, 52], [0, 0, 0, -205, 0, 0, -35, 47, 300, 21, 21, -50], [-413, -65, 8, -4, 60, -18, 0, 4, -4, -30, 30, -4], [-3, 57, -50, 25, -10, 88, 0, -25, 25, 40, -40, 25], [0, 0, 0, 226, 0, 0, 3, -60, -83, 46, 46, 99], [40, 78, 8, -4, -200, -52, 0, 4, -4, -2, 2, -4], [0, 0, 0, -146, 0, 0, 8, 46, -64, 8, 8, 54], [-287, 13, 28, -14, -132, 2, 0, 14, -14, -50, 50, -14], [0, 0, 0, 114, 0, 0, -15, 54, -37, -28, -28, 101], [-413, 79, 32, -16, -54, -126, 0, 16, -16, 6, -6, -16], [18, -52, -24, 12, 112, -52, 0, -12, 12, -4, 4, 12], [0, 0, 0, -178, 0, 0, 10, 50, 36, -54, -54, 12], [0, 0, 0, -92, 0, 0, -32, 2, 148, 73, 73, -10], [0, 0, 0, -204, 0, 0, -18, -36, 94, -41, -41, -68], [-98, -64, -76, 38, -168, 84, 0, -38, 38, -66, 66, 38], [805, -35, 20, -10, 48, 54, 0, 10, -10, 0, 0, -10], [-84, 2, 40, -20, -84, 36, 0, 20, -20, -4, 4, -20], [325, -33, 20, -10, -38, -52, 0, 10, -10, 46, -46, -10], [0, 0, 0, -233, 0, 0, 26, -23, 75, 6, 6, 69], [0, 0, 0, -58, 0, 0, 28, 38, 194, 38, 38, 6], [0, 0, 0, -116, 0, 0, 56, 4, 194, 20, 20, -68], [0, 0, 0, -132, 0, 0, -34, -80, -10, 2, 2, -26], [0, 0, 0, 96, 0, 0, -6, -24, -232, -76, -76, -62], [126, 84, -56, 28, 268, 64, 0, -28, 28, -16, 16, 28], [0, 0, 0, 84, 0, 0, 37, -76, 337, 28, 28, -109], [83, 23, 12, -6, 58, -130, 0, 6, -6, 38, -38, -6], [272, -54, 16, -8, 128, -20, 0, 8, -8, -15, 15, -8], [-819, 45, 0, 0, 68, 26, 0, 0, 0, 32, -32, 0], [0, 0, 0, 14, 0, 0, -7, 64, -181, 8, 8, 5], [0, 0, 0, -296, 0, 0, 38, -20, -38, 46, 46, 82], [0, 0, 0, 316, 0, 0, -4, 40, 136, -17, -17, 94], [0, 0, 0, -85, 0, 0, 31, 35, 0, 69, 69, 92], [0, 0, 0, -176, 0, 0, 21, -36, -255, -30, -30, 51], [-143, 1, 160, -80, 0, -14, 0, 80, -80, 58, -58, -80], [179, -15, -52, 26, 82, 8, 0, -26, 26, 96, -96, 26], [0, 0, 0, 9, 0, 0, 48, -45, 87, -12, -12, -71], [-177, -7, 4, -2, -214, 16, 0, 2, -2, -15, 15, -2], [0, 0, 0, 277, 0, 0, -55, 13, 290, -25, -25, 56], [-73, 73, -36, 18, 266, 16, 0, -18, 18, -3, 3, 18], [28, 10, -66, 33, 188, 38, 0, -33, 33, -78, 78, 33], [1144, 54, -24, 12, 140, -20, 0, -12, 12, 8, -8, 12], [0, 0, 0, 345, 0, 0, 90, -57, 17, 26, 26, -9], [0, 0, 0, -42, 0, 0, -8, -76, 34, -50, -50, -94], [0, 0, 0, 274, 0, 0, -22, -110, -110, -104, -104, -88], [373, 49, -88, 44, -132, 54, 0, -44, 44, 6, -6, 44], [601, 25, -52, 26, 216, -178, 0, -26, 26, 24, -24, 26], [-242, 212, -24, 12, 148, 20, 0, -12, 12, 67, -67, 12], [0, 0, 0, -287, 0, 0, -88, 43, -247, -124, -124, -127], [-461, -209, -36, 18, -232, 122, 0, -18, 18, -72, 72, 18], [0, 0, 0, 57, 0, 0, 69, -147, 86, 41, 41, -12], [16, 6, -16, 8, 84, -36, 0, -8, 8, 26, -26, 8], [0, 0, 0, -168, 0, 0, 12, -24, -244, 23, 23, 90]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_105_h_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_105_3_h_a();".
// 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_105_3_h_a(:prec:=12)
    chi := MakeCharacter_105_h();
    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_105_3_h_a();".
// 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_105_3_h_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_105_h();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,3,sign)));
    Vf := Kernel([],Snew);
    return Vf;
end function;