Defining Variables and Functions

Variables

x=2

x

y=3

x+y

x*y

x/y

N=6.02*^23

L=6.02*^23

2 x-3 y

c=Sqrt[x^2+y^2]

N[%]

Clear[x]

x

x=4

4

c=5

ArcCos[(x^2+y^2-c^2)/(x^2+y^2)]

Functions

defining a function f[x] = x^2

f[x_]:=x^2

f[5]

f[a+2]

defining the Einstein temperature theta = h*nu (in wavenumber) / k

h=6.626*^-34

k=1.381*^-23

c=2.998*^10

theta[nu_]:=h*c*nu/k

theta[1000]

theta[50]

defining formula for molar volume: Vm (L) = RT(K)/P(atm)

gasconst=0.0821

vm[t_,p_]:=gasconst*t/p

vm[300,1]

vm[273.15,1]

defining a function recursively

g[1]=1

g[n_]:=n g[n-1]

g[10]

10!

defining the Hermite polynomial

h[0]=1

herm[0]=1

herm[1]=2 y

Clear[y]

herm[1]=2y

herm[v_]:=2 y herm[v-1]-2 (v-1) herm[v-2]

herm[2]

herm[3]

Expand[%]

hy[y_]=herm[3]

hy[1]

Plot the v=3 wavefunction of a 1-D harmonic oscillator

psi3[y_]=Exp[-y^2/2] hy[y]

Plot[psi3[y],{y,-4,4}]

ChemicalData["Phenol"]

ChemicalData["Phenol","MolecularWeight"]

ChemicalData["Caffeine","MoleculePlot"]