
// Make newform 225.6.a.r in Magma, downloaded from the LMFDB on 13 January 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_225_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_225_6_a_r();".
// 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_225_6_a_r();".
// 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
        poly := [-36, -1, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rfbasis := [Kf.1^i : i in [0..Degree(Kf)-1]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_225_a();"
function MakeCharacter_225_a()
    N := 225;
    order := 1;
    char_gens := [101, 127];
    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_225_a_Hecke(Kf)
    return MakeCharacter_225_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 := 6;
    raw_aps := [[3, -1], [0, 0], [0, 0], [-50, 20], [-390, -20], [100, -80], [954, 32], [-916, 320], [-912, 504], [-1290, 1280], [-2692, -440], [7000, -1440], [480, -1360], [-12200, -1280], [9552, -184], [24426, 608], [-31110, -980], [-21838, -5440], [-7100, 8120], [-31860, -1480], [-46550, -4640], [-24484, 2680], [-23316, -10728], [47700, -8400], [-3650, -2880], [135510, -4320], [-33650, 7380], [114156, -10152], [-1294, -10080], [-8634, 128], [-60050, -15020], [36390, -55980], [-228570, -10560], [-152956, 20880], [66090, 65120], [259088, -19360], [-410300, 16800], [205900, 70200], [147192, -53064], [-494430, 10560], [-227430, -6740], [240338, 23040], [-461100, 42200], [383050, 60000], [99774, -21408], [-217744, 30320], [56492, -44160], [160150, -45180], [890976, 91408], [-370306, -132320], [-227430, -109440], [-608820, -34760], [-608458, 98240], [-35730, 109860], [-508602, -69216], [578568, 38344], [1334430, 22240], [-1343608, 81440], [-919400, 98720], [-914700, 218400], [-698300, -44200], [-954498, 177216], [329200, 100240], [-461940, -190920], [-843350, 207840], [-417570, 449440], [-642388, -191840], [-1623950, -255680], [777408, -147136], [-1794406, 397280], [16482, 109056], [3492360, -143520], [-703850, -222460], [2287900, 203200], [1648964, -151600], [-1515792, -550536], [2265090, -422880], [-671600, 520240], [457860, -101520], [-3642166, 486720], [183270, -404140], [384638, 787040], [228960, 311280], [3996250, -301760], [-795064, -145600], [-68856, 161952], [-5636340, -329120], [-606650, -523040], [-2044830, 94560], [2350450, 32780], [-49932, 325144], [171420, 553560], [5375050, 361500], [-3832890, -671020], [-1139284, 183680], [-6240240, 215080], [-3689250, 784000], [-1197900, -623200], [-7168700, 97240], [158042, 1414240], [2057800, 874240], [4148730, 531840], [4869672, -305424], [-1998660, 1263120], [-8206948, -496800], [10230550, 702240], [3941436, -1707912], [-1783314, -65312], [3346680, -465760], [5326358, -1727040], [4321450, -1323620], [-4305800, -973040], [7573506, 1251648], [3161156, 113520], [-6137548, -1130200], [-1519320, -941760], [-9993500, -187960], [-6960960, -1508680], [-2797986, -1093088], [-6131010, -173180], [-3554542, 1295360], [7856050, -2483200], [-3888042, -1808736], [4672332, -2853144], [-3233092, -57040], [7097670, -305440], [4936334, -2121280], [21688920, -691440], [-580550, 2367420], [16595200, 489600], [6231044, 976880], [1113360, 1663880], [-2845612, 2652440], [-2315000, 3551680], [-3542820, 1506240], [1287566, 766080], [-1273194, 3423648], [-3529700, 841000], [-1848414, 2680288], [8216280, 55040], [-4869412, -144560], [6211950, -2246400], [3513250, -4980], [37631448, -4816], [14506634, 514720], [-6560400, 2562800], [22315000, 519440], [-60918, 3801056], [-5399164, -5328400], [-12311640, -3182120], [-9376100, -2240800], [5752260, 5021680], [-5807900, -2971320], [-15567168, -2533944], [16623400, -2478160], [-19889760, -1533680], [-10154356, 6202280], [26938140, -76480], [-1887050, -2582560], [3738810, 3894080], [28843896, -2927232], [24386238, -3011296], [-12000050, 1872180], [-25728570, 1402740], [1891194, 1885952], [-8566944, -5195352], [962912, -5697840], [-19820300, 4524560], [-31964794, -1534080], [12107562, -4534304], [-37328070, 385740], [12216662, -9478240], [43236840, -3296880], [3410050, -1346080], [-14034916, -7069480], [47174340, -176880], [-36690052, 3413200], [-7144830, 1402560], [-27642350, -4412340], [-10397434, -161920], [25332250, -7236420], [5035470, 4603460], [23055400, 613360], [21942630, -4232960], [-54911352, 2970984], [16576890, 7779520], [-34030100, 2600960], [-60224900, 1738840], [-1387306, 5599680], [-17501220, 468040], [24766450, 6945280], [7239864, 5119712], [-55715092, -3940640], [12721650, -4896800], [53615628, -2504376], [-845346, 1472032], [70981442, 1979840], [52939300, -4745200], [3152478, 9707424], [65585016, 4290328], [-50168670, -4342560], [-43855492, 3654760], [-26112500, -8228080], [36334094, 5281280], [-18891270, -9451860], [15566022, -71424], [-72245284, 3905880], [35632536, -11018512], [-45634620, 1725840], [60462188, 6553440], [-58166750, -2037600], [-33764550, 2753600], [-10373450, 5058980], [333624, 1725392], [67159740, -3898680], [20621138, -13104960], [-12678650, 11331460], [27011940, 10963920], [38640240, -7851080], [16274634, 1339872], [62147942, -290560], [77579864, 240000], [-33436680, 5675760], [-30788750, 4725580], [-80783796, 8465032], [16676006, -1416480], [59316798, 13613184], [9482760, 765680], [-43607750, 9450940], [-83874990, -6434820], [29437300, 1404560], [-95616484, 4780880], [-84490408, 3392640], [-68974980, -736640], [-82904900, 653640], [5755224, 14877192], [-27016894, -3980480], [11676438, -521696], [97425210, 8028780], [42226380, 19986840], [-22717104, 11026368], [-58393852, -12945200], [-28595150, -15218900], [40337786, 16686400], [91760658, 500064], [-83907300, 9502600], [-11459450, -13773660], [91577730, 6182140], [114594956, 8496720], [-95358240, -572920], [91712800, -11997200], [44478720, -1591040], [-78968928, 13139976], [-83611534, -273920], [-19264542, 12734464], [43241310, -6855420], [-114611902, 2919200], [166503100, -4077480], [-54255078, 24283776], [-60177350, -182880], [-164440850, 5240020], [-33030384, -22831472], [137613014, -1922400], [-56633600, 172640], [-62492682, 12918144], [117866516, 1442480], [81618570, -4370240], [-87935880, 21910160], [11426500, 4122840], [-22120554, 10448768], [168583238, -8033760], [112933600, -5844080], [-104147150, 15615360], [-82542556, 14977480], [14561650, 6606560], [118766950, -11074620], [21271344, 14425152], [-30573886, 19002400], [110045162, -3760640], [19678830, -16020060], [76256160, -23801720], [115902008, 4939760], [128453664, 10374712], [-60122002, -7407200], [-114984800, 25148960], [-37965060, -30481080], [-37123850, 15578560], [-32099898, 11853216], [114874016, -17986320], [142553520, -8102640], [51481410, -12337120], [-201753612, -7500296], [75630354, 27397632], [55754490, 36263820], [-106903400, 33341760], [-132773190, 7630080], [51913292, 31498440], [-266573958, 409536], [-190325790, 24198780], [118552000, -14711760], [107387650, 30017120], [65746206, -10922752], [35000984, 46069520], [-3604620, 12452040], [50719292, 19336640], [66399550, -24565920], [102845820, 7069560], [46023686, -15780000], [-718980, -17951640], [29081500, -31699840], [58391976, 9922008], [107158230, 3788640], [62599380, -43046160], [30964600, 9033360], [-119928960, 875320], [-19276666, 10051520], [-388830, -527940], [-178382940, 23545080], [-163514750, 686720], [151834440, 27691920], [82556492, -34931760], [-106504550, 51524160], [201355470, 14452960], [-5315150, 39278380], [3780570, -26077440], [-196024138, -3922240], [161952356, 22653120], [56336800, -63361040], [243098472, -31846824], [-146030022, 902624], [-282171442, -19370240], [180329946, 34415168], [-292395316, 16620120], [62518980, -60403160], [80090012, 882960], [-112718484, -16755272], [-69233506, 20138880], [241794042, -17334464], [-105836662, -31656960], [-244600850, -16911820], [-244172300, -12768320], [168425562, 1196896], [-18314610, -58092480], [-222326248, -28134800], [421514994, 8466752], [54685890, 937020], [-118610098, 17623200], [233762800, -13377920], [-369610140, 6867480], [-185321286, -1529888], [214780508, -38815040], [354991750, -19023040], [-411365490, -20516320], [208744150, -42018620], [2951234, -48918080], [-48399966, -764928], [-102508080, 62886560], [11983050, -18782100], [121466382, -67160544], [71636232, 35658056], [-263003900, 33934960], [-291843120, 26185840], [-92455272, 8834424], [-59558790, 32248780], [89962900, 50704920], [-67489250, -59261120], [-295393470, 51438240], [149269750, -27163900], [-19749562, -31820160], [95029170, 49608060], [-33880156, 7661680], [6746928, -20228776], [-98901210, -55301280], [324650888, -3852560], [232079200, 48224080], [333133410, -9327620], [-245798280, -539040], [18143350, 165600], [383080140, -14820480], [-149468450, -27642080], [-284049390, 38996480], [304068894, -53190048], [-449611850, -11575100], [30140778, 72425824], [-91587484, 594880], [-75424248, -5601784], [425941412, -28191240], [7291000, -40637280], [67600600, -743680], [-423127560, 19244520], [-83114194, -38689280], [32774322, -64412224], [-99885870, -75350660], [-136798700, -46047720], [52525680, 77434240], [49070350, 850560], [-97939384, 28856880], [304853640, -2460480], [127423412, 42962960], [-122154990, -16732320], [-221669866, -73166080], [-82500498, -51818784], [-378136250, 12184900], [147170886, 17682688], [-128546370, 30095840], [230114612, -12615640], [247984600, 28059120], [226599540, 60200720], [561385900, -6547720], [403007190, -61385580], [-225772250, 28134560], [-520179882, -9003456], [-199439388, 77951096], [-35718988, -17251040], [-416289950, -3039840], [-729727290, -14858720], [-18201240, -42062320], [30643150, -55719020], [3971142, -46978464], [-208217352, -88069016], [-136950870, 58043840], [-65287100, -42470960], [-151643832, 57061944], [-92883210, 111159220], [-298754750, -54074880], [108962646, 22976768], [134702364, -25001288], [-622302480, -28508640], [279003908, 20325360], [45535200, -7048400]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_225_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


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