# Convert state Vectors to Bloch Sphere angles

I think this question is a bit low brow for the forum. I want to take a state vector $\alpha |0\rangle + \beta |1\rangle$ to the two bloch angles. What's the best way? I tried to just factor out the phase from $\alpha$, but then ended up with a divide by zero when trying to compute $\phi$ from $\beta$.

-

1
This question should be migrated to physics.sx – Frédéric Grosshans May 4 '12 at 19:37

2
– Piotr Migdal May 8 '12 at 7:05

1
You have asked 13 questions, cast 0 votes, and marked only one question as accepted. Consider marking more questions as correct and definitely start voting on answers to your own questions, as well as other questions and answers that you have not provided. There is little incentive for anyone to answer your questions as it stands. – Mark S. Everitt May 10 '12 at 4:24

2
Sure, Ill do that more. I didnt understand that I could give back to people answering simply by upping their numbers. I like the community and will try to do better as a member – Ben Sprott May 17 '12 at 15:10
No problem. It can take a while to find your feet on SE. Sometimes we just need to make a little noise. ;) – Mark S. Everitt May 18 '12 at 9:08

## 2 Answers

You are probably dividing by $\alpha$ at some point to eliminate a global phase, leading to your divide by zero in some cases. It would be better to get the phase angles of $\alpha$ and $\beta$ with $\arg$, and set the relative phase $\phi=\arg(\beta)-\arg(\alpha)$. Angle $\theta$ is now simply extracted as $\theta = 2\cos^{-1}(|\alpha|)$ (note that the absolute value of $\alpha$ is used). This is all assuming that you want to get to

$$|\psi\rangle = \cos(\theta/2)|0\rangle + \mathrm{e}^{i\phi}\sin(\theta/2)|1\rangle\,,$$

which neglects global phase.

-

1
Your previous questions suggest that you are using Matlab, which has the `angle()` function for calculating `arg`. In other languages that support complex types, `arg` (or something similar such as `carg` for C99 complex doubles) is more common. – Mark S. Everitt May 10 '12 at 4:21

$\phi$ is the relative phase between $\alpha$ and $\beta$ (so the phase of $\alpha/\beta$). You will only get zero or divide-by-zero when $\alpha=0$ or $\beta=0$. But in that case, $\phi$ is arbitrary. And when $\alpha$ or $\beta$ are close to zero, you are near the poles of the Bloch sphere, and $\phi$ doesn't really matter that much.

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 22, "mathjax_display_tex": 1, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9662218689918518, "perplexity_flag": "middle"}