Kapitza pendulum derivation question I'm looking at the Kapitza pendulum solution on Wikipedia and am not sure how the lagrangian was simplified in one of the steps.

Using:
$$\omega = \text{frequency of base oscillations}$$
$$a = \text{amplitude of base oscillations}$$
$$l = \text{length of pendulum}$$
$$\phi = \text{angular displacement}$$
Position of pendulum at given time t:
$$x = l \sin\phi$$
$$y = -l\cos\phi - a\cos(\omega t)$$
Velocity:
$$V_x = \dot{x} = \dot{\phi}l\cos{\phi}$$
$$V_y = \dot{y} = \dot{\phi}l\sin{\phi} + a\omega\sin(\omega t)$$
This gives the energies to be:
$$E_{POT} = -mg(l\cos{\phi} + a\cos(\omega t))$$
$$E_{KIN} = \frac{ml^2}{2}\dot{\phi}^2 + malv \sin(\omega t)\sin(\phi)\dot{\phi} + \frac{ma^2\omega^2}{2}\sin^2(\omega t)$$
$$L = T - U$$
So the unsimplified lagrangian is:
$$L = \frac{ml^2}{2}\dot{\phi}^2 + mal\omega \sin(\omega t)\sin(\phi)\dot{\phi} + \frac{ma^2\omega^2}{2}\sin^2(\omega t) + mg(l\cos{\phi} + a\cos(\omega t))$$
This next step is what confuses me. I understand that the two terms $\frac{ma^2\omega^2}{2}\sin^2(\omega t)$ and $mga\cos(\omega t)$ are removed because of their lack of dependence on either $\phi$ or $\phi \text{ and } t$. But the lagrangian is simplified to this:
$$L = \frac{ml^2}{2}\dot{\phi}^2 + ml(g + a\omega^2\cos(\omega t))\cos\phi$$
How does the unsimplified lagrangian term $$mal\omega \sin(\omega t)\sin(\phi)\dot{\phi}$$ become $$mla\omega^2\cos(\omega t)\cos\phi$$
 A: The Lagrangian of a system isn't unique in general. It's a well-known result that adding a total time derivative of an arbitrary function to a Lagrangian gives the same equations of motion, meaning that if $$\mathcal{L}' = \mathcal{L} + \frac{\text{d}f}{\text{d}t},$$
$\mathcal{L}$ and $\mathcal{L}'$ are physically equivalent. The two terms that you mention at the end of your post are certainly not equal, but they are equal up to a total time derivative and hence one can be substituted for the other, in order to simplify later calculations.
To see this explicitly, observe that the term that you have a problem with is (proportional to):
$$\sin(\omega t)\sin(\phi)\dot{\phi} = -\frac{\text{d}}{\text{d}t}\left( \sin(\omega t) \cos(\phi)\right) + \omega \cos(\omega t) \cos(\phi),$$
a relation you should be able to verify very easily. Thus,
$$mal\omega \sin(\omega t)\sin(\phi)\dot{\phi} = m a l \omega^2 \cos(\omega t) \cos(\phi) + \frac{\text{d}f}{\text{d}t},$$
where $f(\phi,t) = - \sin(\omega t)\cos(\phi)$ in this case. Using the result given above, it should be clear that ignoring the total time derivative will continue to give the same equations of motion. (It's very easy to show that both these terms give the same equation when plugged into the Euler-Lagrange Equations, if you are still unconvinced.)
