Very precisely explaining when phase plays a role or doesn't play a role in QM My question is probably basic at first view but I would like to really understand this in details.
The way I understand the role of the phase in quantum mechanics is that as soon as we have a physical quantum state: $|\psi\rangle$, multiplying it by $e^{i \phi}$ doesn't change the physical state. We say that the overall phase doesn't play a role.
And for instance, in the state: $|\psi \rangle = |a \rangle + | b \rangle$, I can add a global phase to $|\psi \rangle$, but not to $|a \rangle$ or $|b \rangle$ because then a relative phase might appear between the two and the resulting state would not be the same (excepted, of course, if the same phase is added to both).
But then, how to formalize rigorously the role of phase. When we say "the overall phase" doesn't play a role: overall with respect to what ? Imagine I have the physical state $|\psi \rangle$, I can add a phase to it if I want. But as soon as I imagine creating something like $|\phi \rangle = |\psi \rangle + |\psi' \rangle$ then I cannot do this. And it is a little bit paradoxical because before, I could imagine that I don't know that later on the state $|\phi\rangle$ would be created. So I would add a phase, but I cannot do it...? (I hope I am clear here).
My question is: what is the proper and rigorous way to define things? Do we have to first, separate physical states from mathematical "basis" states? If so, how do we define the physical states? Are they the states of the system we want to describe is in ? And then we say that adding a phase to physical states doesn't play a role in the physics, but not to basis states? But what is a physical state can become a basis state like $|\psi \rangle$ in my example $|\phi \rangle = |\psi \rangle + |\psi' \rangle$
An example of question that disturbs me, let's assume $X$ and $Y$ are two quantum states, I compute $\langle X |Y \rangle$ and I find a complex number. Can I modify the phase of $Y$ so that my number will be positive in the end? Am I allowed to do this? I guess that if $X$ and $Y$ are two physical states I can but not if one of them is a basis state. Which comes back to my question of defining precisely things.
 A: Basis vs not-basis is not the relevant distinction, because any vector can be part of a basis. However, what I think you're getting at, and you're correct, is that you have to separate the physical state from the mathematical ket. This can be hard to understand abstractly, so let's work with wavefunctions on the line. The main points are:

*

*Given some $\psi$, $\psi$ and $e^{i\alpha}\psi$ are different vectors, and they represent the same physical state. The correspondence between physical and mathematical objects is one-to-many.


*Superposition as an operation is defined not on states but on mathematical vectors; I think this is the key confusing point. Given some other function $\phi$, you can't form a superposition between the physical states represented by $\phi$ and $\psi$, because of the phase ambiguity. You have to actually pick a specific function.


*The consequence of this is that even though $\psi$ and $e^{i\alpha}\psi$ represent the same state, $\phi + \psi$ and $\phi + e^{i\alpha}\psi$ do not. You can multiply the whole superposition by a phase, but not the summands.
I think the confusion comes about because we are repeatedly told that two functions related by a constant phase are equivalent, but it is not emphasized that the formalism still requires the use of the functions themselves. $\psi$ and $e^{i\alpha}\psi$ represent the same physical state, but we can't just take them as completely mathematically equivalent. We have to deal with the ambiguity, because, like I said, you take superpositions of functions, not of states.
And yes, you can change the phase of $\langle X | Y \rangle$ at will without changing the physical interpretation of $|X\rangle$ and $|Y\rangle$. But the inner product is a mathematical operation; if you relate it to an observable quantity, the phase will drop out.
A: The easy way:  Just think of choosing a global phase in the same way you think of choosing a zero for potential energy.  You're allowed to set the zero of potential energy to be wherever you want (e.g. for kinematics problems, you might set gravitational potential energy to be zero at ground level), but once you've made a choice you have to be consistent.  You can't have energy be zero at sea level in some places and zero at the bottom of the ocean in others.
In the same way, you can change global phase however you like, but you have to be consistent.  If you add a phase to $| X \rangle$ so it becomes $e^{i\phi} | X \rangle$, then $| Y \rangle $ also must become $e^{i\phi} | Y \rangle$. This answers the last question in the OP, because if $|Y\rangle \rightarrow e^{i\phi} |Y\rangle$, then $\langle Y|\rightarrow e^{-i\phi}\langle Y|$, because bras are conjugates to kets (so the phase is also conjugated).  Hence $\langle Y | X \rangle \rightarrow \langle Y | e^{-i\phi} e^{i\phi} | X \rangle =  \langle Y | X \rangle$ is unchanged.  There is no physical meaning to overall phase.
Actually, the choice of zero of potential energy is closely related to choice of global phase, because if you add some energy offset $E$ to every state, then after time $t$ every state will have an extra (global) phase $e^{iEt/\hbar}$.  So choosing energy offsets and choosing global phases are almost the same thing.

