
// Make newform 24.10.a.b in Magma, downloaded from the LMFDB on 25 December 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_24_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_24_10_a_b();".
// 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_24_10_a_b();".
// 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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_24_a();"
function MakeCharacter_24_a()
    N := 24;
    order := 1;
    char_gens := [7, 13, 17];
    v := [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_24_a_Hecke( : Kf := Kf)
    return MakeCharacter_24_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 := 10;
    raw_aps := [[0], [81], [-794], [-5880], [-30644], [-15314], [-575086], [-617644], [441880], [-2328642], [9588512], [9276678], [-5903766], [33593452], [21135408], [-108575594], [-127636868], [147189214], [-33157756], [-9293752], [351080074], [-126193328], [475037588], [-566133990], [-1474684318], [-643692474], [-2158338200], [854142636], [-667211378], [-2483817486], [552122752], [4451638724], [-6548565558], [-2978971956], [3491681270], [2363453336], [11838266686], [-4873561116], [-15571671384], [5649960654], [-2064729612], [8332126230], [10645199040], [10085114306], [2735162790], [16351451080], [-323788268], [-17793338912], [21670634532], [-73690688570], [41725941802], [-70377264400], [-21984284814], [-60741674692], [29921011970], [50359231240], [89818825262], [-57487677424], [47049826678], [57972261338], [31935416156], [-147197040378], [83010152052], [-256030131912], [99451224570], [-276175457826], [-156679626868], [-84258624558], [204006779292], [53648462334], [390042651746], [56631715176], [-120927014288], [635287796438], [-642559190596], [-437825678976], [757236373606], [-569443514962], [-801975919854], [-570012835494], [-458353323804], [-252732102010], [-1072476494416], [249808878130], [1314380314296], [1279217978876], [-695230418750], [-955669482742], [984272826094], [1754357002448], [1126224285972], [-1364214778912], [1054896459496], [-2427936465876], [1454534052660], [710773517304], [-398320524642], [-34446242998], [-691553748404], [887586974910], [130770847076], [-724082809778], [2258388217204], [2701242676474], [-2976122960772], [2185793417282], [3999718977676], [5596039558354], [1474757276760], [69410873626], [438347980640], [-2408822634682], [-6316699320918], [-6919997813588], [-2132584141448], [-2010439080062], [6818057823684], [2458375983752], [-6695873836626], [6823230353364], [-4688624304394], [-1718405152094], [1993282394758], [-4954615817492], [6348423982580], [6385769897310], [4512481514150], [2664829527760], [9742512030168], [6633281247614], [-1740990115804], [-13213393486616], [-5171287463952], [-10016110199722], [8632518229946], [-15859211653630], [-2966931874842], [5916068247124], [10228792278718], [-2672490006166], [4479928708972], [22328872185750], [3162769562168], [-13907206756996], [2460333323998], [13779218796360], [-3653000702026], [-8688224094438], [9895003853724], [8670184920928], [-19142777459058], [11128466511602], [-27924131419468], [31117213034360], [459823708108], [-24074689812080], [-26623400739176], [-8260679533150], [38955325590762], [26846628392910], [9077909129460], [-41553209048454], [15742279061192], [3605154739212], [11636389035858], [-41122336498728], [-10198360267040], [-17256677367098]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_24_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_24_10_a_b();".
// 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_24_10_a_b(:prec:=1)
    chi := MakeCharacter_24_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_24_10_a_b();".
// 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_24_10_a_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_24_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<5,R![794, 1]>],Snew);
    return Vf;
end function;