
// Make newform 75.10.b.b in Magma, downloaded from the LMFDB on 24 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_75_b();"
// To make the character of type GrpDrchElt with Codomain the HeckeField, type "MakeCharacter_75_b_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_75_10_b_b();".
// 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_75_10_b_b();".
// 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 := [1, 0, 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_75_b();"
function MakeCharacter_75_b()
    N := 75;
    order := 2;
    char_gens := [26, 52];
    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_75_b_Hecke();"
function MakeCharacter_75_b_Hecke(Kf)
    N := 75;
    order := 2;
    char_gens := [26, 52];
    char_values := [[1, 0], [-1, 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 := 10;
    raw_aps := [[0, 22], [0, 81], [0, 0], [0, -5988], [-14648, 0], [0, -37906], [0, -441098], [-441820, 0], [0, -2264136], [1049350, 0], [-7910568, 0], [0, -20992558], [13285562, 0], [0, 23130764], [0, -13873688], [0, 57635174], [32042120, 0], [110664022, 0], [0, -118568268], [276679712, 0], [0, 264023294], [-448202760, 0], [0, -851015796], [-189894930, 0], [0, -1014149278], [-1315368558, 0], [0, 1827972724], [0, 185367372], [-1978689590, 0], [0, -1578746686], [0, 2400005332], [-1968395208, 0], [0, -2029094538], [1136729140, 0], [4738537510, 0], [2262162472, 0], [0, -11788859278], [0, -11460793796], [0, -13370656008], [0, -10626363186], [-26125435120, 0], [2346889262, 0], [22406421032, 0], [0, 36595949974], [0, -5415455718], [-262713880, 0], [13449310292, 0], [0, 26646265564], [0, 33631791932], [-50045292150, 0], [0, 32962559874], [7954217240, 0], [-75247743998, 0], [-98463127008, 0], [0, 8523991422], [0, -5906543816], [71596101350, 0], [-124754651888, 0], [0, 112824180402], [87020807922, 0], [0, -3276964236], [0, 149860164294], [0, -184569910148], [90464979072, 0], [0, -10793038946], [0, 41831934962], [-12330976908, 0], [0, -21797581958], [0, -84361290188], [1232948810, 0], [0, -173387723766], [-63815917320, 0], [0, 112241606052], [0, -721003873546], [204331000340, 0], [0, 547180000584], [346262180070, 0], [0, 256757692282], [20167945242, 0], [43340521510, 0], [-510680461160, 0], [321228183382, 0], [447617411472, 0], [0, 141185768294], [850497697160, 0], [0, -303187912836], [1403278417670, 0], [0, 335353598362], [1042749631842, 0], [0, 974083754244], [0, -197850678508], [908731105320, 0], [0, 1169629218932], [-2491486068688, 0], [557571087620, 0], [0, -1801366855856], [2401096873670, 0], [1030077035282, 0], [0, -1066369079836], [2517486023382, 0], [0, -1103529331028], [0, -1090720039758], [0, -1030805225676], [4066175272590, 0], [986144387492, 0], [0, -2869473138238], [0, 1141694898732], [0, 2971762606354], [-1772617523720, 0], [1258381908842, 0], [0, 174534604492], [0, -4630369457746], [0, 2505177639342], [-544227615740, 0], [-6519747334448, 0], [-3362965780158, 0], [0, -1180819220676], [0, 6631762482592], [0, -825189215186], [440214037640, 0], [9777884642542, 0], [0, -4225910364186], [0, -7569770190918], [0, 1920285453924], [-3998388906788, 0], [11273616080282, 0], [-11267900052070, 0], [9052470846240, 0], [0, 1344083568692], [0, -657401165786], [-2155870422700, 0], [0, 7735942623584], [-11244801937688, 0], [0, -11854438840718], [-2247651763758, 0], [14450525662270, 0], [0, -5190224051466], [0, -13993847295788], [0, 20126878481762], [8957747618710, 0], [-1764457434948, 0], [14808178742322, 0], [0, 3396507315724], [0, 18834421634452], [-11894665629990, 0], [12288146871880, 0], [0, 4613545257054], [0, -4293628278338], [6404282426420, 0], [0, 3244207905184], [0, 28971147004722], [7504473544522, 0], [0, -28714133607236], [0, 9998251603512], [0, 4708461943572], [26966252086912, 0], [3966177723440, 0], [-19691225561210, 0], [0, -21130483382598], [5410718200082, 0], [0, 3442590745932], [0, 4184403332234], [0, 14980025803772], [-28246046905488, 0], [0, -46224186526778], [0, -48036293325216], [23121091830512, 0], [0, -13536183450678]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_75_b_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_75_10_b_b();".
// 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_75_10_b_b(:prec:=2)
    chi := MakeCharacter_75_b();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 10));
    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_75_10_b_b();".
// 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_75_10_b_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_75_b();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,10,sign)));
    Vf := Kernel([<2,R![484, 0, 1]>],Snew);
    return Vf;
end function;