Since my early studies, I have learned the principle of Newton for the law of dynamics as follows:
$$\sum \vec{F} = m \vec{a}\tag{1}$$ with $\sum \vec{F}$ all the forces applied on the object, $m$ its mass and $\vec{a}$ its acceleration.
Later, after this first version, I have learned another version:
$$\sum \vec{F} = \dfrac{d\vec{p}}{dt}\tag{2}$$ with $\vec{p}$ the momentum which is equal to $\vec{p}=m\,\vec{v}$
With this second form, we have a derivate both on mass and on speed.
I know the first version is not demonstrable (except with Euler-Lagrange equations or maybe Hamiltonian formalism).
But I would like to know how to get the expression of the second version. I ask this because the famous Einstein's formula $E=mc^2$ can be obtained from the second version, i.e $\sum \vec{F} = \dfrac{d\vec{p}}{dt}$ where mass $m$ may not be constant.
Finally, in which context do I have to use the first or the second one?
UPDATE :
Thanks for your answer. However, I don't know how to prove the general form, i.e $\vec{F}=\dfrac{\text{d}\vec{p}}{\text{d}t}$ with Euler-Lagrange equations. With Hamiltonian formalism, I can prove that momentum $\dot p=-\dfrac{\partial H}{\partial q} \equiv -\dfrac{\partial E_p}{\partial q}\equiv F$ (If $\vec{F}$ is only a conservative force).
Then I get the general form : $\dot p = F$, don't I ?
Is it the only way to prove it ?
Regards