-- Exchange energy for two electrons in a box (10 seconds) pi = float(pi) -- use numerical value of pi -- base units ampere = "ampere" kilogram = "kilogram" meter = "meter" second = "second" -- derived units coulomb = ampere second farad = ampere^2 kilogram^(-1) meter^(-2) second^4 joule = kilogram meter^2 second^(-2) volt = ampere^(-1) kilogram meter^2 second^(-3) -- physical constants hbar = 1.054572 10^(-34) joule second -- Planck's constant epsilon0 = 8.854188 10^(-12) farad / meter -- electric constant e = 1.602176 10^(-19) coulomb -- elementary charge me = 9.109382 10^(-31) kilogram -- mass of electron mp = 1.672622 10^(-27) kilogram -- mass of proton eV = 1/e coulomb "eV" / joule -- conversion constant -- numerical integrator N = 100 S(f) = (L/N)^2 sum(j,1,N,sum(k,1,N, test(j == k,0,eval(f,x,(j - 0.5) L/N,y,(k - 0.5) L/N)))) -- position basis for particle in a box phi(n,x) = sqrt(2 / L) sin(n pi x / L) "Length" L = 1.0 10^(-9) meter L -- antisymmetrized wavefunction psi = sqrt(1/2) (phi(1,x) phi(2,y) - phi(2,x) phi(1,y)) "Potential energy" Vhat(psi) = psi e^2 / (4 pi epsilon0 abs((x - y) / meter) meter) f = conj(psi) Vhat(psi) V = S(f) eV V "Classical potential energy" f = conj(phi(1,x) phi(2,y)) Vhat(phi(1,x) phi(2,y)) V0 = S(f) eV V0 "Exchange energy" V - V0