Sum of roots of unity equal to a fix number Let $\lambda $ be a complex number with $|\lambda|\le n $ , is there a way to choose  roots of unity $x_j$'s (of any order, repetition allowed) such that $$\sum_{i=1}^{n} x_i=\lambda$$?
This is part of my effort of trying to generate a random unitary matrix with arbitrary trace.  Any idea will be greatly appreciated.

As noted in the comments by Conrad and Ross, $\lambda$ will have to be algebraic if the equality is to be exact.
 A: I don't know enough analysis to help you find your random unitary matrix, but I can help show why this equality will not always hold and contemplate conditions on when it will. For one, you can do a counting argument similar to the one @RossMillikan gave in the comments: there are countably many roots of unity and therefore only countably many finite sets of roots of unity, so only countably many sums can possibly appear.
This argument is very convincing, but nonconstructive. I can, however, give you an explicit example of a complex number which will never be of this form: $2^{1/3}$. I arrived at this using Galois theory. Indeed, let's say $x_i$ is an $m_i^{th}$ root of unity. Then it is also a $k m_i^{th}$ root of unity for any integer $k \geq 1$. Hence, if we let $m = lcm(m_1, \dots, m_n)$, then each $x_i$ is an $m^{th}$ root of unity. Let $\mu_m$ be the set of $m^{th}$ roots of unity in $\mathbb C$. Then $\mathbb Q(\mu_m)$ denotes the field extension we get from adjoining all $m^{th}$ roots of unity to $\mathbb Q$. Every $x_i \in \mu_m \subseteq \mathbb Q(\mu_i)$ so any possible sum of the $x_i$ will be in $\mathbb Q(\mu_m)$ as well. In fact, the evaluation of any polynomial with rational coefficients in $n$ variables at the $x_i$ will also be in this field. Furthermore, $\mathbb Q(\mu_m) / \mathbb Q$ is an abelian extension. In fact, its Galois group is $(\mathbb Z/n\mathbb Z)^\times$. Hence, if we had an intermediate field $\mathbb Q(\mu_m) / F /\mathbb Q$, the extension $F/\mathbb Q$ would also be abelian if it was Galois. Hence, if $\lambda$ was a sum of various roots of unity, then the Galois closure of $\mathbb Q(\lambda)$ would be an abelian extension over $\mathbb Q$. This is not the case for $2^{1/3}$, as the splitting field of the polynomial $x^3 - 2$ has Galois group $S_3$ over $\mathbb Q$.
So we now have a way to determine if $\lambda$ is a sum of roots of unity, in fact to determine if it is $f(x_1, \dots, x_n)$ for a rational polynomial $f$ in $n$ variables: we compute the Galois group of the Galois closure of $\mathbb Q(\lambda)$ and see if it is abelian. We can sort of go the other way too, by way of the highly nontrivial Kronecker - Weber theorem. This says that any abelian extension of $\mathbb Q$ is contained in a cyclotomic extension $\mathbb Q(\mu_m)$. Hence, if the Galois closure of $\mathbb Q(\lambda)$ is abelian, it will be contained in some big cyclotomic extension $\mathbb Q(\mu_m)$. In particular, $\lambda \in \mathbb Q(\mu_m)$. Hence, $\lambda = f(\zeta_1, \dots, \zeta_k)$ for a rational polynomial $f$ and some $\zeta_i \in \mu_m$. This is not quite the sum you had in mind, but it's very close. A product of roots of unity is still a root of unity, so $f(\zeta_1, \dots, \zeta_k)$ is a $\mathbb Q$ linear combination of some roots of unity. If we, furthermore, had that $f$ had integer coefficients then this would become an actual sum of roots of unity.
In summary, $\lambda \in \mathbb C$ is a $\mathbb Q$ linear combination of various roots of unity if and only if the Galois closure of $\mathbb Q(\lambda)$ is an abelian extension of $\mathbb Q$. I'm not sure off hand what conditions would guarantee that $\lambda$ were a $\mathbb Z$ linear combination of roots of unity, but we care about this as any $\mathbb Z$ linear combination of roots of unity is a sum of roots of unity, which is what you were after.
A: The answer is no. Not even for algebraic numbers. If such an equality were possible, it would mean that there exists roots of unity, $x_1,\dots x_n$ such that any $\lambda \in \bar{\mathbb{Q}}$  lies in $K = \mathbb{Q}(x_1, \dots x_n)$. The galois group of $K$ is always a finite abelian group whereas the galois group of $\lambda$ can easily be non-abelian. For instance, $^3\sqrt{2}$.