The mathy way:  We usually think of quantum mechanics problems as being represented mathematically in a Hilbert space.  This is not quite accurate.  The real setting for quantum mechanics problems is "ray space", a.k.a. "projective Hilbert space", which is essentially just a mathematical formalization of the notion that global phases don't matter.  The details are pretty straightforward, so I won't repeat them here.  The important point is that quantum mechanics properly "lives" in a space with no notion of global phase at all.  It is usually more convenient to work in the associated Hilbert space, though, and the only price you pay for doing so (with one major exception$^1$) is the global phase ambiguity.
So at the end of the day, the resolution is the same as above: once you've set up your quantum mechanics problem, if you choose to work in Hilbert space instead of ray space, then you have to make a global choice of phase.  You just need to remember to be consistent, so that all states are given the same global phase.


*

*The one catch to working in Hilbert space instead of ray space is when it comes to symmetries.  It turns out ray space allows slightly more general symmetry operations than Hilbert space, and in particular anti-linear operations are allowed.  See Wigner's theorem for more on this.

A: I think you might benefit from an analogy to classical waves. Take light, for example, and imagine the electric field is a continuous sine wave. By itself, it’s phase is not “absolute” because you could define your time $t=0$ to be at any point along the wave, and it would make no difference to any physically measurable property like amplitude, polarization, etc.
Phase matters when you start working with more than one wave because they would then have a physically meaningful phase difference. Mathematically, this would come into play when you are adding or multiplying two or more waves (in an interference or nonlinear mixing experiment, for example). Addition and multiplication operations are not equivalent between cases when the waves are in phase and when they are out of phase:
$$ \sin(\omega t)\cos(\omega t) \ne \sin(\omega t)\sin(\omega t) $$
$$ \sin(\omega t) + \cos(\omega t) \ne \sin(\omega t) + \sin(\omega t)$$
On the other hand, if I’m just measuring the time-average $\langle .\!\rangle$ power of a single light wave, phase doesn’t matter:
$$ \langle \sin(\omega t)^2 \rangle = \langle \cos(\omega t)^2 \rangle = 1/2$$
The thing about quantum mechanics is that physically measurable quantities always involve multiplying wavefunctions (e.g. $\langle \psi |\psi \rangle$ or $\langle \psi | H |\psi \rangle$), so in any case where those waves could be out of phase with each other, phase matters. Of course, it wouldn’t be the case for $\langle \psi |\psi \rangle$, as above, but if $H$ is complex, and in general it is, then phase would matter for $\langle \psi | H |\psi \rangle$.
A: Note: See the comment at the bottom about Projective Hilbert Space.
If $|a\rangle$ is a ket then $e^{i\phi}|a\rangle$ is also a ket. But in general
$$
|a\rangle \neq e^{i\phi}|a\rangle
$$
Also, $\frac{1}{\sqrt{2}}|a\rangle$ is also a ket but in general
$$
|a\rangle \neq \frac{1}{\sqrt{2}} |a\rangle
$$
No one is saying in quantum mechanics that the kets $|a\rangle$, $e^{i\phi}|a\rangle$ and $\frac{1}{\sqrt{2}}|a\rangle$ are equivalent to each other as vectors or kets.
What is going on is that in quantum mechanics, the space of kets is larger (in some sense) than the space of states. In a mathematical sense we might say that a state is an equivalence class on the space of kets.

Suppose we have a Hilbert space $\mathcal{H}$. Let $|a\rangle, |b\rangle \in \mathcal{H}\setminus{0}$ (The Hilbert space excluding the zero vector). Define the equivalence relation $\sim$.
$|a\rangle \sim |b\rangle$ iff there exists a $\phi \in [0, 2\pi)$ such that
$$
\frac{|a\rangle}{\sqrt{\langle a|a\rangle}} = e^{i\phi}\frac{|b\rangle}{\sqrt{\langle b|b\rangle}}
$$
That is, the normalized version of $|a\rangle$ is related only by a phase factor to the normalized version of $|b\rangle$.
We can now define the equivalence class of $|a\rangle$:
$$
\left[|a\rangle\right] = \left\{|b\rangle \in \mathcal{H}\setminus 0: |b\rangle \sim |a\rangle \right\}
$$
That is, the set of all kets $|b\rangle$ that are equivalent to $|a\rangle$ under equivalence relation $\sim$.
We can now define the set of states as
$$
\mathcal{S} = \left\{\left[|a\rangle\right]: |a\rangle \in \mathcal{H}\setminus 0\right\}
$$
That is, the set of states, $\mathcal{S}$ is the set of all equivalence classes within $\mathcal{H}\setminus 0$ under the equivalence relation $\sim$.

