Mathematica For Physicists - What is an Expression?

1. Everything’s an Expression

a=my[new[Mathematica[expression,is,great]]]

Head[a]

TreeForm[a]

Level[a,{2}]

b+c

FullForm[b+c]

b=11; c=12;

Plus[b,c]

FullForm[(((d+e f))^2)+g]

TreeForm[(((d+e f))^2)+g]

27.5//Head

3/4//Head

12//Head

point[x,y,z]

Head[point[x,y,z]]

2. Lists and Matrices

myList=List[1,2,3]

secondList={4,5,6}

Part[secondList,2]

secondList[[2]]

secondList[2]

secondList[[0]]

myList//MatrixForm

Dot[myList,secondList]

myList.secondList

myList+secondList

myList secondList

Cross[myList,secondList]

Attributes[Times]

Attributes[Cross]

σ1={{0,1},{1,0}};

σ2={{0,-I},{I,0}};

σ1.σ2-σ2.σ1

σ1 σ2-σ2 σ1

3. Applying Functions

Map[f,g[1,2,3]]

f/@g[1,2,3]

Function[t,NIntegrate[(E^(-(x^2))),{x,0,t}]]/@{1,2,3}

Apply[f,g[1,2,3]]

Apply[Plus,{1,2,3}]

Plus@@{1,2,3}

a

novel@@@a

4. Controlling Evaluation

x=2

Hold[x=2]

x

Hold[x=2]//FullForm

ReleaseHold[Hold[x=2]]

x

Length[ReleaseHold[List@@@Hold[1+2+3+4+5]]]

HoldForm[Cos[π]]