# Iteration of the function $d(n)=a-n$

I start by defining the function $f$

$$f(0)=0,~~~~~f(n+1)=d(f(n))=a-f(n)$$

So:

$$f(n)=d^{\circ n}(0)$$

$f(1)=a-0=a$

$f(2)=a-(a-0)=0$

$f(3)=a-(a-(a-0))=a$

How can I find the solution of $f(x), x\in\mathbb R$?

I notice that:

$$f(n)=\underbrace{a+(-a)+a+(-a)+...}_n$$

So maybe I think $f(n)=\sum_{i=1}^n a(-1)^{i+1}$ $n\in\mathbb N$ is right, but I can't understand how this result would help me find a value for $f(x), x\in\mathbb R$ And given the summation, how can I find a closed form using known functions?

-
Please verify that my editing clarified - but did not change - your original question. There was a typo in the title, correct? – BobStein-VisiBone Mar 23 '13 at 18:55
@BobStein-VisiBone Yes, thanks alot, i think is all better. Maybe for the iteration notation: i guess is more correct with $\circ$.I'm going to re-edit it, please check out my edit if you can. – MphLee Mar 23 '13 at 19:30
Not exactly sure this is what you want, but how about $f(x) = a \sin^2(\frac \pi 2 x)$? – Yoni Rozenshein Mar 23 '13 at 19:48
@MphLee glad you made those changes. I wondered about the \circ. What does it mean? Great reference on MathJax here. – BobStein-VisiBone Mar 23 '13 at 20:44
@BobStein-VisiBone I always used the notation $f^ {\circ n}$ for the function itaration because it is the itaration if the composition operator "$\circ$" ($f^ {\circ n+1}=f\circ f^ {\circ n}$), fot that i find it more clear than the exponent notation (like powers). – MphLee Mar 23 '13 at 20:52

Bear in mind that extensions of integer recurrence relations are not unique; a recurrence like $f(x+h) = g(f(x))$ is unique only up to some term with period h.
In this case, we have that $f(x) = a\cdot[1 + ({-1^{x-1})}]$.
So the obvious extension from $\mathbb N$ to $\mathbb R$ is just to use the substitution of $-1^n = e^{n{\pi}i}$, giving $f(x)=a\cdot(1+e^{(x-1){\pi}i})$, which is equivalent to $f(x) =a\cdot[1 + cos({\pi}x-\pi) + isin({\pi}x - \pi)]$, which is unfortunately complex-valued.
Hoever, we can now exploit the fact already mentioned above, that we can simply add or subtract any function with the proper period, and subtract out the imaginary term. In general, you can always just shortcut $(-1)^n$ to $cos(n{\pi})$ without trouble. Hence, a solution is that $f(x) = a\cdot(1 + cos({\pi}x-\pi))$. Again, this is not unique; there are other valid extensions from your original recurrence relation to the real numbers. However, it does correspond to the original recurrence at every point where that recurrence is defined.
yes. If you want that the extension is unique, you must have at least another recursion for $f(n+\alpha)$ with $\alpha$ irrational. – mau Mar 24 '13 at 12:28
mmh, can you make an example?$f(n+\alpha)=d^{ \circ\alpha}(f(n))$ So do you mean I need to know at least the value of an $\alpha$-iterate of $d$ (with $\alpha$ irrational)?@mau – MphLee Mar 24 '13 at 19:48