How to calculate the energy of a spring-mass system considering harmonic oscillation of the normal mode? For a spring-mass system, we know that the potential and kinetic energy are
$$E_p = \frac{1}{2}ku^2 \text{ and } E_k = \frac{1}{2}m\dot{u}^2.$$
where $k$, $m$ and $u$ are the spring constant, mass and the displacement of the mass. If we consider harmonic motion of the normal mode, we have that
$$ u(t) = \hat{u}\, \mathrm{e}^{i\omega t},$$
where $\omega = \sqrt{k/m}$ is the natural frequency. If we substitute this equation into the energy formulas above, we get
$$ E_p = \frac{1}{2}k\hat{u}^2\mathrm{e}^{2i\omega t} \text{ and } E_k = -\frac{1}{2}m\omega^2\hat{u}^2\mathrm{e}^{2i\omega t}. $$
Substituting the natural frequency yields
$$ E_p = \frac{1}{2}k\hat{u}^2\mathrm{e}^{2i\omega t} \text{ and } E_k = -\frac{1}{2}k\hat{u}^2\mathrm{e}^{2i\omega t}. $$
However, this is clearly wrong since the total energy $E=E_p+E_k$ would be zero. Besides, we know that $E$ should be constant over time and equal the maximum kinetic or potential energy ($E =\frac{1}{2}k\hat{u}^2$). What am I doing wrong? How can one calculate the energy of a spring-mass system considering harmonic oscillation of the normal mode?
I don't have a solid background in physics, so, please, be as clear as possible.
Motivation: the question relevancy lies on being able to use Euler's representation to calculate energies. Although the stated problem is simple and could be solved using trigonometric functions, Euler's representation is much more convenient when dealing with complex problems -- such as multi-degree-of-freedom systems -- and the answer to the question could be extended to such problems.
 A: The position of a spring-mass system is real valued function of time, not complex. When you write down the normal mode, you need to specify that you are taking the real part of the complex expression:
$$
u(t) = \text{Re}\left(\hat u e^{i\omega t} \right) = A \cos(\omega t + \delta).
$$
Here, $A = |\hat u|$ is the amplitude of the oscillation and $\delta$ is an unimportant phase shift.
The time derivative of this expression gives
$$
\dot u(t) = \text{Re}\left(i\omega \hat u e^{i\omega t} \right) = - \omega A \sin(\omega t + \delta).
$$
If we compute the potential and kinetic energy using these two expressions we get
$$
E_p = {1 \over 2} k A^2 \cos^2(\omega t+\delta),
~~~~~
E_k = {1 \over 2} m \omega^2 A^2 \sin^2(\omega t+\delta).
$$
Using $\omega^2 = k/m$, the total energy is then
$$
E = E_p + E_k = {1 \over 2} k A^2 (\cos^2(\omega t+\delta)+\sin^2(\omega t+\delta)) = {1 \over 2} k A^2,
$$
which is constant in time, as we expect.
A: It is possible to use Euler's representation, but the general solution comes from a second order differential equation, which requires 2 arbitrary constants.
$$ u(t) = \hat{u}_1\, \mathrm{e}^{i\omega t} + \hat{u}_2\, \mathrm{e}^{-i\omega t}$$
Note that $u(t)$ is real $\implies u = u^* \implies$$\hat{u}_1$ and $\hat{u}_2$ are complex conjugates. What implies that $E_p$ and $E_k$ are also real, and $E$ is real and constant:
$$u^2 = \hat{u}_1^2\, \mathrm{e}^{2i\omega t} + \hat{u}_2^2\, \mathrm{e}^{-2i\omega t} + 2\hat{u}_1\hat{u}_2 = (\hat{u}_1\, \mathrm{e}^{i\omega t} + \hat{u}_2\, \mathrm{e}^{-i\omega t})^2$$
$$\dot{u}^2 = -\omega^2\hat{u}_1^2\, \mathrm{e}^{2i\omega t} - \omega^2\hat{u}_2^2\, \mathrm{e}^{-2i\omega t} + 2\omega^2\hat{u}_1\hat{u}_2 = -\omega^2(\hat{u}_1\, \mathrm{e}^{i\omega t} - \hat{u}_2\, \mathrm{e}^{-i\omega t})^2$$
$$E = E_p + E_k = 2k\hat{u}_1\hat{u}_2 $$
There are 2 particular cases for the phase shift:
When $\hat{u}_1 = \hat{u}_2 = \hat{u}$, they are real:
$u = \hat{u}(\mathrm{e}^{i\omega t} + \mathrm{e}^{-i\omega t}) = 2\hat{u}cos(\omega t)$
When $\hat{u}_1 = -\hat{u}_2$, they are pure imaginary:
$u = -i\hat{u}(\mathrm{e}^{i\omega t} - \mathrm{e}^{-i\omega t}) = 2\hat{u}sin(\omega t)$
For both cases, the constant that multiplies the trigonometric function is $2\hat{u}$, and the energy becomes $$E = 2k\hat{u}_1\hat{u}_2 = 2k\hat{u}^2 = \frac{1}{2}k(2\hat{u})^2$$
A: 
we have that
$$ u(t) = \hat{u}\, \mathrm{e}^{i\omega t},$$

When we write something like this, what we really mean is that the actual displacement is the real part:
$$
u(t) = \Re(\hat u e^{i\omega t})
$$
and we should introduce some new notation for a new complex displacement like:
$$
\tilde u(t) = \hat u e^{i\omega t}
$$
Given the definition:
$$
u(t) = \Re(\hat u e^{i\omega t}) = \frac{1}{2}(\hat u e^{i\omega t} + \hat u^* e^{-i\omega t})
$$
we have:
$$
E_p = \frac{k}{8}\left(\hat u^2 e^{i2\omega t} + {\hat u^*}^2 e^{-i2\omega t} + 2|\hat u|^2\right) = \frac{k}{4}\left(\Re(\hat u^2e^{i2\omega t})+|\hat u|^2\right)
$$
and
$$
E_k = \frac{-\omega^2 m}{8}\left(\hat u^2 e^{i2\omega t} +{\hat u^*}^2e^{-i2\omega t} - 2|\hat u|^2\right) = \frac{\omega^2m}{4}\left(-\Re({\hat u^2e^{i2\omega t}})+|\hat u|^2\right)
$$
Now, with $\omega ^2 m = k$ we have
$$
E = E_k+E_p = \frac{k}{4}2|\hat u|^2 = \frac{1}{2}k|\hat u|^2\;,
$$
as expected.
If we want to emphasize how the fixed total energy E sloshes back and forth between (real) kinetic energy  and (real) potential energy, we could write:
$$
E_k(t) = E/2 -\frac{k}{4}\Re({\hat u^2e^{i2\omega t}})
$$
$$
E_p(t) = E/2 +\frac{k}{4}\Re({\hat u^2e^{i2\omega t}})
$$
