# Interpolating a period-two sequence ($f(x) = f(x-2)$): why $(-1)^x$?

Wolfram|Alpha gives the recurrence equation solution $f(x) = c_2(-1)^x + c_1$.

Why is the interpolating function $(-1)^x$? Other functions like $\cos(\pi x)$ (the real part) and even $\frac{2}{\pi}\cos^{-1}(\cos(\pi x))$ (triangle wave) satisfy the recurrence. Is there a fundamental reason for this or is it just convention? Are other functions ever used?

-

Of course, $\cos(\pi x)$ is just $(-1)^x$ in disguise, at least on the integers. You're right that it's mostly convention, but it's a convention with a purpose behind it; in general, the solutions of any constant-coefficient (linear) recurrence relation $f(x) = a_1f(x-1) + a_2f(x-2) + \ldots + a_nf(x-n)$ can be represented as a sum of exponentials in $x$: $f(x) = c_1r_1^x+\ldots+c_nr_n^x$ , where $r_1, \ldots, r_n$ are the roots of the so-called characteristic polynomial of the recurrence, the polynomial $x^n-a_1x^{n-1}-\ldots-a_{n-1}x-a_n = 0$ (with a minor tweak when the polynomial has a multiple-root). In this case, the characteristic polynomial is $x^2-1$ with roots $\pm 1$, and Alpha writes its solution in this form; $c_11^x+c_2(-1)^x$, and of course the first term is just $c_1$. For more information on this sort of thing, check out the 'homogeneous linear' section of Wikipedia's recurrence relations page.
If you are working over the reals, you can define $f$ to be whatever you want on an interval of length $2$, for example on $[0,2)$. Then $f(x)$ is defined for all $x$. It appears Alpha was taking $x$ to be an integer, in which case you define $f(0)$ and the value at all even numbers is the same, then define $f(1)$ and the value at all odd numbers is the same as that. The Alpha solution just has $f(0)=c_1+c_2, f(1)=c_1-c_2$
From your recurrence, you take characteristic equation $r^2=1$, its roots are $1$ and $-1$, therefore the most general solution ($x$ ranging over the integers) is $f(x) = c_1*1^x + c_2*(-1)^x$. – GEdgar Aug 22 '11 at 15:40