We have the above relations in Quantum mechanics. Is there a way to implement them and use it in the first line of the below expression and get an aswer as in the second line.

$$\sigma_{z}^{A}|f\rangle =\sigma_{z}^{A}|\downarrow\rangle_{A}+\sigma_{z}^{A}|\uparrow\rangle_{A}$$ $$=-|\downarrow\rangle_{A}+|\uparrow\rangle_{A}$$

  • 1
    $\begingroup$ You can represent $\sigma_z$ as a diagonal matrix with {1,-1} on the diagonal. $\endgroup$
    – yarchik
    Sep 30, 2020 at 6:39
  • $\begingroup$ Just to be completely clear: what exactly is |f>? I guess it's a superposition state? $\endgroup$ Sep 30, 2020 at 9:22
  • $\begingroup$ If> is a superposition state $\endgroup$
    – Jasmine
    Sep 30, 2020 at 10:06

1 Answer 1


First define the operator

sz[state_] := Coefficient[state, "up"] "up" - Coefficient[state, "dn"] "dn"

sz[a "up" + b "dn"]



"up" a - "dn" b

You can use $"|\uparrow \rangle"$ for "up" and $"|\downarrow \rangle"$ for "dn".

This is more of a mathematics solution than mathematica solution which uses the matrix.

up = {1, 0};
dn = {0, 1};
sz = {{1, 0}, {0, -1}};
ceff[x_] = {up.x, dn.x};


y = {a,b};

{1, 0}

{0, -1}

{a, -b}

where the first element is coefficient of up and second element is coefficient of dn state.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.