
// Make newform 24.25.h.a in Magma, downloaded from the LMFDB on 08 February 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_24_h();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_24_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_24_25_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_24_25_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
        Kf := Rationals();
    end if;
    return [Kf!elt[1] : elt in input];
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_24_h();"
function MakeCharacter_24_h()
    N := 24;
    order := 2;
    char_gens := [7, 13, 17];
    v := [2, 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;

// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_24_h_Hecke();"
function MakeCharacter_24_h_Hecke( : Kf := false)
    N := 24;
    order := 2;
    char_gens := [7, 13, 17];
    char_values := [[1], [-1], [-1]];
    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 := 25;
    raw_aps := [[-4096], [-531441], [365381854], [-27475271998], [-5105521239842], [0], [0], [0], [0], [-704484700049098082], [-98824112975306878], [0], [0], [0], [0], [-853658455089505675682], [-1867887281342901440162], [0], [0], [0], [-22675930921224014736958], [-23695071070783151934718], [-58612900694776237645922], [0], [-1060863215715650415640318], [1188200263426698674527198], [2380879835628510120569282], [-1115698941223457531220002], [0], [0], [18288615907580897736627842], [44723928943157041049986078], [0], [0], [224564724275935293868111198], [-105402405763883748657412798], [0], [0], [0], [42134660982568887204598558], [1072336397715348869218741918], [0], [0], [-3814713315602219496651494398], [-6795403145512841608802030882], [7671524747176081402801041602], [0], [29527335829490530430955104642], [21038344127456006578745820958], [0], [0], [0], [-1243243143929780231265901438], [49230253189365899205126146398], [0], [0], [-33547546202575519707412669922], [87987974842210930200473114882], [0], [0], [0], [560307987704836988852307256798], [0], [0], [1591839060499373413466193053762], [-1916298771249754844776935911522], [0], [-4114944174663645751553537946238], [1621411872100998940978575527518], [0], [0], [0], [-11915698466131872091412803015678], [0], [0], [0], [23619315458058631028986216001758], [0], [0], [42026382776318270865153903869762], [-58114235301579113051954287300322], [0], [0], [-32237203230046171011085643076478], [-76734989473664804244686151744958], [-44931798759389885456520186813602], [0], [69363867642653289320382629131202], [-89167429357722965884185929679842], [-192221356872978473600014081885438], [191740496630023467122852831179678], [0], [165274534863409294590574527783362], [-375774180490241645275784657302562], [0], [0], [-39525849913470799066460961867362], [0], [0], [0], [0], [-934002196697287000812353278053602], [1881250319898088878141541039739038], [0], [0], [-2711727575957817597780723005890558], [2660647392771910860590831336329438], [0], [0], [2476739401597544177514825378388802], [560175891509071092429315349488002], [0], [0], [0], [-5565687519485003397805069379974078], [0], [0], [0], [5164319132069374008276494888524318], [-9717074618427012199802601453348962], [0], [-2217609245901131839081359157858558], [-4867962589618219705923096920324642], [17687421633991403523440286786624478], [0], [-25620108339613192226581395510856802], [0], [0], [27428942037704238252341805127544642], [0], [0], [0], [-19567939603153327659251718022886398], [0], [0], [56050752153626162536474450321297922], [70344140374481030983900690507380958], [0], [-47636954081724537439732297719830882], [0], [0], [-61004184204797112863403930952306082], [-182495403995382306287381775015898558], [70558400478311242441173011622238558], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [-208193787201702298925952942735257278], [0], [31423748831049361895769194397984962], [896928445221643867646497396982948638], [995695094754567483077636896669161118], [0], [-422685923352473021677227222078876478], [-328620006761416395130845908406715682], [0], [0], [-1769799133597213639090495424645965438], [0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_24_h_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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