Lagrangian in presence of an Electromagnetic Field Given the following definition of the Magnetic Vector Potential $\vec{A}$:
$$\vec{A} \ \mid \ \vec{B}=\vec{\nabla}\times\vec{A}$$
We can derive (but I don't know how) that the Lagrangian in presence of an electromagnetic field is:
$$\mathcal{L}=K-V=\frac{1}{2}mv^2-q\Phi+q\vec{v}\cdot\vec{A} \tag{1}$$
where $K$ is the kinetic energy and $V$ is the potential energy. The Lagrangian is by definition the difference between $K$ and $V$, but $q\Phi$ is of course the potential energy of the electric field, this must mean that:
$$-q\vec{v}\cdot\vec{A} \tag{2}$$
is the potential energy of the magnetic field. I now have two distinct but related problems:

*

*How can we prove that (2) is the potential energy of the magnetic field?1

*How can we prove that (1) is the correct formula for the Lagrangian in presence of an electromagnetic field?

Of course, these two questions are strongly linked: if you answer one of them you have also basically answered the other one.2
All this seems to me a really important and fundamental problem. But, paradoxically, I have not found any source providing a direct, simple and complete answer to it; that's what I am searching here.

[1]: Seems impossible to me to prove such a statement; because I think the statement itself is wrong. The magnetic field has non-zero curl: shouldn't this mean that its potential energy is not definable?
[2]: There is also the possibility that the second question can be answered without proving the first statement true. Maybe (2) is not the magnetic potential energy, but also (somehow) $q\Phi-q\vec{v}\cdot\vec{A}$ is the total electromagnetic potential energy of an electromagnetic field; in this case, I would like to understand how to prove it.

Edit: In response to mike stone's comment and Emmy's answer: In my textbook the Lagrangian, in the context of non-relativistic mechanics, is defined as:
$$\mathcal{L}=K-V$$
but not only on my textbook! Take a look at this section in the related wikipedia page: citing directly:

It is nevertheless possible to construct general expressions for large classes of applications. The non-relativistic Lagrangian for a system of particles can be defined by
$$L=T-V$$

Is this wrong? Seems strange.
Also: if the Lagrangian is indeed any function that gives back the correct Newtonian equations of motion once put into the Euler-Lagrange equations then why use the lagrangian formalism in the first place? The beauty of this formalism is that by knowing the energies we can derive the equation of motion; if this does not hold, at random, then I am forced to remember the arbitrary correct form of the Lagrangian in every given case or to derive it every time from Newtonian mechanics, that is not easy to do and also seems to kill half the purpose of the Lagrangian formalism.
 A: Question 1 : you should not try to interpret this Lagrangian as kinetic energy - potential energy. In fact, the magnetic part of the Lorentz force does not come from a potential; there is no potential energy associated with the charge in the magnetic field.
Question 2 : to prove that this is the right Lagrangian, it is enough to observe that the corresponding equations of motion give you back Newton's law with Lorentz's force.
A: You are right, $(2)$ is not the potential energy of the magnetic field. In fact, there is no potential energy linked to the magnetic field, since the magnetic force does no work as it is perpendicular to displacement. The Lagrangian not always is the difference between kinetic and potential energy, and this is a clear example of this. The potential energy $V$ is just $q\Phi$.
Some other times, the Lagrangian can be constructed as $L=T-U$, where $U$ is a generalized potential related to its generalized force this way
$$Q_i=\frac{d}{dt}\left[\frac{\partial U}{\partial \dot{q}_i}\right]-\frac{\partial U}{\partial q_i}.$$
In cartesian coordinates, $Q_i=F_i$, so it can bee seen that if $U=q(\Phi-\dot{\vec{x}}\cdot\vec{A})$
$$F_i=\frac{d}{dt}\left[\frac{\partial U}{\partial \dot{x}_i}\right]-\frac{\partial U}{\partial x_i}$$
reproduces the Lorentz force.
The only way to see that $(1)$ is the correct Lagrangian for a particle in an electromagnetic field is that its Euler-Lagrange equations reproduce the known equations of motion
$$m\ddot{\vec{x}}=q(\vec{E}+\dot{\vec{x}}\times\vec{B}).$$
If you computed the Hamiltonian, it would be $$H=\frac{p^2}{2m}+q\Phi=T+V=E\neq T+U$$
