# On maximizing a function

I have a function as below, $$f(n) = \sum_{i}{-\Big( (1-q_i)^{n-1} - b \Big)^2}$$ how to find an integer $n\in[0,N]$ that maximizes function $f(\cdot)$. Here, $q_i\in[0,1]$, $b\in[0,1]$ and $N \gg 1$. Or which area should I look into, to solve this problem?

-
A few questions: is $n$ real or is it an integer? what do you know about $b$? what about $q_i$? what is the range on your sum? The reason I ask, is that if your sum range is small and n is an integer (with a small $N$), then if may be easiest just to calculate every possible value. –  rcollyer Apr 18 '11 at 19:53
edited accordingly. –  Richard Apr 18 '11 at 21:01
In that case, you'd want to look at integer programming. –  Ｊ. Ｍ. Apr 18 '11 at 21:08

By looking at the function, it seems that you only have to compute $f(n)$ for a few values of $n$. Let $q \in \mathbb{R}^k$ and the solution be $n^*$. Now, $n^* \neq 0$ since $(1-q_i) \in [0,1]$. Also, note that $f(1) = -k(1-b)^2$. Now, for $n>1$, you'll have some fluctuations in $f(n)$ due to $b$, but as $n$ increases, $f(n)$ should monotonically decrease to $-kb^2$.
Therefore, finding the $\max$ of the first $m=20$ values should do the trick (you can experiment with the value of $m$).