  Though algebraic geometry over $\mathbb C$ is often used to describe the
closure of the tensors of a given size and complex rank, this variety includes
tensors of both smaller and larger rank. Here we focus on the $n\times n\times
n$ tensors of rank $n$ over $\mathbb C$, which has as a dense subset the orbit
of a single tensor under a natural group action. We construct polynomial
invariants under this group action whose non-vanishing distinguishes this orbit
from points only in its closure. Together with an explicit subset of the
defining polynomials of the variety, this gives a semialgebraic description of
the tensors of rank $n$ and multilinear rank $(n,n,n)$. The polynomials we
construct coincide with Cayley's hyperdeterminant in the case $n=2$, and thus
generalize it. Though our construction is direct and explicit, we also recast
our functions in the language of representation theory for additional insights.
  We give three applications in different directions: First, we develop basic
topological understanding of how the real tensors of complex rank $n$ and
multilinear rank $(n,n,n)$ form a collection of path-connected subsets, one of
which contains tensors of real rank $n$. Second, we use the invariants to
develop a semialgebraic description of the set of probability distributions
that can arise from a simple stochastic model with a hidden variable, a model
that is important in phylogenetics and other fields. Third, we construct simple
examples of tensors of rank $2n-1$ which lie in the closure of those of rank
$n$.
