Suppose you have a reasonable continuous function on some interval, say on , and you want to approximate it by a trigonometric polynomial. A straightforward approach is to write

which, frankly, is not a very good deal for the price.

Still using the standard Fourier expansion formulas, one can improve approximation by shifting the function to and expanding it into the cosine Fourier series.

where

Then replace with to shift the interval back. With , the partial sum is

which gives a much better approximation with fewer coefficients to calculate.

To see what is going on, one has to look beyond the interval on which is defined. The first series actually approximates the periodic extension of , which is discontinuous because the endpoint values are not equal:

Cosines, being even, approximate the symmetric periodic extension of , which is continuous whenever is.

Discontinuities hurt the quality of Fourier approximation more than the lack of smoothness does.

Just for laughs I included the pure sine approximation, also with .

Draw a closed curve passing through the points and : more specifically, from (3,0) to (0,1) to (-3,0) to (0,-1) and back to (3,0).

I’ll wait.

… Done?

Okay, you may read further.

This is an interpolation problem. The geometry of the problem does not allow for curves of the form . But polar graphs should work. (Aside: in the variable usually taken to be independent is listed first; in it is listed second. Is consistent notation too much to ask for? Yes, I know the answer…) Since must be -periodic, it is natural to interpolate by a trigonometric polynomial. The polynomial does the job. But does it do it well?

This is not what I would draw. My picture would be more like the ellipse with the given points as vertices:

The unnecessary concavity of the peanut graph comes from the second derivative being too large at the points of minimum (and too small at the points of maximum). We need a function with flat minima and sharp maxima. Here is the comparison between (red) and the function that describes the ellipse in polar coordinates (blue):

I thought of pre-processing: apply some monotone function to the -values, interpolate, and then compose the interpolant with . The function should have a large derivative near , so that its inverse has a small derivative there, flattening the minima.

The first two candidates and did not improve the picture enough. But when I tried , the effect surprised me. Interpolation between yields , which after application of produces — exactly the ellipse pictured above.

Next, I tried a less symmetric example: curve through .

Again, the second approach produces a more natural looking curve.

Finally, a curve with five-fold symmetry, with ranging from to .

The interpolation and plotting were done in Scilab, by invoking the functions given below with commands polar1([3,1,3,1]) or polar2([2,5,2,5,2,5,2,5,2,5]), etc. Because I considered equally spaced interpolation nodes, the coefficients of interpolated polynomials are nothing but the (inverse) discrete Fourier transform of the given values. First function interpolates the radius itself.

function polar1(R)
clf()
p = fft(R,1)
t = 0:.01:2*%pi
rho = zeros(t)
for i = 1:length(p)
rho = rho + real(p(i)*exp(-%i*(i-1)*t))
end
polarplot(t,rho,style=5)
t = resize_matrix(linspace(0,2*%pi,length(R)+1),1,length(R))
plot(R.*cos(t), R.*sin(t), 'o')
endfunction

The second function includes preprocessing: it interpolates and then raises the interpolant to power .

function polar2(R)
clf()
p = fft(R^(-2),1)
t = 0:.01:2*%pi
rho = zeros(t)
for i = 1:length(p)
rho = rho + real(p(i)*exp(-%i*(i-1)*t))
end
rho = max(rho,0.01*ones(rho))
polarplot(t,rho^(-1/2),style=5)
t = resize_matrix(linspace(0,2*%pi,length(R)+1),1,length(R))
plot(R.*cos(t), R.*sin(t), 'o')
endfunction

Added: one more comparison, vs vs ; the last one loses convexity again.