# How to find $l$ that minimises value of $(c\sum\limits_{n=1}^l n)^{d/l}$

I have the following formula which represents the cost $s$ of an action on a particular day:

$s = (c\sum\limits_{n=1}^l n)^{d/l}$

I want to choose $l$, so that $s$ is minimised, given a particular $c$ and $d$.

Notes
* I will want to do the action many times per day.
* On any particular day, $d$ is given, but it may be different on different days.
* $c$ is also given, but may be different each time I do the action.
* For $l$, I can choose any integer between $1$ and $d$ (inclusive).
* $d$ will be an integer. Realistic values are around $100$ to $10000$, although higher and lower are possible. It will always be at least $1$, if that matters.
* $c$ will be a positive number (greater than $0$).

How do I determine the value for $l$ that results in the lowest possible $s$, given $c$ and $d$?

-
I come from a software development background, so if anything is ambiguous or poorly expressed, please assume I mean it as a programmer would. –  everybody Dec 8 '12 at 12:10
is c a function of n –  Amr Dec 8 '12 at 12:12
If c is a constant why don't you put it outside of the sum? –  Amr Dec 8 '12 at 12:13
c is a constant and has now been moved outside the sum. –  everybody Dec 8 '12 at 12:17

I'll write $L$ instead of $l$ for easier readability.
Here is a partial solution that assumes that the optimal $L$ will be fairly large. The sum can then be written as $$s(c,d,L) = (cL^2)^{d/L} \left(\sum_{j=1}^L \frac{j}{L^2} \right)^{d/L} \approx (cL^2)^{d/L} \left(\frac{1}{2} \right)^{d/L} = \left(\frac{cL^2}{2} \right)^{d/L}$$ since $\sum_{j=1}^L \frac{j}{L^2} \approx \int_0^1 x dx = 1/2$ for large $L$.
Take logarithms to get $$\log s \approx (\log c + 2 \log L - \log 2) \frac{d}{L} \, .$$ The derivative with respect to $L$ is $$\frac{\partial }{\partial L} \log s = \frac{d(2 - \log c - 2 \log L + \log 2)}{L^2} = \frac{d}{L^2}\left(\log (2e^2/(cL^2) \right)$$ and this is positive if $cL^2 < 2e^2$ and negative for larger $L$. Therefore $s$ is minimal when $L$ is as large as possible, i.e. $L = d$, resulting in the value $s \approx cd^2/2$.
This should now be compared against small values of $L$ ($L \le 10$ or so), which can be done by direct computation.