Note for example, that
\begin{align}
\left[|a\rangle \right] = \left[e^{i\phi}|a\rangle \right] = \left[\frac{1}{\sqrt{2}}|a\rangle \right]
\end{align}
This is basically the rigorous statement of the physicists claims that "all states must be normalized" and "global phases have no physical meaning".
Example:
\begin{align}
|\psi_1\rangle =& \frac{1}{\sqrt{2}} \left(|a\rangle + |b\rangle \right)\\
|\psi_2\rangle =& e^{i\phi}\frac{1}{\sqrt{2}} \left(|a\rangle + |b\rangle \right)\\
|\psi_3\rangle =& \frac{1}{\sqrt{2}} \left(|a\rangle + e^{i\phi}|b\rangle \right)\\
\end{align}
We can see directly from the definition of $\sim$ above that
\begin{align}
|\psi_1\rangle \sim |\psi_2 \rangle
\end{align}
So this means that
\begin{align}
\left[|\psi_1\rangle\right] = \left[|\psi_2\rangle\right]
\end{align}
That is, even though the kets $|\psi_1\rangle$ and $|\psi_2\rangle$ are not equal, the states that they represent, $\left[|\psi_1\rangle\right]$ and $\left[|\psi_2\rangle\right]$, are equal.
But, because $|\psi_3\rangle$ involves a relative phase we have that in general
\begin{align}
|\psi_3\rangle \nsim |\psi_1\rangle
\end{align}
So in general
\begin{align}
\left[|\psi_3\rangle\right] \neq \left[|\psi_1\rangle\right]
\end{align}
In this case the kets $|\psi_1\rangle$ and $|\psi_3\rangle$ are not equal and the corresponding states $\left[|\psi_1\rangle\right]$ and $\left[|\psi_3\rangle\right]$ are also not equal.
However, all of this is much too verbose for physicists. Physicists commit the usual abuse of notation and simply identify the states $\left[|a\rangle\right] \in \mathcal{S}$ with their representative kets $|a\rangle$ and simply keep in mind the two rules mentioned just above.
So you have to keep in mind, when doing quantum mechanics, whether what you are working with at any given moment is meant to truly represent a state or if you are just manipulating a ket. This might be confusing because the states in quantum mechanics are written in terms of kets.
In reference to the examples above, physicists would simply say that $|\psi_1\rangle$ and $|\psi_2\rangle$ represent the same state (justified by the facts that 1] both kets are normalized and 2] they only differ by a global phase) while $|\psi_3\rangle$ represents a different state even though $|\psi_{1,2,3}\rangle$ are technically kets and not states which are distinguished from eachother in my treatment here.
Furthermore, I'll note that it would be perfectly valid to formulate quantum mechanics wholly in terms of kets (excluding the zero ket because it is weird). In that case we would say states truly are represented by kets. We would just have to alter the Born rule to include an explicit normalization step prior to the calculation of probabilities and we would carry around states $|a\rangle$, $e^{i\phi}|a\rangle$ and $\frac{1}{\sqrt{2}}|a\rangle$ as independent states that just happen to give the exact same results for any physical measurement. Instead, Physicists pseudo-adopt the equivalence relation idea in an intuitive sense but without the formalism. This is because physicists work well off of intuition and are happy to just say all states need to be normalized and states that differ by a global phase are equivalent.
To connect a bit with the OP: What the OP calls physical states I call states and what the OP calls basis states I call kets. I think my language is an improvement here. Especially since the kets we use to describe states do not necessary need to be collected together from any particular basis. I could define a state $|\psi\rangle = |\uparrow\rangle + |+\rangle$ where $|\uparrow$ is a spin up state chosen from the $z$-basis for a spin and $|+\rangle$ is the spin up state in the $x$-basis. The point is that when we write down states we do it using kets.
To answer the question: "My question is: what is the proper and rigorous way to define things?" I think I've given a sufficient answer above in terms of states being represented as equivalence classes on kets.
To answer the question that is the title of this thread: "Very precisely explaining when phase plays a role or doesn't play a role in QM". Kets that differ by a phase factor are indeed different kets. States represented by kets that differ only by a phase factor are NOT different states.
edit: I just looked up the definition of projective Hilbert space which I have redefined here. It looks like we can define it more slickly by defining the equivalence relation as $|a\rangle \sim |b\rangle$ iff there exists any $z \in \mathbb{C}$ with $|a\rangle = z|b\rangle$. This covers the normalization and global phase in one swoop. I'll leave my definition and text above because I think it highlights the point that if we are concerned about putting together kets with different phases to form a state we should also be concerned about putting together kets of different norms to form a state. Of course my answer shows that we do not, in fact, need to be concerned about any of this.
A: An overall phase is a phase that preserves the norm of the vector in Hilbert space. This generalises to inner products being preserved. Quantum states are vectors in Hilbert space and all measurements are ultimately inner products that map vectors in Hilbert space to real numbers. Thus since an overall phase necessarily preserves inner products, the physical measurements are unaffected.
Overall phases are transformations of the following kind:
$$|\psi\rangle\to e^{i\phi}|\psi\rangle$$
As can easily be seen, the norm is preserved.
Now consider that our state is actually a superposition of two different states:
$$|\psi\rangle= c_1|\phi_1\rangle+ c_2|\phi_2\rangle$$
Note that our original state $|\psi\rangle$  is exactly this linear combination of states $|\phi_1\rangle$ and $|\phi_2\rangle$.
Now let’s add arbitrary extra phase to the system:
$$c_1|\phi_1\rangle+ c_2|\phi_2\rangle\to c_1 e^{i\theta_1}|\phi_1\rangle+ c_2 e^{i\theta_2}|\phi_2\rangle $$
The only way we can preserve the inner product, ie get back the original state’s inner product is if $\theta_1=\theta_2$
$$c_1|\phi_1\rangle+ c_2|\phi_2\rangle\to e^{i\theta_1}\Big(c_1|\phi_1\rangle+ c_2|\phi_2\rangle\Big) = e^{i\theta}|\psi\rangle$$
This is an overall phase.


