# Minimal coupling in Dirac equation

In the framework of relativistic quantum mechanics (not QFT) the Dirac equation in presence of external electromagnetic field is obtained by means of the minimal coupling, i.e. the substitution:

$$p_{\mu} \rightarrow p_{\mu}-eA_{\mu}$$

This substitution is often motivated by saying that it "ensures gauge invariance of the theory" (Greiner "Relativistic quantum mechanics", page 121). The resuting "modified" Dirac equation is:

$$i\frac{\partial\psi}{\partial t}=\left( \vec{\alpha} \left( \vec{p}-e\vec{A} \right)+\beta m + e \phi\right)\psi$$ This equation seems to change if one changes the 4-potential by a gauge transformation $$A_{\mu}\rightarrow A_{\mu}+\partial_{\mu}\Lambda$$. So what does it mean that the minimal coupling ensures gauge invariance? What am I missing?

You are missing the phase transformation of $$\psi$$.
The Dirac equation is indeed not invariant to the gauge transformation $$A_{\mu}\rightarrow A_{\mu}+\partial_{\mu}\Lambda$$ alone.
But it is invariant to the combined gauge/phase transformation \begin{align} A_{\mu}&\rightarrow A_{\mu}+\partial_{\mu}\Lambda \\ \psi &\rightarrow \exp\left(-\frac{ie\Lambda}{\hbar}\right)\psi \end{align}
You are missing the fact that a gauge transformation transforms $$\psi$$ as well. It changes the complex phase of the spinor at each point in spacetime. See if you can figure out how much of a phase change will leave the equation unchanged.
It’s this local phase change of the matter field that explains why the gauge group for electromagnetism is called $$U(1)$$.