I'm doing some self-study on Hodge theory and elliptic operators right now. I'm trying to come up with an example of a harmonic $p$-form $\omega$ on a compact manifold, i.e. a form such that $d\omega =0$ and $d^* \omega=0$ where $d^*=(-1)^{np+n+1}\star d\star$ and $\star$ is the Hodge star. But I can't seem to find an example of one in any texts or through my own imagination.
Can anyone give me a (nontrivial) example of a harmonic form on a compact manifold?
If you start with a Kahler manifold $X$ of dimension $n$ (that is, a complex manifold equipped with a Hermitian metric $h$ whose associated $(1,1)$-form $\omega := -\operatorname{Im}h$ is $d$-closed), then $\omega^k$ is harmonic for any $k$. This is because $$ * \frac{\omega^k}{k!} = \frac{\omega^{n-k}}{(n-k)!}. $$ For cheap examples of such manifolds, take any hypersurface in a complex projective space defined by a homogeneous polynomial, equipped with the restriction of the Fubini-Study metric.
Alternatively, consider a torus $X = \mathbb{R}^n / \mathbb{Z}^n$ equipped with the flat metric induced by the Euclidean one. The tangent bundle of the torus is trivial, so one gets isomorphisms $$ C^{\infty}\Bigl(X, \bigwedge{}^k\, T_X^*\Bigr) = C^{\infty}(X) \otimes \bigwedge{}^k\, \mathbb{R}. $$ That is, the smooth $k$-forms on $X$ can be viewed as forms $$ u(x) = \sum_{J} u_J(x) dx_{j_1} \wedge \cdots \wedge dx_{j_k}, $$ where $J = (j_1, \ldots, j_k)$ is a multiindex and $u_J(x)$ are smooth functions on the torus (which can be pulled back to smooth functions on $\mathbb{R}^n$). It is illuminating to prove that such a form $u$ is harmonic if and only if all the $u_J$ are constant.
For really fun times, note that the definition of the Hodge $*$ operator doesn't depend on the metric being positive-definite, but only on it being nondegenerate. Consider then the torus $X = \mathbb{R}^2 / \mathbb{Z}^2$ equipped with the metric induced by $$ \begin{pmatrix} 1 & 0 \\ 0 & -1\end{pmatrix} $$ on $\mathbb{R}^2$ and compute what the harmonic forms on it are. Extra points for noticing what about this makes geometers focus on positive-definite metrics.