Commit 90584877 authored by Timothy Budd's avatar Timothy Budd
Browse files

Some corrections to lecture 7

parent 6442be1c
......@@ -49,13 +49,13 @@
The path-integral formulation has the advantage over canonical quantization, that the variables involved, i.e. the positions $x(t)$ at different times $t$, are regular numbers instead of non-commutative operators. However, we are left with a functional integral that is highly oscillatory and requires a fragile destructive interference of the phases $e^{\frac{i}{\hbar}S}$ to yield a sensible result.
### Correlation functions
The transition amplitude as function of $x_i,x_f$ and $t_i,t_f$ contains all information about the quantum system and is accessible in both frameworks. However, since they play the role as boundary conditions in the path integral, it is not necessarily easy to vary them in practice. Luckily the same information as in the transition amplitude is also available in the collection of **correlation functions** without varying the initial and final state. In canonical quantization a correlation function generally is an expectation value with respect to a fixed state, for instance the ground state $|0\rangle$ of the Hamiltonian, of an operator constructed from $\hat{x}(t)$ at different times, e.g. the two-point correlation function $\langle 0 | \hat{x}(t_2)\hat{x}(t_1) | 0 \rangle$ for $t_2 > t_1$. Given a complete set of eigenstates $|\phi_n\rangle$ with increasing energies $E_n$, $H |\phi\rangle = E_n |\phi_n\rangle$, this is given by
\langle 0 | \hat{x}(t_2)\hat{x}(t_1) | 0 \rangle &= \langle 0 | e^{ i H t/\hbar} \hat{x}(0) e^{-i H t/\hbar} \hat{x}(0) |0 \rangle \\
&= \sum_n \langle 0 | e^{i H t/\hbar} \hat{x}(0) e^{-i H t/\hbar} |\phi_n\rangle\langle \phi_n| \hat{x}(0) |0 \rangle \\
&= \sum_n |\langle 0 | \hat{x}(0) | \phi_n\rangle |^2 e^{-i E_n t/\hbar}. \tag{1}
\langle 0 | \hat{x}(t_2)\hat{x}(t_1) | 0 \rangle &= \langle 0 | e^{ i H t_2/\hbar} \hat{x}(0) e^{-i H (t_2-t_1)/\hbar} \hat{x}(0) e^{-i H t_1/\hbar}|0 \rangle \\
&= \sum_n \langle 0 | \hat{x}(0) e^{-i H (t_2-t_1)/\hbar} |\phi_n\rangle\langle \phi_n| \hat{x}(0) |0 \rangle \\
&= \sum_n |\langle 0 | \hat{x}(0) | \phi_n\rangle |^2 e^{-i E_n (t_2-t_1)/\hbar}. \tag{1}
So we see for instance that the different energy eigenstates can be extracted from Fourier analysis of this correlation function. Correlation functions are particularly natural objects in the path integral as they are computed by simply "putting the observable in the integrand", e.g.
$$C(t_2,t_1) = \frac{\langle x_f, t_f| \hat{x}(t_2)\hat{x}(t_1) | x_i,t_i \rangle}{\langle x_f, t_f|x_i,t_i \rangle} = \frac{1}{\mathcal{Z}}\int_{\substack{x(t_i) = x_i\\x(t_f) = x_f}}[\mathcal{D}x]\,x(t_2)x(t_1) e^{\frac{i}{\hbar}S[x(t)]}, \qquad \mathcal{Z}:=\int_{\substack{x(t_i) = x_i\\x(t_f) = x_f}}[\mathcal{D}x] e^{\frac{i}{\hbar}S[x(t)]}.$$
Note this is not precisely the same correlation as $\langle 0 | \hat{x}(t_2)\hat{x}(t_1) | 0 \rangle$, but if we wish we could obtain the latter by integrating over the boundary conditions. Point is that being able to computer arbitrary correlation functions gives sufficient information, without the need to change boundary conditions.
......@@ -79,14 +79,14 @@
Let us consider the example of a simple harmonic oscillator with potential $V(x) = \frac{1}{2}\omega^2 x^2$. Instead of choosing initial and final boundary conditions in (imaginary) time, it is convenient to choose the time coordinate $\tau$ to be periodic with some period $T$. We therefore obtain the path integral
$$ Z = \int [\mathcal{D}x(\tau)] e^{-\frac{1}{\hbar}S_E[x(\tau)]}, \qquad S_E[x(\tau)] = \int_0^T \mathrm{d}\tau\left(\frac{1}{2} \dot{x}(\tau)^2 + \frac{1}{2}\omega^2 x(\tau)^2\right), \qquad x(T)=x(0).$$
Its two-point correlation function can be related to the canonical quantization via
$$\langle x(s)x(0) \rangle := \frac{1}{Z} \int [\mathcal{D}x(\tau)] x(s)x(0) e^{-\frac{1}{\hbar}S_E[x(\tau)]} = \frac{\mathrm{Tr}[ \hat{x}(s)\hat{x}(0) e^{-T H/\hbar}]}{\mathrm{Tr}[e^{-T H/\hbar}]} = \frac{\sum_n \langle \phi_n |\hat{x}(s)\hat{x}(0)|\phi_n\rangle e^{-T E_n/\hbar}}{\sum_n e^{-T E_n/\hbar}}.$$
If $T (E_2-E_1)/\hbar \gg 1$ and $s \ll T$ then the left-hand side is proportional to $e^{-(E_1-E_0)s}$, so the two-point function $\langle x(s)x(0) \rangle$ should show an exponential decay for small $s$ with rate given by the excitation energy of the simple harmonic oscillator.
If $T (E_1-E_0)/\hbar \gg 1$ and $s \ll T$ then the left-hand side is proportional to $e^{-(E_1-E_0)s}$, so the two-point function $\langle x(s)x(0) \rangle$ should show an exponential decay for small $s$ with rate given by the excitation energy of the simple harmonic oscillator.
In order to simulate this partition function, we need to perform a **lattice discretization**, in a way that is essentially the reverse of what we did above when relating the canonical to path-integral quantization. We only record the position $x_1, x_2,\ldots, x_N = x_0$ on the $N$ sites of a one-dimensional lattice in the time direction and choose a **lattice action** in which the time derivatives are replaced by discrete counterparts,
$$S_E[x] \approx a \sum_{j=1}^{N} \left(\frac{1}{2} \left(\frac{x_{j}-x_{j-1}}{a}\right)^2 + \frac{\omega^2}{2}\left(\frac{x_j+x_{j-1}}{2}\right)^2\right),$$
$$S_E[x] \approx a \sum_{j=1}^{N} \left(\frac{1}{2} \left(\frac{x_{j}-x_{j-1}}{a}\right)^2 + \frac{\omega^2}{2}x_j^2\right),$$
where $a = T / N$ is the **lattice spacing**. We then introduce **dimensionless** parameters $\hat{x}_i = x_i / a$, $\hat{\omega}=\omega a$, $\beta = a/\hbar$. Leading to the Boltzmann distribution in terms of a dimensionless action
$$\pi(\hat{x}) = \frac{1}{Z} e^{-\beta S_L}, \qquad S_L[\hat{x}] = \frac{1}{2} \sum_{j=1}^N \left(\left(\hat{x}_{j}-\hat{x}_{j-1}\right)^2 + \hat{\omega}^2 \hat{x}_j^2\right).$$
This is our desired distribution, in which the analogy with a statistical partition function has been made explicit through the introduction of a fiducial inverse temperature $\beta = a/\hbar$. Now we are in business, because we know how to sample from this distribution using **Metropolis-Hastings**!
Note that in this case $\beta$ does not play any role, as it can be absorbed in a rescaling $\hat{x}_j \to \hat{x}'_j=\hat{x}_j \sqrt{\beta}$, so we can safely set $\beta = 1$. As proposal transition we select a uniform site $t$ and take $\hat{y}_t = \hat{x}_t + U$ and $\hat{y}_j = \hat{x}_j$ for $j\neq t$, where $U$ is uniform on $(-\delta,\delta)$. The result is then accepted with probability
......@@ -100,35 +100,39 @@
rng = np.random.default_rng()
import matplotlib.pylab as plt
%matplotlib inline
def lattice_action(x,omega_sq):
'''Compute lattice action S_L[x] on state x.'''
return 0.5 * ( - np.roll(x,1),x-np.roll(x,1)) + omega_sq*,x) )
def lattice_action_diff(x,t,newx,omega_sq):
'''Compute change in action when x[t] is replaced by newx.'''
w = len(x)
return (x[(t-1)%w]+x[(t+1)%w])*(x[t]-newx) + (1+0.5*omega_sq)*(newx*newx - x[t]*x[t])
# MH implementation
def oscillator_MH_step(x,omega_sq,delta):
'''Perform Metropolis-Hastings update on uniform site with range delta.'''
t = rng.integers(0,len(x))
newx = x[t] + rng.uniform(-delta,delta)
deltaS = lattice_action_diff(x,t,newx,omega_sq)
if deltaS < 0 or rng.uniform() < np.exp(-deltaS):
x[t] = newx
return True
return False
def run_oscillator_MH(x,omega_sq,delta,n):
'''Perform n Metropolis-Hastings moves on state x.'''
total_accept = 0
for _ in range(n):
if oscillator_MH_step(x,omega_sq,delta):
total_accept += 1
return total_accept
def two_point_function(states):
return np.array([np.mean(states * np.roll(states,t,axis=1)) for t in range(len(states[0]))])
'''Estimate two-point correlation <x(s+t)x(s)> from states (averaging over s).'''
return np.array([np.mean(states * np.roll(states,t,axis=1)) for t in range(len(states[0]))])
time_length = 32
omegas = [0.4,0.8,1.2]
delta = 1.8 # chosen to have ~ 50% acceptance
equil_sweeps = 1000
......@@ -173,15 +177,17 @@
%% Cell type:code id: tags:
``` python
def oscillator_heatbath_step(x,sigma):
'''Perform heatbath update on state x.'''
w = len(x)
t = rng.integers(0,w)
x[t] = rng.normal(sigma*sigma*(x[(t-1)%w] + x[(t+1)%w]),sigma)
def run_oscillator_heatbath(x,omega_sq,n):
'''Perform n heatbath updates.'''
sigma = 1/np.sqrt(2+omega_sq)
for _ in range(n):
two_point_funs = []
......@@ -231,39 +237,45 @@
%% Cell type:code id: tags:
``` python
def potential_v(x,lamb):
'''Compute the potential function V(x).'''
return lamb*(x*x-1)*(x*x-1)-x*x
def neighbor_sum(phi,s):
'''Compute the sum of the state phi on all 8 neighbors of the site s.'''
w = len(phi)
return (phi[(s[0]+1)%w,s[1],s[2],s[3]] + phi[(s[0]-1)%w,s[1],s[2],s[3]] +
phi[s[1],(s[1]+1)%w,s[2],s[3]] + phi[s[1],(s[1]-1)%w,s[2],s[3]] +
phi[s[0],s[1],(s[2]+1)%w,s[3]] + phi[s[0],s[1],(s[2]-1)%w,s[3]] +
phi[s[0],s[1],s[2],(s[3]+1)%w] + phi[s[0],s[1],s[2],(s[3]-1)%w] )
def scalar_action_diff(phi,site,newphi,lamb,kappa):
'''Compute the change in the action when phi[site] is changed to newphi.'''
return (kappa * neighbor_sum(phi,site) * (phi[site] - newphi) +
potential_v(newphi,lamb) - potential_v(phi[site],lamb) )
def scalar_MH_step(phi,lamb,kappa,delta):
'''Perform Metropolis-Hastings update on state phi with range delta.'''
site = tuple(rng.integers(0,len(phi),4))
newphi = phi[site] + rng.uniform(-delta,delta)
deltaS = scalar_action_diff(phi,site,newphi,lamb,kappa)
if deltaS < 0 or rng.uniform() < np.exp(-deltaS):
phi[site] = newphi
return True
return False
def run_scalar_MH(phi,lamb,kappa,delta,n):
'''Perform n Metropolis-Hastings updates on state phi and return number of accepted transtions.'''
total_accept = 0
for _ in range(n):
total_accept += scalar_MH_step(phi,lamb,kappa,delta)
return total_accept
def batch_estimate(data,observable,num_batches):
'''Determine estimate of observable on the data and its error using batching.'''
batch_size = len(data)//num_batches
values = [observable(data[i*batch_size:(i+1)*batch_size]) for i in range(num_batches)]
return np.mean(values), np.std(values)/np.sqrt(num_batches-1)
lamb = 1.5
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment