# Quantum Mechanics operators

$$\sigma_{z}^{A}|\downarrow\rangle_{A}=-|\downarrow\rangle_{A}$$

$$\sigma_{z}^{A}|\uparrow\rangle_{A}=|\uparrow\rangle_{A}$$

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}$$

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

First define the operator

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

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


"up"

-"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};

ceff[sz.up]
ceff[sz.dn]

y = {a,b};
ceff[sz.y]


{1, 0}

{0, -1}

{a, -b}

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