I compute $\langle X |Y \rangle$ and I find a complex number. Can I modify the phase of $Y$ so that my number will be positive in the end?

Any modification to the inner product means that you are changing the state and the two cases correspond to two different physical systems.
Consider the example of the double slit experiment. The phase difference between the two states corresponding to the two different paths is what leads to the interference pattern. Changing the slit width changes introduces an extra phase difference between the paths as compared to our unchanged slit width. This means the interference pattern is altered. Leading to a different physical state.
On the other hand, if we just rotated the whole system by some angle leaving everything else unchanged, then the final pattern is unchanged albeit rotated by an overall angle. This is the effect of the overall phase.

A: There are already so many good answers here, but there are still a few minor things that one can add that may help to clarify the issue.
The purpose of quantum theory is to compute what one would observe in an experiment. Such computations are of the form $\langle \psi | \hat{O} |\psi\rangle$, where $\hat{O}$ is an operator that represents the observable. Already here you can see that a global phase would cancel out and therefore won't have any effect on the result of the calculation.
Due to this purpose for quantum theory, a quantum state is often represented as a density operator. For a pure state it is
$$ \hat{\rho} =  |\psi\rangle \langle \psi |$$
and the observation is now calculated by the trace tr$\{\hat{\rho}\hat{O} \}$.
Note that the global phase would cancel out in the density operator. However, relative phases that exist in the expansion of the ket would remain. One can argue that all physical quantum states can be represented in terms of such density operators and therefore the global phase never makes a physical difference to any observation.
But what about the relative phases? Would a global phase not become a relative phase when a new term is added in the expansion? Here we need to think how nature works. Quantum states evolve according to some unitary process. What this means is that the quantum state lives on a Hilbert space where it can be expanded in terms of the basis of that space. This basis never changes. All that unitary evolution does is to change the weights or coefficients of all the basis elements in the expansion.
It can happen that the unitary evolution would give one basis element a non-zero coefficient after it was initially zero. So then one can think of this element as being added to the expansion. However, the unitarity of the process would require that the coefficients of the other element also change. As a result one would not be able to distinguish the relative phase of the other elements as a global phase of the state before the change. Hope this makes sense.
