
// Make newform 10.15.c.a in Magma, downloaded from the LMFDB on 16 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_10_c();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_10_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_10_15_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_10_15_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
        poly := [91125000, -12217500, 819025, -11690, 2, -2, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0], [177209808750, -21376234525, 137033615, -962087, -148963, -27556], [-9607187345, 2997000, 1297590, -201354, -24026, -222], [524538144697500, -38755988958425, 991491950230, 34470074426, 619265974, -43521437], [-139134133350000, 38110094958425, -1271140130230, 8924433574, 1381798526, 91365437], [-2045037534536250, 245935421194175, -4855565916805, 4244146309, 1767216041, 325457492]];
    Rf_basisdens := [1, 162210633750, 1044835, 162210633750, 162210633750, 162210633750];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    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_10_c();"
function MakeCharacter_10_c()
    N := 10;
    order := 4;
    char_gens := [7];
    v := [3];
    // 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_10_c_Hecke();"
function MakeCharacter_10_c_Hecke(Kf)
    N := 10;
    order := 4;
    char_gens := [7];
    char_values := [[0, -1, 0, 0, 0, 0]];
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    values := ConvertToHeckeField(char_values : pass_field := true, 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+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 := 15;
    raw_aps := [[-64, 64, 0, 0, 0, 0], [485, 485, 0, 1, 0, 0], [13752, -18634, -7, 4, -17, -6], [157124, -157124, -79, 0, 113, 79], [-7594208, 0, -542, -601, -601, 0], [-8701134, -8701134, -9113, 19630, 0, -9113], [-49114757, 49114757, 14878, 0, 184678, -14878], [0, 636309218, 0, -20294, 20294, -78634], [-1571403368, -1571403368, 26493, -1345107, 0, 26493], [0, 5918169182, 0, 322060, -322060, 1967306], [625659100, 0, -1335122, -8804863, -8804863, 0], [-71658052212, 71658052212, -856227, 0, 24285408, 856227], [7578435160, 0, -12833134, 46195171, 46195171, 0], [-155943192417, -155943192417, -27289402, 69513665, 0, -27289402], [-160952988042, 160952988042, -14126433, 0, -268955403, 14126433], [-311388421006, -311388421006, 145594479, 219814968, 0, 145594479], [0, -1919025468826, 0, 92485290, -92485290, -57902718], [352029635808, 0, -94802414, -316872301, -316872301, 0], [-1414236925873, 1414236925873, -261369138, 0, 2081684625, 261369138], [3722591433356, 0, -40746482, -495159247, -495159247, 0], [-1166111112881, -1166111112881, -1140373166, 39115288, 0, -1140373166], [0, -3321768540888, 0, -57359552, 57359552, 489899192], [-10085519551347, -10085519551347, 2381105704, -1956036779, 0, 2381105704], [0, -21005367910460, 0, 2948444520, -2948444520, -437255700], [-51218932804839, 51218932804839, 7585255592, 0, 10698613328, -7585255592], [19628878518638, 0, 11942104588, 16834174850, 16834174850, 0], [-64497934497068, -64497934497068, 3773545825, -35489518955, 0, 3773545825], [57197955071869, -57197955071869, -3608774320, 0, 19085478857, 3608774320], [0, 38178852836680, 0, 45047719701, -45047719701, 8697503592], [-98407333325173, -98407333325173, 14073101038, 21498487558, 0, 14073101038], [220666669217774, -220666669217774, -37482360265, 0, -78987688783, 37482360265], [-582758190201656, 0, -31710926198, 138294684803, 138294684803, 0], [310382756389107, -310382756389107, 100823323678, 0, -111328780424, -100823323678], [0, 576865274854414, 0, -288649347110, 288649347110, 104834717882], [0, 245930089992144, 0, 580184392747, -580184392747, -202909827424], [-1321571772041348, 0, 40826808830, -285564897335, -285564897335, 0], [1541618917154784, -1541618917154784, -62446904559, 0, 491364327078, 62446904559], [-866907968367619, -866907968367619, 44371973416, -1536975481391, 0, 44371973416], [1614504111992216, -1614504111992216, 245250354253, 0, -89879250851, -245250354253], [-4375442454785828, -4375442454785828, -39402715355, 790586341360, 0, -39402715355], [0, -843653986388006, 0, 794018289838, -794018289838, -605325811522], [-2618241321487246, 0, -631695084616, 334493681284, 334493681284, 0], [5843666640647516, 0, 149808525678, 2176645410513, 2176645410513, 0], [1688150172079671, 1688150172079671, 194747246146, -158893068746, 0, 194747246146], [1462321511653812, -1462321511653812, -642267374603, 0, -3138205635440, 642267374603], [0, -8110225388392260, 0, -2017456094756, 2017456094756, 123159699668], [-2329642299760960, 0, 801736257682, 4492766956319, 4492766956319, 0], [-12066205124065146, -12066205124065146, -1266156191585, 843788423569, 0, -1266156191585], [749146571551595, -749146571551595, -1447091852734, 0, 2763407243045, 1447091852734], [0, 1181900786700282, 0, 6264565235604, -6264565235604, 1868796851454], [7107867417669933, 7107867417669933, 1215012169708, -6948281787170, 0, 1215012169708], [0, 18330738504783360, 0, -4429010581068, 4429010581068, 1069986310464], [-5115726463896632, 0, 6873690974034, -8071875496317, -8071875496317, 0], [9252865563563256, 0, -8569927052854, 20153706985267, 20153706985267, 0], [-12227309780131609, 12227309780131609, -8858658540270, 0, -5507814221274, 8858658540270], [24947402298257024, 24947402298257024, -4189488087675, -35671216179351, 0, -4189488087675], [0, 109341344328333956, 0, 6738453082299, -6738453082299, -2665585538724], [-45256976036146332, 0, -1812292006362, 31123650697125, 31123650697125, 0], [871252220237046, -871252220237046, 9676452922219, 0, 47197983465790, -9676452922219], [-86009908206740808, 0, -8649028948910, -10093987787485, -10093987787485, 0], [45319514165466335, 45319514165466335, -7367844968426, -10646976476795, 0, -7367844968426], [14577625317197556, 14577625317197556, 15037072560261, -82291003424586, 0, 15037072560261], [-160021783491965757, 160021783491965757, 3302805199290, 0, -66321702251535, -3302805199290], [68731120660267268, 0, 136343850070, -33339438430339, -33339438430339, 0], [-135348770310900855, -135348770310900855, -13296476427824, 57193130334622, 0, -13296476427824], [-5678681404430184, 5678681404430184, 27587840563033, 0, -51462478921946, -27587840563033], [460392912021069232, 0, -9563334072302, -22367899050721, -22367899050721, 0], [-252523576930455195, 252523576930455195, -9469994277572, 0, 23347409986672, 9469994277572], [209033537379754333, -209033537379754333, 24910837772864, 0, -173631472267771, -24910837772864], [0, -152578924972993378, 0, -60124291985076, 60124291985076, 556354327434], [-238460260286190039, -238460260286190039, -11697091068968, 59094901971520, 0, -11697091068968], [0, 126894555434262532, 0, 130174166827800, -130174166827800, -893415148884], [233685860276478050, -233685860276478050, -44276327521949, 0, 487077642489505, 44276327521949], [360764197687251586, 360764197687251586, 23605924988511, -96857188725816, 0, 23605924988511], [0, 310864102230783998, 0, 304201416904038, -304201416904038, -52239391854390], [144748537016015214, 144748537016015214, -50134858141513, 493840278085841, 0, -50134858141513], [0, -345333249357641220, 0, -114585404093427, 114585404093427, 98573965714596], [504937563224168062, -504937563224168062, 71661953036795, 0, -489313364564152, -71661953036795], [-1397440179721030686, 0, 143242772731904, 179207399762224, 179207399762224, 0], [0, 1043521016422290666, 0, -351734271410693, 351734271410693, 116026466517182], [0, 919036666456726218, 0, -34675796166118, 34675796166118, 48200440977358], [-237284851548587968, 0, -183803596550110, -266611991923205, -266611991923205, 0], [-2482398554201596076, 0, -63239847979722, -732092095899939, -732092095899939, 0], [1673498649693343925, 1673498649693343925, -133174898413364, 372343212321232, 0, -133174898413364], [0, 1698771658338347596, 0, -613479140024168, 613479140024168, -212419125273148], [-1784380814570508345, -1784380814570508345, -36638661888082, 552750352893029, 0, -36638661888082], [0, 874275209321053658, 0, -447699218205699, 447699218205699, -323724175402194], [-233851847977002759, 233851847977002759, 80321815630032, 0, 675032722616238, -80321815630032], [932056485709178494, 0, -722331290757972, 376217508226386, 376217508226386, 0], [-1282926548037220642, -1282926548037220642, -393971734263945, -181305315122403, 0, -393971734263945], [675796641651440071, -675796641651440071, 236728151533158, 0, -502681398063411, -236728151533158], [0, 307630350745755560, 0, -816620491365780, 816620491365780, 765510042891000], [685936203063672852, -685936203063672852, -317135931556671, 0, -878800341984903, 317135931556671], [6065994611832435968, 0, 199313435623490, -570744915406649, -570744915406649, 0], [0, -413875333215289694, 0, 2114128918149362, -2114128918149362, 524532284753302], [-2345007986491155864, -2345007986491155864, -630416653810035, -476369811638907, 0, -630416653810035], [0, -4738497680883677554, 0, 2746273236976620, -2746273236976620, -1106412724466982], [-5200800199124099874, 0, -1056055770919484, 103342914209942, 103342914209942, 0], [-3642785848396702461, -3642785848396702461, 1057131606160082, -3023103462770659, 0, 1057131606160082], [-1205350244041127234, 0, 54471666262988, -1924271401631582, -1924271401631582, 0], [2988218199470855211, -2988218199470855211, -1072985498295230, 0, 625345130476021, 1072985498295230], [-2702626952615881338, 2702626952615881338, 1328485218147635, 0, 1633898374032248, -1328485218147635], [-208855177149647895, -208855177149647895, 1596438119374236, 1011355865916777, 0, 1596438119374236], [0, -10877373745822963634, 0, -724645927981739, 724645927981739, 733112414250410], [8070873763936002224, 0, 63092716882418, -3669764138784929, -3669764138784929, 0], [3649184561055558487, -3649184561055558487, -932986030103646, 0, -7450546220320218, 932986030103646], [-2135311139635464015, 2135311139635464015, 2078469813920844, 0, -12279007072633947, -2078469813920844], [16306191839199242509, 16306191839199242509, 82284555351284, 11508004427619008, 0, 82284555351284], [0, -4517124009707640220, 0, -592536372249284, 592536372249284, -4033055118726388], [-796835967193556680, 0, -299862102975150, 5509078773819843, 5509078773819843, 0], [-6431702222928182982, 6431702222928182982, 1101108731769723, 0, -254147840835387, -1101108731769723], [11547672641546088612, 11547672641546088612, -2530590180521387, -891798461284922, 0, -2530590180521387], [1367357696075577585, -1367357696075577585, -656848560588712, 0, -6692153199554578, 656848560588712], [0, 12024913800432780030, 0, -5997888998499510, 5997888998499510, 1325980906311690], [17411554285242357988, 0, -6762463825269130, -9773095179436499, -9773095179436499, 0], [1209559394638565864, 0, -4543961988629742, -10826741722877949, -10826741722877949, 0], [-50658505227652812399, -50658505227652812399, 1635630539484100, 4601859140281213, 0, 1635630539484100], [-25127328179261304244, 25127328179261304244, 1196843916011849, 0, 15411888472941785, -1196843916011849], [-10549223553777986220, -10549223553777986220, 1444375702603373, -25936703311781296, 0, 1444375702603373], [0, 35721530328022509730, 0, 8396812093487946, -8396812093487946, 4712768698722582], [48276335162382231536, 0, -1271959743016878, 16608662998028835, 16608662998028835, 0], [-23046138600731913479, -23046138600731913479, 228820700552456, -13154925114764176, 0, 228820700552456], [-24886939466508829844, 24886939466508829844, -3912015267797507, 0, 2333519269617904, 3912015267797507], [-17898195962861698017, -17898195962861698017, -7676065964464954, 13518819201262433, 0, -7676065964464954], [-35585308469050032, 0, 9571583500835074, -2635500030571897, -2635500030571897, 0], [30929651302212534832, 0, -9697760265078782, 25887876674865659, 25887876674865659, 0], [0, 54779066369725627850, 0, 37614312330109572, -37614312330109572, -5506570695963666], [0, -47664678017213600464, 0, -15502119276938892, 15502119276938892, 227798721240144], [88793317345031913456, -88793317345031913456, 6035342082170149, 0, -1063378857074735, -6035342082170149], [6338150092975792096, 6338150092975792096, -622703818893791, 23332831665199312, 0, -622703818893791], [0, 114047808998918934994, 0, -24856740742008322, 24856740742008322, 513757330729318], [76531273551010704704, 76531273551010704704, 2200358540981093, -41180401864614223, 0, 2200358540981093], [48821713200130783164, 0, -7849071756823698, 30554287619752593, 30554287619752593, 0], [93741963920741711742, -93741963920741711742, -1061309908237341, 0, 58906807783473102, 1061309908237341], [-95357662357824713246, 0, -10381199985456464, 30250114157679320, 30250114157679320, 0], [0, 35023453608803225968, 0, -37843863055050744, 37843863055050744, -26354641757156784], [80032921426067168700, 80032921426067168700, -16686406441789763, 3039795982263718, 0, -16686406441789763], [-67836232291088307581, 67836232291088307581, -15582102766645094, 0, 49382423583342793, 15582102766645094], [-8324233362664443984, 8324233362664443984, 16249754225551745, 0, 12812773791809606, -16249754225551745], [0, -17672708584769916548, 0, -21143552113153592, 21143552113153592, 10437989181081812], [239155598973658037336, 0, -3503116263101366, 55806986078265971, 55806986078265971, 0], [25143142437898034704, 0, 11782185861685874, 37214594174211619, 37214594174211619, 0], [-110301170196776666512, -110301170196776666512, -2183461795556379, -14095020245545827, 0, -2183461795556379], [-28368619599697187115, 28368619599697187115, -25334119821662008, 0, 45602581751888981, 25334119821662008], [0, 11540705029584581836, 0, 50671241651125291, -50671241651125291, 17801202565434740], [0, -343680635359408960772, 0, 12749932376118156, -12749932376118156, -15058945311442284], [-5059638689310179048, -5059638689310179048, 20536859606287073, 12473964351771398, 0, 20536859606287073], [5486628996535717623, -5486628996535717623, -8566082071037894, 0, 6423682666078696, 8566082071037894], [0, 214634275565525471542, 0, -41166567564385750, 41166567564385750, -28135246416800654], [-218748430138496656310, -218748430138496656310, 8634312977010731, -2540876505031483, 0, 8634312977010731], [144958398923741685684, -144958398923741685684, 804885651552989, 0, 137383273650427286, -804885651552989], [-95296195449332611064, 0, 19555916309148946, -140539243619961373, -140539243619961373, 0], [50913147752119201177, 50913147752119201177, -28947086104626580, -105684084795602935, 0, -28947086104626580], [85142839787822602128, -85142839787822602128, 55913323417768805, 0, -166599056926106695, -55913323417768805], [-2684343769373572715, 2684343769373572715, -30402903532371336, 0, -107590169071946007, 30402903532371336], [-299671950938057463364, 0, 34276450519905966, 63522220876462017, 63522220876462017, 0], [0, -72964898796019127564, 0, -82389760527814188, 82389760527814188, 37754239898996412], [0, -372393896845747204042, 0, -33619476959456861, 33619476959456861, -43371955271214718], [-12398532591570346223, 12398532591570346223, -17616188363499784, 0, -271175057824995106, 17616188363499784], [-289941872285218988670, 0, -116276298771374792, 152483923796944292, 152483923796944292, 0], [159342633497880152243, -159342633497880152243, 8450478177536010, 0, -2538442122352575, -8450478177536010], [255221147173956917625, 255221147173956917625, -35359357617432544, -22761449900403058, 0, -35359357617432544], [59123210873052747976, -59123210873052747976, -63747393266145603, 0, 167394964651902933, 63747393266145603], [-938015441535310437976, 0, 50573641736036218, 81653280376496171, 81653280376496171, 0], [220428496785438173205, -220428496785438173205, 50540268670730060, 0, -89348965631100496, -50540268670730060], [-2107317840436391188, -2107317840436391188, 40341535517983609, -5724788441999231, 0, 40341535517983609], [-532130852773391845244, 0, -12182882896740954, 24961295594252757, 24961295594252757, 0], [476828591302856893114, -476828591302856893114, -25522249712731897, 0, 225417863910762350, 25522249712731897]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_10_c_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_10_15_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_10_15_c_a(:prec:=6)
    chi := MakeCharacter_10_c();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 15));
    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_10_15_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_10_15_c_a( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_10_c();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,15,sign)));
    Vf := Kernel([<3,R![153653538240557582112, -111294285222361968, 40306321823076, 957313944, 4239872, -2912, 1]>],Snew);
    return Vf;
end function;