Transformation of Wave function under gauge transformation I am trying to obtain the transformed wavefunction $\psi$ under gauge transformation in the presence of the E-M field. So Schrödinger's equation is (in the units $c=1$ and $\hbar$ = 1)
$$i\frac{d\psi}{dt} = H\psi \text{,} \qquad  \text{where }  H=\frac{(p -qA)^2}{2m} + q\phi.$$
consider the gauge transformation
$$A\rightarrow A + \nabla f, \qquad \qquad   \phi\rightarrow\phi - \frac{df}{dt}.$$
To conserve probability $\psi$ must change only via a phase, I put $\psi\rightarrow\alpha$ $\psi$, where modulus square of $\alpha$ is 1.
Inserting all those transformations in the Schrodinger's equation gives me  (After some simplifications)
$$i\frac{d\alpha}{dt} = -q\alpha\frac{df}{dt} + \alpha (q\nabla f)^2 - \alpha\frac{(p-qA)(q\nabla f)}{m}.$$
Now, How do I proceed further to find $\alpha$, it's evident that I get the standard phase factor, i.e $\alpha$ = $e^{ifq}$ if only all the space-dependent terms vanish, i.e all $\nabla f$  terms vanish, but that doesn't seem right, also it suggests that the transformed $\psi\rightarrow e^{iqf}\psi$ only works for specific cases of function f.
Any suggestions here?
 A: Under a Gauge transformation you have:
$\phi \rightarrow \phi - \frac{\partial f}{\partial t}$
$\vec A \rightarrow \vec A + \nabla f$
And we want to prove that this implements a phase transformation Schrödinger's Equation.
$\psi \rightarrow e^{iqf}\psi$
The time derivative term transforms as:
$i\frac{\partial \psi}{\partial t}
\rightarrow 
-qe^{iqf}\frac{\partial f}{\partial t}\psi
+i e^{iqf}\frac{\partial \psi}{\partial t}$
The first term of this cancels with the change in $\phi$. Now the spatial pieces, for this we need to evaluate:
$(p-qA-q\nabla f)(p-qA -q\nabla f)e^{iqf}\psi$
To evaluate this you need to know that $[G(x),p]=i\nabla G$, to commute the exponential factor with each of the parenthesis (I do assume here that both $A$ and $f$ depend only on coordinates and not on momentum):
$(p-qA -q\nabla f)e^{iqf}=e^{iqf}(p-qA)$
Commuting with the parenthesis one by one you can see that the spatial term transforms as:
$\frac{(p-qA)^2}{2m}\psi\rightarrow e^{iqf}\frac{(p-qA)^2}{2m}\psi$
Which means that Schrödinger's Equations is unchanged.
