Solution (source code)

= Solution

If $x=0$, the generated subspace is zero and invariant. Otherwise, let $r$ be the first index for which $x,Tx,\ldots,T^rx$ are <linearly dependent>. Such an index exists with $1\leq r\leq n$, since there are $n+1$ vectors. The preceding vectors are independent, so the coefficient of $T^rx$ in this first relation cannot vanish. Hence
$$
T^rx\in\operatorname{span}\{x,Tx,\ldots,T^{r-1}x\}.
$$
The <linear operator> $T$ sends each of the first $r-1$ generators to the next and sends the last into their <span>. This proves that their span is an <invariant subspace>. Every later iterate lies in the same subspace by induction, so it equals the span of the first $n$ iterates. Therefore \b[the indicated subspace is $T$-invariant]. This proof of a <cyclic subspace> uses only finite <dimension> and <linear dependence>.