# Bra's and Ket's - State superpositions, functional states?

Lets say I have a Bloch sphere, where I can represent states as

• $|0\rangle$ or $|1\rangle$ in the Z basis,
• $|+\rangle$ or $|-\rangle$ in the X basis, or
• $|+i\rangle$ or $|-i\rangle$ in the Y basis

Here you can think of the X and Y states as superpositions with a complex phase of the first two {0,1} states.

If I was in the 2D case where I only consider the Z,X basis', then it's conventent to be able to write a Mathematica state as:

$|\Phi (\theta \_)\rangle \text{:=}|1\rangle \sin \left(\frac{\theta }{2}\right)+|0\rangle \cos \left(\frac{\theta }{2}\right)$

Ket[Φ (θ_)] :=  Cos[θ/2] Ket[0] + Sin[θ/2] Ket[1]


This works fine, and use it functionally, ie. $|\Phi\left(\frac{\pi }{4}\right)\rangle$, or Ket[\[CapitalPhi] (\[Pi]/4)] gives back the state as I want it, $|1\rangle \sin \left(\frac{\pi }{8}\right)+|0\rangle \cos \left(\frac{\pi }{8}\right)$.

However, when trying to expand to include the third Y basis, the functional form doesn't seem to be able to be defined in the same way, ie:

$|\psi(\phi \_,\theta \_)\rangle \text{:=}|0\rangle \cos \left(\frac{\theta }{2}\right)+|1\rangle e^{i \phi } \sin \left(\frac{\theta }{2}\right);$

Ket[ψ (ϕ_, θ_)] := Cos[θ/2] Ket[0] + E^(I ϕ) Sin[θ/2] Ket[1];


How can I allow this functional ket to take two arguments?

Note, I have found how you can define operations between these states, which is extremely useful notation!

• I would define \[Psi][\[Phi]_, \[Theta]_] = Cos[\[Theta]/2] Ket[0] + E^(I \[Phi]) Sin[\[Theta]/2] Ket[1] (and similarly for the other case). – b.gates.you.know.what May 22 '18 at 8:54
• Yes, I think this is actually what I meant haha - but for some reason the curly brackets still work for the singular case. Neither curly nor square brackets work for two variables. You can use the form \ket[\[Psi]] [\[Phi]_, \[Theta]_] = ... which I guess might be as close as I get? – Mr G May 22 '18 at 11:22
• Ket[\[Psi][\[Phi]_, \[Theta]_]] := Cos[\[Theta]/2] Ket[0] + E^(I \[Phi]) Sin[\[Theta]/2] Ket[1] seems to work just fine for me. What problems are you having with that? Be sure to try it in a fresh kernel. – Sjoerd Smit May 22 '18 at 15:23

The use of circular brackets is not the correct syntax for Mathematica functions.

Consequently, both forms,

$$|\psi[\phi\_,\theta\_]\rangle = \cos\left[\frac{\theta}{2}\right]|0\rangle + e^{i\phi}\sin\left[\frac{\theta}{2}\right]|1\rangle$$

\ket[\[Psi]] [\[Phi]_, \[Theta]_] = Cos[\[Theta]/2] Ket[0] + E^(I \[Phi]) Sin[\[Theta]/2] Ket[1]


and

$$|\psi\rangle[\phi\_,\theta\_] = \cos\left[\frac{\theta}{2}\right]|0\rangle + e^{i\phi}\sin\left[\frac{\theta}{2}\right]|1\rangle$$

Ket[\[Psi][\[Phi]_, \[Theta]_]] := Cos[\[Theta]/2] Ket[0] + E^(I \[Phi]) Sin[\[Theta]/2] Ket[1]


work fine for defining ket's as functional states.

Credit to @Sjoerd Smit and @b.gatessuck in comments.
{"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": 1, "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, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7795441150665283, "perplexity": 3435.5960676577843}, "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": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-45/segments/1603107919459.92/warc/CC-MAIN-20201031151830-20201031181830-00485.warc.gz"}