I am aware that this question has been asked before, but the answer uses a formula I haven't seen before, and I was wondering if there is another more intuitive way to solve this problem.
I wish to find the Lagrangian of a charged particle ($q$) in a magnetic field $B=\nabla\times A$.
Lorentz force equation gives
$$\begin{align}F=-\nabla V&=q(v\times B)\\
-\frac{\partial V}{\partial x_i}&=q\epsilon_{ijk}\epsilon_{kab}v_j\frac{\partial A_b}{\partial x_a}\\
&=q(\delta_{ai}\delta_{bj}-\delta_{aj}\delta_{bi})v_j\frac{\partial A_b}{\partial x_a}\\
\implies-\nabla_i V&=\nabla_i[q(v\cdot A)]-q(v\cdot\nabla)A_i\\\end{align}$$
So we get $$\nabla[V+q(v\cdot A)]=q(v\cdot \nabla)A$$
I believe the answer is $V=-q(v\cdot A)$, but I don't know how to conclude it from here. It looks like if both sides are $0$, then it could be proved, since we only need to know $V$ up to a constant. But why should either of these sides be zero? How can I finish this?
Edit
After some guidance in the comments by JM1, I have got to the point that $$\nabla[V+q(\dot{x}\cdot A)]=(\dot{x}\cdot\nabla)\frac{\partial}{\partial \dot{x}}[V+q(\dot{x}\cdot A)]\\\implies\left(\nabla-(\dot{x}\cdot\nabla)\frac\partial{\partial \dot{x}}\right)[V+q(\dot{x}\cdot A)]=0$$ I then tried to simplify this operator as follows: $$\frac{\partial}{\partial x_i}-\dot x_j\frac{\partial}{\partial x_j}\frac{\partial}{\partial \dot x_i}=\left(\delta_{ij}-\dot x_j\frac{\partial}{\partial \dot x_i}\right)\frac{\partial}{\partial x_j}=\left(2\delta_{ij}-\frac{\partial}{\partial \dot x_i}(\dot x_j~\cdot)\right)\frac{\partial}{\partial x_j}$$which didn't do much really. It looks really close to finished but I don't see how to finish it. Is it sufficient to say the operator bracket is non-zero, so $V+q(\dot x\cdot A)=0$?