
// Make newform 64.12.a.d in Magma, downloaded from the LMFDB on 22 April 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_64_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_64_12_a_d();".
// 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_64_12_a_d();".
// 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_64_a();"
function MakeCharacter_64_a()
    N := 64;
    order := 1;
    char_gens := [63, 5];
    v := [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_64_a_Hecke( : Kf := Kf)
    return MakeCharacter_64_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 := 12;
    raw_aps := [[0], [0], [12938], [0], [0], [-2631822], [-5059294], [0], [0], [-111071390], [0], [-818241334], [620972890], [0], [0], [6069399322], [0], [-12898038110], [0], [0], [-25532351862], [0], [0], [14555415610], [-18892108206], [-187917410998], [0], [0], [-20686041294], [391153985362], [0], [0], [867810924794], [0], [755219223514], [0], [-1681870191166], [0], [0], [-440806069678], [0], [-5115543859782], [0], [-3398579272718], [-5883523979254], [0], [0], [0], [0], [-2144086975830], [20482052784362], [0], [24293765691330], [0], [-22787375525374], [0], [27641307885074], [0], [-82889466246], [11101208360890], [0], [20614753347178], [0], [0], [-36012802569718], [98445597322754], [0], [96185061773874], [0], [-31045004687390], [25858188295138], [0], [0], [-224923075114598], [0], [0], [318753524948266], [383249133619666], [-216891030443998], [461883966497706], [0], [214462070028330], [0], [562421013305218], [0], [0], [-411999784745486], [-408323272308294], [-517220843627438], [0], [0], [0], [0], [0], [0], [0], [-973371258215390], [-1196962246537222], [0], [377942535293442], [0], [-1932112259766254], [0], [-161937104423926], [0], [-1358725887801214], [0], [3062225044337138], [0], [-2968591491975110], [0], [-3819025474650902], [-686490252300374], [0], [0], [-950868262185550], [0], [0], [2432122704084242], [0], [-5529496701240550], [-3909891780860782], [-3037048309711414], [0], [0], [-7782840723030110], [2814231927256170], [0], [0], [-7872472694787678], [0], [0], [0], [6845420592697914], [12334501010079562], [3114015464208050], [-12515268717430742], [0], [-17293216050977086], [-18357245297780390], [0], [16783601419919450], [0], [0], [16339911129945954], [0], [-13775857167224902], [1705879876370794], [0], [0], [-19163183326753166], [31499530306754450], [0], [0], [0], [0], [0], [809734033344146], [39057384727327786], [-39482247239747342], [0], [48417993562354442], [0], [0], [-8824040779170206], [0], [0], [31568496062317834], [-50922659806048830], [34968682318379258], [0], [-46981889022532222], [0], [64752323328524298], [0], [-81540717326072390], [0], [83912689365971338], [0], [89196537443061074], [0], [0], [81110899373045322], [77900937352284874], [0], [-9398619830126950], [-107921198319852414], [0], [-91867589678483046], [0], [-119720874384232638], [0], [0], [-157809520557534110], [0], [149010705617092202], [-92132627978925550], [-59824253945401758], [-93961962877352126], [0], [-159095754393160270], [0], [-59255565921016326], [-213561739506772830], [0], [-71798822230835326], [0], [0], [200316854075830730], [0], [-79506529650399454], [-226406362354200550], [0], [0], [0], [-292005776859411110], [0], [-344482843308885662], [0], [299650462225702178], [-369575668405187670], [0], [-411353578367951950], [0], [0], [356157978430809146], [-318977366363481862], [0], [0], [0], [376296198980484018], [0], [0], [-2286372283586230], [0], [0], [541337413264721634], [520349929215227482], [0], [0], [0], [0], [0], [-344352040573048270], [385414295294845298], [0], [0], [0], [0], [0], [162460121363477826], [-228527815014575998], [0], [634583575380653706], [408321028987470482], [0], [836753866896004122], [0], [-167542024515780086], [-822058483537366454], [0], [0], [-886928312458999830], [303278890689480098], [556934549187090706], [0], [-1198008529623952270], [236035459952674778], [0], [1296725040806575018], [-1102447542092219342], [0], [1371751115893502202], [0], [622619033196292626], [0], [0], [-1495101909754919390], [-1522193721538034230], [0], [0], [0], [0], [1095519130369019338], [0], [0], [227417114084393442], [-1792528519540941254], [0], [2002378736101943266], [-1591562024464649230], [0], [980010315617722138], [0], [378748498046054162], [2009149949388627586], [0], [-775001493242670982], [0], [0], [2776815759172220218], [-2828193635157285326], [0], [0], [0], [-2389660655828808366], [0], [2735552164574057490], [0], [2928847492970615338], [0], [-405272018738366950], [983640097595812882], [0], [0], [-1296505216955559510], [0], [0], [-2237931800331156798], [-2085673064877539854], [0], [-3803774921769553046], [-3866444836511982110], [0], [2856720955780588058], [-1994089278019940670], [0], [0], [0], [-4457237408378470678], [-5014976934600954990], [2813150258210164994], [0], [0], [0], [0], [2016766588776097826], [1619753907477579362], [-4813477156119051990], [0], [-4235033579711462662], [-5970125774294910134], [4230903146374612394], [0], [-3139769095061551742], [0], [-2177401951671443670], [0], [0], [7047669210363054586], [0], [7271779153276615866], [4375517941941678770], [0], [2801603229382353050], [79171695366130298], [0], [0], [5067160193277801794], [0], [1939136732886473834], [-4956210573431132342], [0], [0], [0], [-2117155371944259478], [-8535529221695712494], [0], [8259525438773217770], [0], [0], [0], [10856843165912271514], [0], [11054739728248141506], [0], [0], [6766572815909146978], [3494058655412923394], [-8184520083110233206], [8720827722116683778], [-12958811586080831942], [0], [-12914196532434652126], [0], [0], [0], [471496919099252826], [0], [0], [-14067237320449074366], [-1516079382809468758], [0], [0], [0], [9068739398072958378], [0], [-13752559063518356390], [0], [11701849947053039450], [-15047544774969188414], [16513448502825179122], [0], [-2203737762161513366], [7969121591380940266], [0], [17764984318522076754], [-7931796010903379902], [0], [0], [-19027708031816955022], [4621333428778128826], [0], [0], [19933232512623152874], [-15446519849503571438], [0], [0], [9914415862227297634], [0], [-10387745482686879806], [-4614478681472679094], [0], [0], [-18786138101973571718], [2349619784474370994], [0], [-23555656166185831174], [0], [0]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_64_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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