In Hamilton's "on a general method in dynamics", he starts with varying the function ##U## and writes the equation:
$$\delta U=\sum m(\ddot x\delta x+\ddot y\delta y+\ddot z\delta z)$$
Then he defines ##T## to be:
$$T=\frac{1}{2}\sum m (\dot x^2+\dot y^2+\dot z^2)$$
Then by ##dT=dU##, he...