Should the phase coefficients of the DFT of a real, even input signal all be zero? The phase coefficients of a real, even input signals should all apparently be $0$ or a multiple of $\pi$. That's a property of the DFT I've learned about in the Audio Signal processing course on coursera. However, the example they use completely confuses me.

They create a triangle wave that looks like this:



and then showed the phase spectrum to be this:



They explained that this phase spectrum was not zero, because the original triangle function wasn't even because it wasn't centered around zero - it had a phase shift that was messing things up. So they adjusted the positioning of the triangle wave so the peak was at zero, like this:



And the phase spectrum duly went to zero (note the minuscule scale on the $y$-axis)



Bearing in mind I'm new to DSP, the thing that is really confusing is that surely both forms of the triangle wave are even - shifting by half a wavelength just creates another even function, doesn't it? Why must the triangle wave be positioned so the peak is at the center rather than the trough, or vice-versa?
You are right, of course it's not necessary to position the peak of the triangle in the center. The only condition for the DFT of a sequence to be real-valued is that the sequence satisfies

$$x[n]=x^*[N-n],\qquad 0\le n&lt;N\tag{1}$$

where $*$ denotes complex conjugation, and $N$ is the DFT length. If $x[n]$ is real-valued, $(1)$ reduces to

$$x[n]=x[N-n],\qquad 0\le n&lt;N\tag{2}$$

Conditions $(1)$ and $(2)$ require the periodic continuations of $x[n]$ (period $N$) to be even with respect to $n=0$.

From your first figure it appears that your signal satisfies

$$x[n]=x[N-1-n]\tag{3}$$

with $N=15$. Of course this corresponds to a certain symmetry condition, but note that its periodic continuation is not even around $n=0$, as required by $(1)$ and $(2)$.

A simple example of a triangular signal similar to your example but with a purely real-valued DFT (i.e., satisfying $(2)$) is

x = [0 1 2 1]

Its purely real-valued DFT is given by


X = fft(x)
X =

   4  -2   0  -2



What follows is an explanation why the DFT coefficients $X[k]$ are real-valued if (and only if) condition $(1)$ is satisfied. If $X[k]$ is real-valued, we have

$$X[k]=X^*[k]\tag{4}$$

With

$$X[k]=\sum_nx[n]e^{-j2\pi nk/N}\tag{5}$$

where the sum is over one period, i.e., over $N$ adjacent indices, and where we assume that $x[n]$ is continued periodically, such that $x[n]=x[n+N]$. Using Eq. $(5)$ we can write $(4)$ as

$$\begin{align}\sum_nx[n]e^{-j2\pi nk/N}&amp;=\sum_nx^*[n]e^{j2\pi nk/N}\\&amp;=\sum_nx^*[N-n]e^{j2\pi (N-n)k/N}\\&amp;=\sum_nx^*[N-n]e^{j2\pi k}e^{-j2\pi nk/N}\\&amp;=\sum_nx^*[N-n]e^{-j2\pi nk/N}\tag{6}\end{align}$$

where I've used the index transformation $n\rightarrow N-n$, and the fact that $e^{j2\pi k}=1$. From $(6)$, Eq. $(1)$ follows immediately. Note that $(1)$ is dual to the fact that the DFT of a real-valued sequence is conjugate symmetric. In the case we've considered here, we have a conjugate symmetric sequence, leading to a real-valued DFT.