
// Make newform 30.12.a.c in Magma, downloaded from the LMFDB on 17 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_30_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_30_12_a_c();".
// 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_30_12_a_c();".
// 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_30_a();"
function MakeCharacter_30_a()
    N := 30;
    order := 1;
    char_gens := [11, 7];
    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_30_a_Hecke( : Kf := Kf)
    return MakeCharacter_30_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 := [[-32], [243], [3125], [56672], [200100], [6686], [-8416758], [-832396], [33264000], [134920806], [238950008], [473431814], [-1183674006], [375190628], [1557840600], [-1695249858], [-2239457100], [6910588790], [7738201772], [-24442024200], [-14914113814], [27081567992], [27364114716], [11710977882], [93415768514], [-127677321282], [163966814528], [-28186788684], [-283049083690], [-276671152374], [-103525147960], [-723200096100], [704329683042], [-678429718996], [774452718606], [657471295808], [979952710814], [-2116641021172], [2207879754000], [871732170774], [-449315300724], [1381152098414], [-3630865345824], [-6062296444846], [5749037446158], [-4010026790608], [-11979429913180], [-11730937384840], [-4296745140084], [9048714892910], [-1672295094174], [-3229952646624], [6320823848402], [-5289680842524], [-23198562169926], [-27960200383200], [20445288438006], [-37750987324216], [-47287345408186], [-20042943346182], [-13694909253004], [56636833440942], [-5378091563860], [15637425389400], [43847552276186], [-58771630679274], [58788095060972], [121587759948482], [24712277226084], [114967831091510], [-7786252550742], [122556500642424], [104841638625704], [-74917138453882], [8660790032204], [-205745077603800], [-32733151168194], [-88050916501954], [-3424301466606], [269327871657674], [75788830052700], [-446351061539410], [315074842815600], [-23570254898782], [-299170885818208], [-606375299575884], [-613003057889694], [682093661809082], [283579545674070], [796377711005528], [897649307322348], [-12653965390176], [726700783749104], [644548696670724], [-458182179528796], [-141509689933968], [-1443699475187994], [1210589441413818], [-37719135476140], [-1709843531595610], [888025118605004], [619146827513526], [2469497980128684], [2251014930359082], [-1729339300898980], [-649299243631486], [-58310060494284], [558476237444490], [3528950164124424], [-766880023399222], [-2213839514304328], [2268964456172486], [-1891346655164190], [-2331163767024244], [-670115580560368], [-1181452796007630], [-1523871036347572], [1764359617525968], [3389493688377174], [-1305928874075748], [5248898839587614], [3127118700584018], [-4738383956935842], [-2345577972295116], [-2110678255712956], [-3335572657005306], [5213578920231662], [85845352048800], [-10086913494721696], [-1119197140924546], [-10766389618075948], [-357270288408432], [7684733363461160], [1047933674969414], [-708785507608182], [532147148395298], [-7430768789107794], [13101150838607372], [-3731937066760410], [-4626298134612246], [-15789123000325204], [5489179021501518], [13100841860431760], [15356866822624884], [-4457928420617338], [16247103471425976], [-6647821296855178], [21780616901383074], [8454700708064204], [16743896268494232], [6319961481595214], [18639806324052546], [8166172481017628], [-12230912031376800], [-10233909865302892], [-11309728733034048], [-7498249238641984], [30370032408395106], [-23261686234971718], [-28785938666187882], [10596697369539852], [-29029170675502542], [-35098766171267728], [12961113367599924], [-30405405555402294], [18460655432230368], [15648603526082984], [-55089043481219818], [-5673080981081902], [-48726710662687122], [-23191917784088748], [68469605455726214], [-10166303408433576], [2632124013951050], [12156707922835544], [10542808487321082], [-73990621138063252], [-20824391744969058], [-1416626797673104], [-46894940676431914], [56932273092870536], [-67766386897776852], [62643911798748950], [-21024501946224558], [19533662343910200], [17354714259102606], [-37195051283299186], [-17565839998772836], [-29217596376934726], [54961840727779776], [84117465838939154], [-42598094935265484], [2138043764371172], [43342021702052070], [-29643581864710452], [96192851087641458], [96904657468044050], [-74542056274908178], [-65500807011069990], [159209875321576368], [-152756289335705418], [13089926028010808], [92087499284660246], [178491871224183746], [48713535592036500], [-105346291075594410], [-130615259858910760], [-101352988007558916], [-147151127631933270], [-45207322460159428], [56985757993890146], [227168717922027342], [185070915954333392], [-114151914107746380], [-226189352258905752], [109016798158257626], [-58018560963951160], [302225149161257394], [-93620855356862832], [-90486126374755962], [-149443714633849810], [242342021272271840], [163894963982805330], [437784568412613464], [5946250731000684], [340262395222352558], [93037949481643458], [318988805656366800], [349433092393348640], [-37280550148232652], [-276013743866801314], [371468950790380580], [-347297110518480616], [-186355511968002582], [-451026272220695404], [452133359662731432], [-461882952154785550], [14200746127670478], [-27538481376345948], [-7429266097231848], [-226869255509192052], [571655267774289020], [34586186249568224], [55689536272564262], [150183506181545658], [429734934713865048], [81143884095229976], [58709114530830924], [-101253763846510372], [-571309117345603032], [-348849110947264354], [-19149979888336734], [-100001720415630336], [-444002576563114726], [99208579029524838], [52898461669303548], [482189063689750766], [200571090585832004], [888950129305972494], [-159824001479531686], [577782128602459160], [409614042853479516], [47151735873678158], [114058282733203118], [-11946005839913526], [574738206888834356], [-839927493196993770], [-414409347410731158], [-816583890698936668], [-771181391928197058], [291928271981470166], [-671011452576311860], [886692628675533722], [-751230977236995160], [-271242007863517918], [-447769810433289136], [1022740150383736548], [51328935731470262], [88714202150785178], [-686102337744662100], [1044916400940261096], [648504472200349760], [-628038609799751904], [1139126887740150590], [-1643884713067093228], [276626339407738224], [-468360463290018478], [-226748385549065106], [1223421695379501392], [507739360100674434], [1136587803017255670], [1864867936057863420], [225584067099807762], [-99306710368586700], [-1052006638619902882], [1177698813063833382], [-1443077396811937144], [-569035970389278594], [-935800895862903900], [-1851512074664490196], [180340181363208650], [635094508442688054], [399924616670831720], [-1744813919368548084], [-2440774791387120532], [-2639178909598758622], [1012889692395290916], [1596902294474998886], [-29477192311123848], [1254894818419968182], [111979675529781096], [2701573544526425934], [-893680757004441054], [-886242884017159204], [-1204063609756180704], [1224643440952429274], [-1663711718246447028], [1389672055672834224], [1491349599099786290], [-1734750307129142670], [843206229273196244], [3656849431019155514], [1139522787253998246], [742337147462211128], [-1862449597008008238], [846128928442981202], [1508798679240332180], [-3320893681647541708], [2834647648030377336], [-873990687260301858], [-3446052598547844538], [829135586124613062], [-2259141364010395912], [-2425029022961839620], [-4451058830212844452], [-1095007199140626348], [2372711108109900134], [-3841183936659332406], [-3930439452655436326], [-4923210619062815560], [258041244046563782], [-5215459203435117054], [-2686489991378024322], [885893532723049760], [-442874597858998026], [2711403048218045676], [-2627013930172615762], [-1769631267025790428], [556103286719646528], [-1215423061628245506], [1170881849420780420], [3499579516677982010], [-558480028990365258], [1462484997697473896], [2927549243186178686], [5591296447861930962], [-525159254850788352], [7071682857549708852], [4195618524539946138], [-4643959142580220464], [2512209607363559510], [1305338198427733242], [-5397347682134191800], [3906381801882872100], [-4759673485149453556], [-4639212803435715046], [-5039924604529811610], [5662292978355593264], [6843534020995198826], [-2838261011412153924], [-5923368205724312644], [-4186284854114853864], [6014217027082941678], [-159431110443235840], [2906980627172011646], [6787775566088226876], [-463153880402167152], [-7700655635470788478], [-2096646388448717742], [4609565009749072682], [-2807385830850619482], [12658128526802465058], [2111987454961947344], [9875453231921590506], [-661721650910973868], [-1698799297185312864], [7387424496727202408], [11588148486052163942], [-5945449617794860444], [4223585367835058232], [7135189072446285698], [-6044087101043270658], [-2535293976226776252], [-3404596259394318964], [-3675861782517989976], [5475795714642998954], [-1875614541417327832], [9521636938919906058], [-668019370963970980], [14612889467427332046], [-16205341002476758714], [-2239168647163208310], [5298526037390826104], [197697114821988978], [-15529598004361533570], [3726944976031210784], [-812544848001468082], [6074484658664340594], [552842177019042428], [11772285822875877948], [-1793967754998615214], [1092857698111657422], [-7628720712915573180], [6082279404421374644], [4651223665811725514], [1483212156652309494], [-15087294839161970304], [8924214294521147744], [17710533987980919546], [-9196965673592383872], [14223059322288946278], [-8112012918718665418], [9485562790912473864], [-454602537589058028], [13115023010539703786], [-20244146154832501146], [2723326934464789788], [-10666047371422302294], [-6081255565135259380], [-3514738968141975576]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_30_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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