I just came upon this thread and thought it would be worth pointing out that when doing such derivations, one must remember that for the principle of virtual work to be valid, the system must be closed to other forms of energy input. As such, you can't do the derivative with respect to...