Why fourier transform tell us energy of any frequency of f(t)

It's a simple question, for a function $f(x)$, if it can be write as:

$f(x) = \frac{a}{2} + \sum_{n=1}^{\infty}a_n\sin nx + b_n\cos nx$

from this formula, we can know the energy at frequency $\frac{n}{2\pi}$ it equal to $\sqrt{a_n^2+b_n^2}$.

but for a function $f(t)$. think about its forier transform: $g(\theta)=\int f(t)e^{-i\theta t}dt$

why $g(\theta)$ tell us energy of $f(t)$ at frequency $\frac{\theta}{2\pi}$.

thanks

If $g$ is the Fourier transform of $f$ then $|g(\tau)|^2$ can be interpreted as $energy \ density$ at the frequency $\tau$, which means that the total energy contained in a small frequency interval $[\tau-\epsilon,\tau+\epsilon]$ around $\tau$ is approximatively given by $2\epsilon\thinspace |g(\tau)|^2$.
In signal processing, the energy of a continuous-time signal is defined as the square of its $L^2$ norm. Hence, the spectral energy of this signal is the square of the $L^2$ norm of this signal in the spectral domain, i.e. of its Fourer transform. By Parceval's theorem, these two energies are equal. But as a consequence, $|x(t)|^2$ is the energy density of the signal at the moment $t$, and $|F(x)(\tau)|^2$ is the spectral energy density at the frequency $\tau$.
This is in complete analogue with the discrete case: in your notation, $a_n^2 + b_n^2$ is equal (up to a multiplicative constant) to the square of the absolute value of $\int f(t) e^{-i \theta t} dt$ for $\theta=n$ (for the real-valued $f$).