One may describe the field of an undulator in the so-called Halbach representation as

(1)
\begin{align} B_x = \sum_i \frac{k_{xi}}{k_{yi}}B_i \sinh(k_x x)\sinh(k_y y) \cos(k_i z) \end{align}
(2)
\begin{align} B_y = \sum_i B_i \cosh(k_x x)\cosh(k_y y) \cos(k_i z) \end{align}
(3)
\begin{align} B_z = -\sum_i \frac{k_{i}}{k_{yi}}B_i \cosh(k_x x)\sinh(k_y y) \sin(k_i z) \end{align}

The angular flux density distribution for a planar undulator is

(4)
\begin{align} \frac{d^2N_0}{d\Omega \frac{d\omega}{\omega}} = \alpha N^2\gamma_0^2 K^2 \xi^2\left[J_{\frac{n+1}{2}}(K^2\xi/4)-J_{\frac{n-1}{2}}(K^2\xi/4)\right]^2 \end{align}
(5)
\begin{align} \xi=\frac{n}{1+K^2/2} \end{align}

In Wu, Forest, Robin, Explicit symplectic integrator for s-dependent static magnetic field,
PHYSICAL REVIEW E 68, 046502 2003,
The field is represented via the vector potential $\vec a = \frac{q \vec A}{P_0 c}$

(6)
\begin{align} a_x = \sum_{m,n} D_{mn} \cos(k_x l x) \sin(k_{zn} z+\theta_n) \end{align}
(7)
\begin{align} a_y = \sum_{m,n} D_{mn} \frac{k_{xl}}{k_{mn}} \sin(k_{xl} x) \sinh(k_{ym}y) \sin(k_{zn} z+\theta_n) \end{align}

# Coherence

— Transverse Coherence length —-
Coisson (1995) gives the coherence factor (eq. 26) of

(8)
\begin{align} s_c = \frac{1}{\left(\sigma^2 +\frac{1}{2R^2}-\frac{1}{2R^2+4s^2}\right)^{1/2}} \end{align}

Elleaume (text) gives (p 66)

(9)
\begin{align} \Delta = 2\frac{\Sigma}{\sqrt{(4\pi E/\lambda)^2-1}} \end{align}

Limborg gives:

(10)
\begin{align} \frac{\lambda R}{d_s} \end{align}

for transverse. R is the distance to the source and d_s is the source size. And

(11)
\begin{align} \frac{\lambda^2}{2\delta\lambda} \end{align}

for the longitudinal.

The energy of the nth harmonic coming out of the undulator is

(12)
\begin{align} E_n = \frac{0.95 E^2 n}{\lambda_u(1+\frac{K^2}{2}+\gamma^2\theta^2)} \end{align}

# Polarization

A completely polarized beam is characterized by a Jones vector.
A partially polarized beam can be represented by a coherency matrix or Stokes vector.
The coherency matrix is given by (from lecture by Detlefs)

(13)
\begin{align} \rho = \frac{I}{2}(1+\sigma\cdot \vec P) \end{align}
(14)
\begin{align} I = Tr(\rho) \end{align}
(15)
\begin{align} P_i = \frac{1}{I}Tr[\sigma_i \cdot \rho] \end{align}