What is the reason for these jiggles when truncating infinite series? Plotting the series $$\displaystyle y = \sum_{k} \frac{\sin kx }{k}$$
In the limit it would look like 

Taking a finite number of terms, I want to understand what is the reason for the jiggling at the extremes, while there the jiggling in the middle is so small its not noticable.

I truncated the sum to $1,2,3\; \mbox{and}\;4$ terms but cannot deduce much of a reason.

The "jiggling" was noticeable here because the sum is linear in the limit, however, for an expression like $$p(x) = x\prod_k\Big(1-\frac{x^2}{k^2\pi^2}\Big) $$
Does the truncated expression oscillate back and forth the limit?
 A: As Qiaochu Yuan commented, this is called the Gibbs phenomenon.  It happens at discontinuities because of the behavior of the Dirichlet kernel
$$
D_n(x)=\sum_{k=-n}^{n}e^{ikx}=\frac{\sin((n+\frac{1}{2})x)}{\sin(\frac{x}{2})}
$$
When you truncate the Fourier series of a function, $f(x)$, at the $n^{th}$ term, you get back that function convolved with the Dirichlet kernel
$$
D_n*f(x)=\int_{-\pi}^\pi f(y) D_n(x-y) dy
$$
Here are plots of the Dirichlet kernel for $n=3$ and its integral.

Note how the integral goes from $0$ to $1$, but it wiggles because of the wavy nature of the Dirichlet kernel.  This wiggle is the root of the Gibbs phenomenon.  As $n\to\infty$, the kernel approaches a periodic Dirac delta distribution and its integral has a steeper slope and smaller (but tighter and more numerous) wiggles.
A: It happens that in this case, the reason becomes physically obvious if you look at it the right way. Focus on the truncated portion...the part you are throwing away. In the case of sin(kx)/k, if k is 100 or more, you effectively have a whole bunch of equal sine waves with slightly different frequencies, all in phase at a single point. It is pretty clear that this sum resonate strongly when the waves are in phase, and gradually fade to zero as they go out of phase.
If you believe that the Fourrier series adds up to what it's supposed to, then it's pretty clear that when you take away the very high frequency residue, you should expect this ringing effect around the sharp corners.
