
// Make newform 12.45.c.a in Magma, downloaded from the LMFDB on 02 May 2026.
// To make the character of type GrpDrchElt, type "MakeCharacter_12_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_12_c_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_12_45_c_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_12_45_c_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_12_c();"
function MakeCharacter_12_c()
    N := 12;
    order := 2;
    char_gens := [7, 5];
    v := [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_12_c_Hecke();"
function MakeCharacter_12_c_Hecke( : Kf := false)
    N := 12;
    order := 2;
    char_gens := [7, 5];
    char_values := [[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 := 45;
    raw_aps := [[0], [31381059609], [0], [7819074024260706146], [0], [6294564130330351554460466], [0], [17511138165858063839822524274], [0], [0], [-1157767379467485353331293906107966], [2805478993138795299667106559840338], [0], [-1433240112034266281487221250217231534], [0], [0], [0], [755110411182356250073429769401192617074], [-29803583442840154214481808897949096995534], [0], [-141532300960705616965868158447197879814942], [-947171232764641690811484743616839173307518], [0], [0], [-99710425432955074292005818220617859544969854], [0], [116110822147504942985899711889512690371131618], [0], [-628483208094066350206117601817551227291092046], [0], [-23720943129405353475661266765900310367853361342], [0], [0], [47953864071904546822699126349551742147076876242], [0], [1062736468517601590505529686168906149583729147554], [2376971715235987173746959292601008579303251651826], [1074995404595192790052655347656780034934889641906], [0], [0], [0], [41663771952549405170794769908301342403121110043154], [0], [-382927354061474826929316412261346587090490853010174], [0], [486093454265052846630831649898706373610895823520354], [2349899388556177579536634468179123377462323666100594], [-9175999543546345820437447244464109046517722454360894], [0], [-5208514205408741008758836649385961315227175053207726], [0], [0], [-8192640576205708166046139166863254734671573796730046], [0], [0], [0], [0], [486974865617737133919800498171419669741838852576292482], [-186210823340402624471889628031690139889342423228039534], [0], [547953127536721349595769734057696130042905830258605586], [0], [-4462397596305333965930554733870008160788589704345376014], [0], [-5048117665431516244632855326551177749122908815849851614], [0], [-53890085277608905499157700176418324216139120732026904878], [-20150454986382771913999450345650396302805563112127853374], [0], [-64847989132744687562913346507097669459057283371688579598], [0], [0], [-58335088236476793382578890752684612676730480072380990974], [-61177735680237008822498397948973429052505244694278742254], [-1019883403446272499794152379190021058204020377717961848686], [0], [0], [1635541203624246335895901404846799489288833066486905792306], [0], [-5443628597981281400038403371668414142921014782368194047326], [0], [10542734726998627837104004810200958245405296724775789158482], [0], [-10425630142412285448080422429965827487529909746803319151294], [19334254832572334067078872434112433046577262925875002932514], [0], [0], [-37680318541440420736428229879925649819145359863436111139102], [0], [-65814272778412612382765489932579722293282498518188175169662], [0], [0], [-253922451527017154437490223723389444448159141624597129412894], [0], [-383359265905612100807441172646177852640468608150875907814926], [0], [0], [0], [151304226569026879069323051493890038361491844697519307388626], [2583908910237729822630926317153743590748395806995283545879794], [1394278237016160826407310928521261654543278186338623964304818], [0], [0], [0], [-6842781817522373036632388858534278867279869897337672550241646], [10618744057411009163281756332331164668638559604578864976635906], [0], [0], [0], [23424917602189349488314467180460125167323738393814872127239074], [30448380306465319105751028073861284388050809679681623291925698], [-37466130977488974390185273608588775931940200639254083355481262], [0], [40624210715284375369748264429216311651134246765815300132015954], [-78572409099746520902503419635328752017430238185080598520527326], [0], [-79050460909342222383343277370318551909892088122186680015108302], [0], [0], [0], [98821494160615807731735135945240001997118876182723579935927442], [257719827081543974575092746464038401562678634303938140201955458], [0], [0], [532631680099907770090674097800010260105440063309109112146059762], [0], [1029328149773907490112811860898137669895900312382791913853744594], [0], [-733724942551097331772533265149483302265338483149247184761249374], [119511729550893248974901604120085338095640618493150326153659378], [2160621095451912633832504216891170409963828846974387439427563442], [0], [-37066699505740090015221347020690789841338626717439277903347198], [-4129015882150351166062138276091393989079129183663049969167264494], [0], [-100384000330828018125633048561892850422347362382630859604241406], [0], [-9383216151422500974515750555777867757111044616632654827377841294], [0], [0], [-4340494538819587455903027877994378432898472605420193769977833646], [0], [25866268748968382253965013485772768952066086015733110740753258786], [0], [-32046292100786639998320848867248165871316685967507929569760747918], [0], [30003713919835750006569259658821802418410481520205720500944157586], [0], [56974753194395015165169309106323823419815400918780977692811500562], [0], [-22131342140113504372237877370666115056396592840478104464882136654], [0], [121958691221391785858932852898107427173534256881140400966017352946], [0], [200302834836462758150940767099440741564697794459533144206119052498], [0], [62614810842197543881083280431787704158282792601001190609672901794], [0], [430335348779612556578204778393540090749356371752145491506173032546], [0], [0], [0], [-253357419555683541301305637330613831401984750487003395621499320222], [0], [0], [0], [-1430150147016988356849233226120884653952263937449681381180151477566], [1415141422190300174787388408030734026810478613575005589435192622418]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_12_c_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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