Coefficient field of a newform using Magma It is well-known that, for a newform $f = \sum c_nq^n \in \Gamma_0(N)$, the coefficient field $K_f := \mathbb{Q}(a_1, a_2, a_3, \cdots )$ is a number field.
I am introducing myself in Magma, and I was wondering (because I failed to find a reference for this) if there is a way to find, for a newform as an input, the number field associated using Magma. I am interested in this, because later on I want to compute the $\text{Norm}_{K_f/\mathbb{Q}} (a_l(E) - c_l)$ for some elliptic curve $E / \mathbb{Q}$.
I would deeply appreciate if anyone has a reference for this or knows the command for this.
Have a nice day.
 A: Here is code in Sage which does what you're asking for:
sage: t = cputime() 
....: f = Newforms(123, names='a')[3]
....: print(f.hecke_eigenvalue_field())
....: E = EllipticCurve('389a')
....: for p in prime_range(1000): 
....:     print(p, (E.ap(p) - f[p]).norm()) 
....: print( "Time %.3f sec" % (cputime() - t))

This took 0.8 seconds on my machine. This can almost certainly be done more or less equally easily in Magma or PARI/GP too.
EDIT. Here's code doing the same thing in Magma:
T := Time();
E := EllipticCurve("389a1");
f := Newforms(CuspForms(Gamma0(123), 2))[4][1];
for p in PrimesUpTo(1000) do
    [p, Norm(FrobeniusTraceDirect(E, p) - Coefficient(f, p))];
end for; 
Time(T);

Magma seems to be a shade faster (0.7 seconds to 0.8) but there's very little in it. I haven't tried coding this up in PARI -- the functionality certainly exists but I'm not so familiar with how to use it. Maybe someone else can weigh in for comparison EDIT: François Brunault has kindly provided a PARI/GP code sample in the comments below.
A: David and François have given nice answers to the question at hand. More generally for questions like "How do I do $X$ in Sage/Magma/PARI/GP?", you could consult the respective reference manuals: Sage, Magma, PARI/GP.
Also, do consider checking out the LMFDB. There you can find lots of code snippets for constructing these objects (e.g. for elliptic curves you can click the respective "Show commands for" button). For your question of Newforms in Magma, there is a "Modular form to Magma" download option (see e.g.  here, on the right) which gives you lots of additional information, and studying the code in that file (as well as the analogous ones for Sage and PARI/GP) is a good way of getting better at mathematical programming in these languages.
