Why displacement is not used to calculate average potential energy in SHM? We know that the average potential energy of a body executing simple harmonic motion (SHM) is
$$\frac{1}{4}KA^2$$
where $K$ is the spring force constant and $A$ is oscillation amplitude. This was derived using potential energy as a function of time:
$$U(t) = \frac{1}{2}KA^2 \sin^2(\omega t)$$
If we take $$U(x) = \frac{1}{2} K x^2$$
and find the average potential energy by
$$\frac{\int_{-A}^A{\frac{1}{2}Kx^2dx}}{\int_{-A}^Adx} = \frac{1}{6}KA^2$$
we get completely different result.

My questions are:

*

*Why are we getting different answers on approaching in two different ways?


*Which of them is correct?


*Why the other one is incorrect?
 A: Neither is "correct", or "incorrect". They are simply two different averages with different interpretations. One is the average over space and one is the average over time. We can measure the first by looking at the potential energy of the oscillator when it passes through a series of equally points and taking the average, whilst the second can be measured by taking measuring the potential energy at a series equally spaced intervals in time and averaging.
As to why they are different
$$
\int U(x) \mathrm{d}x = \int U(x(t))\frac{\mathrm{d} x}{\mathrm{d}t}\mathrm{d}t = \int U(x(t))v(t)\mathrm{d}t
$$
So the spatial average has an extra weighting by the velocity compared to the time average. Physically the oscillator is moving faster when it is near the origin, so these points count for less in the time average than the spatial one, whilst the points further out, where the oscillator is moving slowly count for more. Since the oscillator has more potential energy when it is further out the time average is large than the spatial one.
A: One calculation averages over $t$, the other over $x$. When $|x|$ is small, more energy is kinetic, so $\dot{x}$ is greater. Therefore, these two averages are inequivalent. They're both well-defined notions of "average", as are any number of alternatives to taking an arithmetic mean. However, the time-average is usually of interest. This is equivalent to saying $t$, but not $x$, is uniformly distributed over a period.
A: The two integrals do not evaluate to the same value because the velocity is not constant. In a hypothetical situation, if velocity were constant the two averages would evaluate to the same value.
Let the displacement and velocity of the spring be defined as:
$$x(t) = A \sin(\omega t) \quad \text{and} \quad \dot{x}(t) = \omega A \cos(\omega t)$$
where $A$ is amplitude of oscillations and $\omega$ is the oscillation frequency. Note that $\omega = \frac{2\pi}{T}$ where $T$ is the period of oscillations, and $\omega T = 2 \pi$.

In first case the averaging is done in time for one half period:
$$U_\text{av} = \frac{2}{T} \int_{-T/4}^{T/4}{\frac{1}{2} k x(t)^2 dt} = \frac{A^2 k}{T} \int_{-T/4}^{T/4}{\sin^2(\omega t) dt} = \frac{A^2 k}{T} \int_{-T/4}^{T/4}{\frac{1 - \cos(2\omega t)}{2} dt} = $$
$$ = \frac{A^2 k}{2 T} \Bigl. \Bigl( t - \frac{1}{2 \omega} \sin(2\omega t) \Bigr) \Bigr|_{-T/4}^{T/4} = \frac{1}{4} A^2 k$$
You would get the same result if you evaluated the above integral for one full period. Try it!
In second case the averaging is done in distance for one half period:
$$U'_\text{av} = \frac{1}{2A} \int_{-A}^{A}{\frac{1}{2}kx^2 dx} = \frac{k}{4 A} \frac{1}{3} \left. x^3 \right|_{-A}^{A} = \frac{1}{6} A^2 k$$
You could also evaluate the second integral in time as follows:
$$U''_\text{av} = \frac{1}{2A} \int_{-A}^{A}{\frac{1}{2}kx^2 dx} = \frac{1}{2A} \int_{-A}^{A}{\frac{1}{2}kx^2 \frac{dx}{dt} dt} = \frac{1}{2A} \int_{-T/4}^{T/4}{\frac{1}{2}kx(t)^2 \dot{x}(t) dt} = $$
$$ = \frac{A^2 k}{4} \omega \int_{-T/4}^{T/4}{\sin^2(\omega t) \cos(\omega t) dt} = \frac{A^2 k}{4} \frac{\omega}{\omega} \int{u^2 du} = \frac{A^2 k}{12} \left. \sin^3(\omega t) \right|_{-T/4}^{T/4} = \frac{1}{6} A^2 k = U'_\text{av}$$
where the substitution is $u = \sin(\omega t)$ and $\frac{1}{\omega} du = \cos(\omega t) dt$. Ax expected, the result is the same as in $U'_\text{av}$, which makes sense since that was our starting point.
This brings us to the reason why the final result for the two cases is different. If you compare integrals in time, it is obvious that functions under the integral are not the same:
$$\boxed{\frac{2}{T} \int_{-T/4}^{T/4}{ \frac{1}{2} k x(t)^2 dt} \neq \frac{1}{2A} \int_{-T/4}^{T/4}{ \frac{1}{2} k x(t)^2 \dot{x}(t) dt}} \tag 1$$
unless the motion is uniform at constant velocity
$$\dot{x}(t) = \frac{A - (-A)}{\frac{T}{4} - (-\frac{T}{4})} = \frac{4A}{T}$$
in which case the two sides of the Eq. (1) would be equal!! Of course, the constant velocity is only hypothetical scenario, it does not apply to the spring. I just wanted to show where does the difference come from.
A: Multiple people have answered this question, and they are all pretty much correct. All in all, it is a matter of definition how you calculate the "average".
In that sense, we can regard taking "time" as the averaging variable as a convention, and live with that.
But that begs the question... Why the convention?
Since simple harminic motion is, well, simple, we know all its details. Position, velocity, kinetic energy, potential energy... All as a function of time, and position as we please.
Suppose though, we did not know all the details of the system, just a way to observe some properties of it - for the sake of the argument, take the potential energy $U$ as that "property".
How would I calculate the average value of $U$?
I would measure it a few times. If I got the same value, I may provisionally conclude that this is a constant of the system (under some conditions). Then the average is just that constant value. No discussion there.
What if I get different values in each of the measurements? Then I would go the way of measuring $U$ a reasonably large number, and take the average of those measurements. To use the laguage of statistics, I would be sampling $U$ and taking the average of those samples.
If you take the number of samples to infinity (this is now obviously a theoretical construct) I would be constructing the distribution of $U$, and taking a weighted average according to that distribution. So, the more likely a value of $U$ is to occur, the more weight it would get in the averaging.
What am I really averaging over by sampling the same system again and again? It went unmentioned, but our variable here is obviously time since I am sampling the same system at different times.
Averaging over time is also meaningful for all systems - time is always a variable. Time averaging means, "if you measure this many times repeatedly, and average the values, this is what you will get".
Space averaging on the other hand, while valid for this system, is not always possible. Not all systems have such a variable to begin with.
But, for specific purposes, space average of $U$ can also be useful. It is the answer to the question, "If I stop this mass in SHM in different yet random positions repeatedly, and take the average of those values, what will I get?" This obviously depends on the ability to measure $x$ as well as $U$, and therefore dependent on the "internals" of the system.
So, unless it is expressly specified, when we talk about "average $X$" we mean the time average $X$.
I hope that sheds a bit of light on the subject.
