Uploaded by David Buzz

homework5 Mathematica code

advertisement
Verify commutators. Define operators which act on a function f. It’s easiest to actually act on some
function f. So instead of writing [afunc,bfunc], I actually have to write “afunc[bfunc[f[x,y]]]-bfunc[afunc[f[x,y]]]”. Still, if you do it right you can compose functions easily.
In[1]:=
afunc[f_] := 1  Sqrt[2] x f + D[f, x];
adaggerfunc[f_] := 1  Sqrt[2] x f - D[f, x];
bfunc[f_] := 1  Sqrt[2] y f + D[f, y];
bdaggerfunc[f_] := 1  Sqrt[2] y f - D[f, y];
hamiltonian[f_] := 1  2 - D[f, {x, 2}] - D[f, {y, 2}] + x ^ 2 f + y ^ 2 f;
comm[f_, g_] := f[g[h[x, y]]] - g[f[h[x, y]]];
(* verify commutators of H with a *)
Print"{[H,a† a],[H,b† b],[H,b† a]}=" <> ToString[
{Simplify[comm[hamiltonian, adaggerfunc[afunc[#]] &]],
Simplify[comm[hamiltonian, bdaggerfunc[bfunc[#]] &]],
Simplify[comm[hamiltonian, adaggerfunc[bfunc[#]] &]]} ,
InputForm];
(* verify commutators of the spin operators. *)
Lz = adaggerfunc[afunc[#]] - bdaggerfunc[bfunc[#]]  2 &;
Lx = adaggerfunc[bfunc[#]] + bdaggerfunc[afunc[#]]  2 &;
Ly = adaggerfunc[bfunc[#]] - bdaggerfunc[afunc[#]]  I 2 &;
Print["{[Lx,Ly]-I Lz, [Ly,Lz]-I Lx, [Lz,Lx]-ILy}=" <> ToString[
Simplify[{Lx[Ly[f[x, y]]] - Ly[Lx[f[x, y]]] - I Lz[f[x, y]],
Ly[Lz[f[x, y]]] - Lz[Ly[f[x, y]]] - I Lx[f[x, y]],
Lz[Lx[f[x, y]]] - Lx[Lz[f[x, y]]] - I Ly[f[x, y]]}], InputForm]];
Print["{Lx,Ly,Lz} acting on a function f:"];
Print[Simplify @ {Lx[f[x, y]], Ly[f[x, y]],
Lz[f[x, y]]}];
{[H,a† a],[H,b† b],[H,b† a]}={0, 0, 0}
{[Lx,Ly]-I Lz, [Ly,Lz]-I Lx, [Lz,Lx]-ILy}={0, 0, 0}
{Lx,Ly,Lz} acting on a function f:

1
2
1
4
x y f[x, y] - f(1,1) [x, y], -
1
2
ⅈ x f(0,1) [x, y] - y f(1,0) [x, y],
x2 - y2  f[x, y] + f(0,2) [x, y] - f(2,0) [x, y]
Plots.
2
nn = 4;
mm = 0;
L = 4;
Clear[wf];
wf[x_, y_] = 1  Sqrt[2 ^ nn nn !] 1  Pi ^ 1  4 E ^ - x ^ 2  2
HermiteH[nn, x] 1  Sqrt[2 ^ mm mm !] 1  Pi ^ 1  4 E ^ - y ^ 2  2 HermiteH[mm, y];
wf[x_, y_, 0] = N @ wf[x, y];
(* need a large number of steps for accurately calculating E^-I operator *)
nsteps = 2000;
ϵ = NPi  nsteps;
op = adaggerfunc[bfunc[#]] + bdaggerfunc[afunc[#]] &;
(* calculate the exponential of the operator! *)
Do[
wf[x, y, ll] = Simplify[wf[x, y, ll - 1] - I ϵ op[wf[x, y, ll - 1]]], {ll, 1, nsteps}];
wfs[x_, y_] = Table[Abs[wf[x, y, ll]] ^ 2, {ll, 0, nsteps}];
Download