
// Make newform 825.6.a.c in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_825_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_825_6_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_825_6_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
        poly := [-8, -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_825_a();"
function MakeCharacter_825_a()
    N := 825;
    order := 1;
    char_gens := [551, 727, 376];
    v := [1, 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_825_a_Hecke(Kf)
    return MakeCharacter_825_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+1)]];
    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 := [[-6, -1], [-9, 0], [0, 0], [-104, 62], [-121, 0], [102, -74], [178, 372], [-840, 852], [284, -330], [-398, 1492], [-4440, -1600], [2362, -2816], [18238, 8], [-3328, -3112], [-21676, -390], [9638, -7102], [-404, -1980], [-11638, -2026], [26612, -12704], [13516, 4354], [20606, 5568], [-2712, -11426], [-50700, 21960], [-13750, -26704], [115822, 9924], [4906, 17052], [72336, 5252], [-102140, -5432], [-24550, -19958], [109718, -23752], [-205416, -19486], [43796, -79408], [103766, 72492], [312880, 6204], [176922, 39536], [75776, -38706], [-54358, -49580], [-46540, 80592], [-363544, 52412], [103374, 180972], [597756, 56844], [30686, 2860], [-277028, 121806], [137030, 96444], [-324682, 67684], [-40488, -309036], [102688, 229192], [-1072160, 24944], [453884, -154480], [-862242, 59340], [-570158, -240032], [-449616, 258996], [-945086, -119484], [189140, -488772], [742190, -382736], [135792, -308720], [91666, -75826], [-33224, 303314], [-776634, 14674], [-1168578, 234108], [126912, 168568], [307990, -170912], [833160, -777388], [-602076, 286098], [-330762, 437264], [-1415042, -599730], [1022740, 27144], [-1467146, 1104648], [433932, 218432], [1159250, 17138], [2074814, -700120], [1344912, -45740], [-1299696, -537176], [-466826, -924754], [-1745116, 1074448], [-485372, 340430], [-1187950, -1155226], [-267046, 232908], [1280466, -45988], [-770326, 1163684], [-3602116, 1305772], [-3707626, 549520], [342328, 627976], [-623698, -740904], [1855560, -2356954], [-671292, 2551940], [3182330, 423388], [5512246, 753892], [4115266, -264200], [2299016, -1066068], [-3556172, 1688824], [-2980344, -531712], [-1488168, -1926172], [-2149812, -459776], [-1582796, -1621624], [7702200, 21068], [1986866, 631358], [-256998, -683964], [4835680, -339024], [987130, -3061278], [2245504, -1053780], [-4633282, -689792], [-563788, -1879496], [2589766, 214348], [13514104, 260636], [-2110674, -357900], [6507220, -2554524], [2322826, -844492], [5624500, -3752398], [-682518, -127232], [-3405272, -3539886], [-3733426, -311894], [-10669154, -1851104], [-1248708, -2197664], [-1917248, 3249456], [-6293494, -1725172], [-12702356, 3099624], [-3466932, -1407098], [2973414, 2531702], [-16747668, -351752], [256942, -2635428], [11287958, 2372236], [6260902, -3835652], [2373116, 1620300], [-10646620, -2946720], [-6728398, -639080], [-6096226, 3685308], [9677748, -1716462], [-4859512, -5507356], [-14431610, -998186], [-4701800, 2331152], [-12400160, 4973196], [13589912, 1086640], [18741242, -899336], [18842038, -4101668], [-368662, 1139748], [8243750, -9258526], [18021736, -1165000], [9141686, 500082], [-27279354, 1343280], [1984600, -4560816], [-653446, -5065548], [4437784, 5343040], [-4821364, 7285008], [7534462, 5527680], [-15239748, 3421966], [-17234034, -3492622], [16064378, 5915184], [-20159132, -389168], [-17674772, 996178], [-20947218, -463074], [-13764966, 6571592], [-27100140, 4813816], [-4760528, -3139804], [1294340, -2735368], [676852, -13008278], [15723152, -11126534], [30770, -3964612], [-18310922, 1465248], [22290994, 178396], [-15601492, 3638696], [-51990406, 1525456], [27386000, 2728938], [16569100, -105084], [20900750, -5752468], [4582316, -12410386], [-39482856, 2218496], [26534582, 8712982], [-5192862, 10188172], [-34602610, -1195906], [-26562228, 9029144], [14780966, 12157804], [984352, 2683380], [-10265858, -6019248], [-697632, 430072], [-21756078, 530696], [3124104, 7758244], [-33768334, -1095398], [36319256, 444286], [-28319790, 3925778], [-44010680, 11110776], [7740836, -2794160], [-22212230, 16082536], [26147578, 2229856], [35189276, -1110106], [-29512142, 2064010], [-31812322, 10031282], [19205580, 555720], [191434, -230284], [-6617992, -7002968], [22808894, 3220108], [49955820, -13022296], [-16502684, -4798208], [-28221686, -3643682], [45094852, -7152728], [26427254, -12891544], [20204978, 5456856], [-8148390, -874820], [-14747310, 546192], [7545432, -2759360], [34643458, 5869624], [-7069040, -15037286], [51823426, -12280316], [67703018, -4150232], [65053396, 3454188], [-66394530, 19851110], [-76957784, 3660964], [-53373348, 15047448], [-75495850, 3711140], [40492164, 16502936], [-1911274, -12530140], [60202178, 350042], [-3753456, -29864304], [-21963332, -10728720], [2363712, 459780], [49581738, -8541908], [-16834608, -1181614], [-49555514, 20092492], [-23235932, -27500282], [7589382, 18682038], [27562618, 15584214], [-43121488, -19008850], [126127874, 2247956], [26467600, 6606408], [-71810908, -3469312], [-42968614, 32593146], [-34451394, 10905480], [63501204, 15342534], [-10829096, 28161746], [-5078708, 3344720], [74732466, -9871856], [62400672, -24230200], [-71219968, -14525678], [-74934218, -1277820], [-8375548, -27462384], [-45020016, 42566120], [-63156574, -4403344], [75954470, 3304880], [31868548, -41030428], [28020684, 29970190], [-36355468, -36185096], [107107152, -1726136], [107017056, 14559456], [34899350, -30141244], [-41977990, 25277908], [-4579296, -44599764], [-125802688, 2562172], [62853316, -10815336], [23473784, 39765716], [69642136, 25117284], [52228910, -3956454], [17430534, -48295744], [-62298676, 18487058], [-119863670, 21467084], [3794014, -56330120], [-15553428, 59596792], [-16478058, -56420704], [-85645144, 19467056], [-11740746, 45774606], [79134862, -30380812], [-18743800, -25566690], [101474316, -21679080], [-90455598, -8509742], [-11792114, 3615070], [-30031690, -35379028], [-28344292, 8989936], [148263546, -121614], [-10937070, -22711728], [-12431632, 52332340], [-25433114, 54764476], [29163974, -11708820], [-136802468, -7595888], [109070598, 11262412], [-33199264, 6808734], [46373446, -58745472], [213583880, -5699948], [-85739564, 36116920], [1937818, 9780174], [111590506, -5303256], [-198381700, 1136864], [-45260120, 4216344], [89069320, -57041188], [78872032, 26113412], [-122836038, 70999954], [-58840488, 25740724], [-32478004, -70659358], [-119713858, 35638388], [-122147722, -51018028], [3625304, -25204772], [19187190, 27725068], [127719434, -20136578], [-158574404, 1460924], [39008306, 15403220], [-72721564, 92888], [41411518, 9303694], [165016946, -12935504], [-90182464, -34153436], [87278054, 4327690], [-39636988, 819248], [-79988112, 42377432], [46106750, 3407804], [-119022018, 7997760], [-199878432, 19403162], [164794612, -7283112], [196435300, -20131120], [-209628034, -19521288], [64875716, -74781160], [-163432722, -52521264], [80617100, -1910194], [43574854, 17823190], [33104096, -14649100], [-89372294, -11175358], [88340790, 39508440], [51777612, -43913032], [57332416, 7420552], [-207651294, -4636976], [-36912276, -49807888], [-217130992, 71129016], [40253582, 87548016], [19071790, -93803472], [-238291256, 10129236], [-83670714, -79732460], [165535218, 25124648], [-212928784, 45061468], [38156930, 22156900], [-154375982, -9933796], [289746828, -43737288], [148613972, -54401432], [-96495248, 27778468], [-32979194, 32215908], [100346642, -24228314], [-8768314, 86725610], [59901792, 43723954], [28443132, -61913968], [-96949008, 60118296], [-61654724, -69780728], [102735878, 77233684], [-25256470, 57895972], [-55446646, -35152976], [-232827096, 32080898], [270791842, 43028484], [-17481810, -6637140], [-15214550, 98958088], [-166053064, 70118208], [-377222738, 37837250], [-50053428, 26436856], [-205517746, 37324564], [-91601092, -57557264], [-28470296, 9455140], [105224662, 49090786], [-101611152, -46717784], [13396678, -35287208], [-204570158, -31612466], [-155653000, 11046290], [-230621742, -26736226], [104848426, -65397728], [3658516, 105738178], [-124570932, 25271120], [-472528510, -10357008], [53882524, -64079038], [-84182882, 143564154], [149821054, -159054980], [-258283836, -45579114], [216680268, -62556104], [143169828, -193065360], [70357782, 103762480], [-51774786, 46888944], [271928080, -76839630], [-409258590, -3363108], [-77188460, -139432460], [-246924332, 508336], [170483328, -53139976], [-51238502, -41228572], [175476680, 53549662], [-336084558, 14268232], [101442932, 45283192], [287643760, -46922916], [195931406, -3660896], [-14037874, -43863568], [125867030, -115127260], [460740154, -44615170], [-141806114, -93333380], [-425807728, 97639186], [-59541166, -82766676], [-199587368, -29341872], [-345186004, -14399206], [-246413624, -17646680], [-51681286, 141533776], [-267716752, 41923168], [113257444, 121684298], [80397522, 102999028], [-255167682, -89488930], [158742084, 151216004], [56972204, -62762160], [456298924, 3589966], [329731270, -102230692], [-510640, -50238894], [95318210, -41970052], [-97612604, 42398232], [36210442, -177441732], [-277064902, -49907850], [182511406, 40304940], [13162432, 170232334], [-56765554, 193434764], [526285290, -82035896], [-423947064, 109400226], [209287346, -114177352], [251173158, 150378232], [-156394252, 163954816], [-321313708, 17753920], [-334377602, -13781792], [-14536698, -96086056], [-103557756, 61355312], [-367341712, -74713404], [89945950, -54618672], [380778706, -16665590], [540369760, -17706948], [596048, 27021548], [580653558, 72045988], [247130808, 50208948], [-187332006, 302210810], [-502585746, 112075066], [100486140, 21305046], [-573639428, 68255000], [-214397786, 66972932], [-242011490, 148804786], [401086764, -159027888], [-321512034, -150426656], [-437712092, 43426824], [397117296, -45269504]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_825_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_825_6_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_825_6_a_c(:prec:=2)
    chi := MakeCharacter_825_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_825_6_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_825_6_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_825_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,6,sign)));
    Vf := Kernel([<2,R![34, 13, 1]>],Snew);
    return Vf;
end function;