# Clarification defining/finding the relative phase of a qubit

Let the vector $$|V\rangle = r_0 e^{i\theta_0} |0\rangle + r_1 e^{i\theta_1} |1\rangle$$ correspond to the state of a qubit where $$r_0,r_1,\theta_0,\theta_1 \in \mathbb{R}$$.

According to p. 22 of Quantum Computing: A Gentle Introduction by Rieffel & Polak, the relative phase of $$|V\rangle$$ in this standard basis is the unit modulus complex number $$e^{iX}$$ such that

$$\frac{r_0e^{i\theta_0}}{r_1e^{i\theta_1}} = e^{iX} \frac{|r_0e^{i\theta_0}|}{|r_1e^{i\theta_1}|}.$$

Hence, I derive the relative phase of $$|V\rangle$$ to be $$e^{i(\theta_0-\theta_1)}$$ as follows

$$\frac{r_0e^{i\theta_0}}{r_1e^{i\theta_1}} = e^{iX} \frac{|r_0|}{|r_1|} = e^{iX} \frac{r_0}{r_1}$$

$$\Leftrightarrow e^{iX} = \frac{r_1}{r_0} \cdot \frac{r_0e^{i\theta_0}}{r_1e^{i\theta_1}} = \frac{e^{i\theta_0}}{e^{i\theta_1}} = e^{i\theta_0-i\theta_1} = e^{i(\theta_0-\theta_1)}.$$

However, I have found a few sources stating the relative phase of $$|V\rangle$$ is defined to be $$e^{i(\theta_1-\theta_0)}$$, which is the conjugate of what I derived above using the textbook definition.

Can someone help me make sense of this difference? Is there an error in the textbook definition, or am I making some kind of mistake in my calculation?

As I think about it, I believe either answer would be appropriate depending on which modulus one complex number, either $$e^{i\theta_0}$$ or $$e^{i\theta_1}$$, you factor out of $$|V\rangle$$ to distinguish it from all other vectors equal up to global phase. Could someone confirm? Is there a convention on which phase factor one would factor out?

P.S. I did find a related post here, but it doesn't seem to go into sufficient depth to answer my question. Moreover, the author seems to designate the difference $$\theta_1 - \theta_0$$ or $$\theta_0 - \theta_1$$ as a relative phase as opposed to the entire phase factor $$e^{i(\theta_1-\theta_0)}$$ or $$e^{i(\theta_0-\theta_1)}$$.

TL;DR: It doesn't matter. Both $$e^{i(\theta_0-\theta_1)}$$ and $$e^{i(\theta_1-\theta_0)}$$ are valid.
The textbook is correct and you have made no mistake. Either of the two expressions is appropriate. The notion of relative phase is simply not defined with that fine a level of precision. In fact, we wouldn't want the notion to depend on the implicit order of $$|0\rangle$$ and $$|1\rangle$$, since we'd like it to be valid for any two states in any orthonormal basis, such as $$|H\rangle$$ and $$|V\rangle$$ for light polarization or $$|\text{dead}\rangle$$ and $$|\text{alive}\rangle$$ for Schrödinger's cat, where basis vectors may not be ordered.
Regarding factoring out the global phase, you can factor out any complex number of unit modulus you like. Not just any of the two phases in your state vector, but literally any $$z\in\mathbb{C}$$ as long as $$|z|=1$$. The choice of the global phase is driven primarily by what is convenient for calculations. Sometimes people choose a factor that makes the first amplitude a positive real number (but that is of course ill-defined when the first amplitude is zero or when no order is established among the basis elements).
Expressions such as $$\theta_0-\theta_1$$ or $$\theta_1-\theta_0$$ capture the same underlying idea, though I'd call them relative phase angle to avoid confusion with relative phase. Conflating the two matters little for conceptual understanding, but obviously does matter in calculations.