#1: Div, Grad, Curl

Clear["Global`*"]

ϕ=-((x^2)+(y^2)+(z^2));

Plot3D[ϕ /.{z->1},{x,-1,1},{y,-1,1}]

Grad[ϕ,{x,y,z}]

VectorPlot[Grad[ϕ,{x,y,z}][[{1,2}]] //Evaluate,{x,-1,1},{y,-1,1}]

Div[Grad[ϕ,{x,y,z}],{x,y,z}]

Curl[Grad[ϕ,{x,y,z}],{x,y,z}]

v={x,0,0};
Div[v,{x,y,z}]

VectorPlot[{x,0},{x,-1,1},{y,-1,1}]

Grad[Div[v,{x,y,z}],{x,y,z}]

v={y,-x,0};

Curl[v,{x,y,z}]

VectorPlot[{y,-x},{x,-1,1},{y,-1,1}]

Div[Curl[v,{x,y,z}],{x,y,z}]

Grad[Curl[v,{x,y,z}],{x,y,z}]

Curl[Curl[v,{x,y,z}],{x,y,z}]

#2: Branch Cuts

Clear["Global`*"]

Plot3D[Im[(x+I y)^(1/2)],{x,-4,4},{y,-4,4}]

p2=Plot[Im[(x+I y)^(1/2)] /.{y->{+0.001,-0.001}}//Evaluate,{x,-4,4}]

p3=Plot[Im[(x+I y)^(1/3)] /.{y->{+0.001,-0.001}}//Evaluate,{x,-4,4}]

Show[p2,p3]

3D Plots of Complex Functions

Plot3D[Im[Sqrt[x + I y]],{x,-4,4},{y,-4,4}]

Plot3D[Im[Sqrt[x + I y]],{x,-4,4},{y,-4,4}, Lighting->Automatic]

Plot3D[Im[(x + I y)^(1/3)],{x,-4,4},{y,-4,4}]

ParametricPlot3D[
    {r Cos[theta]
    ,r Sin[theta]
    ,Im[(r Exp[I theta])^(1/4)]}
,{r,0,4}
,{theta,-Pi+0.0001, Pi-0.0001}
,Boxed->False
,BoxRatios->{1,1,0.4}]

Plot[
{Im[(-r Exp[I theta])^(1/4)] /.{theta->(π/2+0.0001)},
Im[(-r Exp[I theta])^(1/4)] /.{theta->(-π/2-0.0001)}}
,{r,0,-4}]

ParametricPlot3D[
    {r Cos[theta]
    ,r Sin[theta]
    ,Im[Sqrt[r Cos[theta] + I r Sin[theta]]]}
,{r,0,4}
,{theta,-Pi+0.0001, Pi-0.0001}
,Boxed->False
,BoxRatios->{1,1,0.4}]

ParametricPlot3D[
    {r Cos[theta]
    ,r Sin[theta]
    ,Re[Sqrt[r Cos[theta] + I r Sin[theta]]]}
,{r,0,4}
,{theta,-Pi+0.0001, Pi-0.0001}
,Boxed->False
,BoxRatios->{1,1,0.4}]

?Ticks

Plot[{ArcSin[x],ArcCos[x]},{x,-1,1},Ticks->{Automatic,Table[z,{z,-π,π,(π/4)}]},GridLines->{Automatic,Table[z,{z,-π,π,(π/4)}]}]

Solve[ (x+ I y )^2 == 2 I x && {x,y}∈Reals,{x,y}] //Simplify

#3: Matrix

Clear["Global`*"]

mat={{0,1/2,(Sqrt[3])/2},{1,0,0},{0,(Sqrt[3])/2,-1/2}};
mat //MatrixForm

Eigenvalues[mat]

evec=Eigenvectors[mat];
 evec//MatrixForm

mat.evec[[1]] ==evec[[1]]

Tr[mat]

sum=1 + Exp[+ I θ] +Exp[- I θ] //ExpToTrig

eq= Tr[mat] == sum

Solve[eq,θ]

#4: Matrix

Clear["Global`*"]

mat={{3,0,0},{0,2,1},{0,1,2}};
mat //MatrixForm

Eigenvalues[mat]

evec=Eigenvectors[mat];
 evec//MatrixForm

evec2  = Normalize /@ evec;
evec2 //MatrixForm

Transpose[evec2].evec2 //MatrixForm

Transpose[evec2].mat.evec2 //MatrixForm

{e1,e2,e3}=evec  //Transpose//Thread

evec3= Normalize /@{e2,e1,e3}

Transpose[evec3].evec3 //MatrixForm

Transpose[evec3].mat.evec3  //Simplify//MatrixForm

{e1.e2,e2.e3,e3.e1}

mat.evec[[1]] ==evec[[1]]

Tr[mat]

sum=1 + Exp[+ I θ] +Exp[- I θ] //ExpToTrig

eq= Tr[mat] == sum

Solve[eq,θ]

#4: OLD

Clear["Global`*"]

rotx={{1,0,0},{0,Cos[θx],+Sin[θx]},{0,-Sin[θx],Cos[θx]}};
rotx //MatrixForm

rotx /.{θx->π/3}

mat= {{0,(1/2),((Sqrt[3])/2)},{1,0,0},{0,((Sqrt[3])/2),((-1)/2)}};
Det[mat]
mat //MatrixForm

mat

Transpose[mat].mat

Eigenvalues[mat]

Eigenvectors[mat]

test={(Sqrt[3]),(Sqrt[3]),1};
mat.test

vec={x,y,z};
unit=DiagonalMatrix[{1,1,1}];

unit

eq= mat.vec== unit.vec //Thread

sol=Solve[eq,{x,y,z}]

evec=vec /.sol[[1]] /.{x->1}

mat.evec //Simplify

#1: Pauli Matrices

xxx

Clear["Global`*"]

Clear[conjugate]
conjugate[mat_]:=mat/. {Complex[a_,b_] :> Complex[a,-b]}

a + I b  //Conjugate

a + I b //conjugate

x rotation

s0={{1,0},{0,1}};
s1={{0,1},{1,0}};
s2=I{{0,-1},{1,0}};
s3={{1,0},{0,-1}};

MatrixForm /@{s1,s2,s3}

vec=x s1+y s2+z s3;
vec //MatrixForm

vec1 ==( vec //MatrixForm)

zrot=s0+((I θ)/2)s3;
zrot //MatrixForm

zrotCT=zrot //conjugate //Transpose;
zrotCT //MatrixForm

(zrotCT.zrot //Expand) /.{(θ^2)->0} //MatrixForm

tmp= (zrotCT.vec.zrot //Expand) /.{(θ^2)->0};
tmp //MatrixForm

tmp-vec  //MatrixForm

vec //MatrixForm

(zrotCT.vec.zrot //Expand)  //MatrixForm