# Function with linearly decreasing difference between subsequent outputs

How can we find a function for a conversion table with the following properties? The range of both inputs and outputs is $[0..100]$; inputs are integers.

$$f(0) = 0$$ $$f(100) = 100$$ $$f(1) - f(0) = 2(f(100) - f(99))$$

So, $f(1)$ should be $1.\bar3$ and $f(99)$ should be $99.\bar3$. The difference between subsequent outputs is linearly decreasing, so $f(50)-f(49)\approx 1$.

-

Let $a_n=f(n)-f(n-1)$. Then $a_1=\frac{4}{3}$ and $a_{100}=\frac{2}{3}$. Since the differences are linearly decreasing, we have $a_n=\frac{4}{3}-\frac{n-1}{99}\frac{2}{3}$.
Hence $f(n)=a_n+...+a_1+f(0)=\frac{4n}{3}-\frac{2}{297}(1+...+(n-1))=\frac{4n}{3}-\frac{n(n-1)}{297}=\frac{n(397-n)}{297}$.
Thank you very much. Now I can use the same logic to verify for different ratios (where ratio in my example was 2, between $f(1)-f(0)$ and $f(100)-f(99)$). –  ΤΖΩΤΖΙΟΥ Dec 12 '12 at 13:36