
// Make newform 1450.2.a.c in Magma, downloaded from the LMFDB on 03 September 2025.
// To make the character of type GrpDrchElt, type "MakeCharacter_1450_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_1450_2_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_1450_2_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_1450_a();"
function MakeCharacter_1450_a()
    N := 1450;
    order := 1;
    char_gens := [1277, 901];
    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_1450_a_Hecke( : Kf := Kf)
    return MakeCharacter_1450_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 := 2;
    raw_aps := [[-1], [1], [0], [2], [-3], [1], [-8], [0], [-4], [-1], [-3], [-8], [2], [11], [-13], [11], [0], [-8], [12], [2], [-4], [15], [-4], [-10], [2], [-8], [-14], [2], [5], [6], [-8], [12], [12], [-20], [15], [2], [-18], [-9], [2], [6], [-10], [7], [-8], [-14], [-18], [-10], [-3], [26], [-18], [10], [1], [0], [17], [27], [-13], [-9], [0], [-13], [2], [27], [-4], [-14], [7], [-8], [-9], [12], [-23], [32], [2], [-15], [26], [-25], [32], [21], [20], [-14], [0], [17], [27], [30], [-10], [32], [32], [16], [20], [-4], [-10], [2], [2], [-4], [27], [-5], [22], [-33], [-20], [-19], [-15], [-13], [-24], [-8], [-38], [2], [11], [-30], [-28], [-8], [-28], [-39], [-5], [2], [-3], [31], [12], [-35], [-38], [-8], [-34], [32], [26], [15], [-18], [-9], [-38], [-24], [-28], [27], [15], [-50], [-8], [-24], [-5], [-44], [32], [-8], [42], [-20], [-14], [22], [32], [0], [-18], [-33], [16], [-13], [40], [45], [-14], [27], [-25], [46], [-13], [42], [26], [-33], [-28], [-13], [30], [-30], [2], [37], [-33], [1], [-13], [-28], [-13], [-49], [22], [-8], [-55], [-4], [30], [37], [-38], [-14], [0], [30], [-8], [12], [1], [10], [-43], [-3], [46], [7], [16], [-5], [12], [-44], [0], [-18], [-29], [21], [-3], [32], [12], [6], [-48], [6], [-33], [36], [10], [12], [42], [30], [20], [-43], [-45], [6], [-45], [47], [42], [42], [1], [-13], [0], [-3], [32], [-28], [32], [46], [32], [-50], [-10], [21], [-48], [-70], [-24], [0], [-13], [22], [-24], [-40], [-28], [-8], [66], [-48], [-40], [-34], [-10], [-3], [-59], [2], [-14], [-20], [46], [30], [12], [-28], [-70], [1], [-68], [7], [57], [40], [-54], [60], [-58], [-63], [42], [-33], [56], [27], [-70], [-4], [-48], [-55], [40], [12], [-44], [51], [17], [-58], [-29], [-40], [32], [-49], [12], [55], [12], [12], [66], [42], [-8], [-38], [12], [12], [-4], [-38], [10], [25], [-13], [-68], [51], [27], [-74], [-25], [17], [51], [50], [-28], [-44], [-38], [80], [51], [12], [-33], [27], [-5], [-70], [-59], [56], [-10], [-78], [36], [-18], [35], [-20], [-18], [-49], [0], [-73], [47], [-18], [-19], [21], [22], [10], [76], [77], [-69], [-28], [-63], [-20], [-44], [7], [-48], [30], [6], [42], [-28], [-44], [-58], [0], [72], [86], [-15], [72], [-68], [27], [-18], [32], [42], [-18], [76], [-80], [56], [65], [-38], [72], [-54], [57], [57], [-3], [10], [87], [-54], [-8], [-74], [82], [57], [-50], [-54], [-50], [-48], [-93], [-100], [27], [36], [55], [67], [-48], [-9], [7], [-48], [50], [66], [32], [77], [11], [52], [-50], [-69], [55], [-23], [57], [-29], [-20], [-20], [82], [-98], [-10], [46], [-28], [67], [-25], [-8], [-13], [-28], [-29], [-100], [-14], [-93], [6], [-68], [2], [22], [75], [42], [12], [-79], [-30], [62], [-63], [-45], [-79], [87], [-24], [40], [72], [95]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_1450_a_Hecke( : Kf := Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_1450_2_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_1450_2_a_c(:prec:=1)
    chi := MakeCharacter_1450_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    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_1450_2_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_1450_2_a_c( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_1450_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<3,R![-1, 1]>,<7,R![-2, 1]>,<13,R![-1, 1]>],Snew);
    return Vf;
end function;