# Construction of a field with roots of unity in MAGMA

I would like to construct a field (NumberField) that contains a (primitive) $$n$$-th root of unity and $$i = \sqrt{-1}$$ using a computer algebra system MAGMA, i.e. $$\mathbb{Q}(\zeta_n, i)$$.

I tried constructing it as follows (for $$n=7$$):

n := 7;
Qx<x> := PolynomialRing(Rationals());
f := CyclotomicPolynomial(n);
g := x^2+1;
F<a> := SplittingField([f,g])
DefiningPolynomial(F);


Here the element a gives me the $$n$$-th root of unity. But how do I get b such that $$b^2=-1$$?

• You can create E<a> := SplittingField(f); and then F<i> := SplittingField(g,F); – Morgan Rodgers Mar 30 at 16:47
• You can also create F as a cyclotomic field, F<a> := CyclotomicField(LCM(n,4)); and then ask for RootOfUnity(4,F); – Morgan Rodgers Mar 30 at 16:50
• @MorganRodgers Thanks. I couldnt think of LCM command. Also I didnt know how to compute SplittingField over another field. – Mike V.D.C. Apr 1 at 12:50