This question is about understanding the basic ideas behind gauge transformations as I am fairly new to this!
I learned that the Hamiltonian is invariant under global U(1) gauge transformations $\Psi\rightarrow e^{i\lambda}\Psi$, which makes sense, as the phase factors just cancel out on both sites of the Schrödinger equation:
$\hat{H}e^{i\lambda}\Psi=Ee^{i\lambda}\Psi$
Now, am I save to say that the Hamiltonian is, quite generally, not invariant under local U(1) gauge transformations $\Psi\rightarrow e^{i\lambda(x)}\Psi$ (just looking at one spatial dimension for simplicity)? My thinking is that the derivatives from the Hamiltonian act on $\lambda(x)$ like
$\partial_x (\partial_x e^{i\lambda(x)})=i\lambda''e^{i\lambda(x)}-(\lambda')^2 e^{i\lambda(x)}$
which is responsible for the invariance.
Is that correct or did I get the whole concept of gauge transformations wrong and the Hamiltonian is, in fact, invariant under both local and global U(1) gauge transformations?