# Proving convexity for a function with summation and integer variable

I would like to show that the function $$f$$ is convex in $$\rho\in [0,1)$$ under $$s\in \mathbb{Z}^+$$. When I use Sympy packages of Python to find $$\displaystyle\frac{\partial^2 f(\rho)}{d\rho^2}$$. I get an extremely long equation which is not really visually workable to prove convexity $$\left(\text{i.e.,}~\displaystyle\frac{\partial^2 f(\rho)}{d\rho^2}>0\right)$$.

$$f = \frac{\left(\rho s\right)^{s}}{2s! \rho s^{2} \left(1 - \rho\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(1 - \rho\right) s!} + \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)}$$

Is there an alternative approach for this proof, e.g., partitioning the function?

For completeness purposes, I am leaving the second order derivative obtained by Sympy and its associated Python code below.

$$\displaystyle\frac{\partial^2 f(\rho)}{d\rho^2}=- \frac{\left(\rho s\right)^{s} \left(- \frac{2 \left(\rho s\right)^{s}}{\left(\rho - 1\right)^{3} s!} + \sum_{n=0}^{s - 1} \left(\frac{n^{2} \left(\rho s\right)^{n}}{\rho^{2} n!} - \frac{n \left(\rho s\right)^{n}}{\rho^{2} n!}\right) + \frac{2 s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right)^{2} s!} - \frac{s^{2} \left(\rho s\right)^{s}}{\rho^{2} \left(\rho - 1\right) s!} + \frac{s \left(\rho s\right)^{s}}{\rho^{2} \left(\rho - 1\right) s!}\right)}{2 \rho s^{2} \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} - \frac{\left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right) \left(\frac{2 \left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + 2 \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{2 s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{2 \rho s^{2} \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{3}\right) s!} + \frac{2 \left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{\rho s^{2} \left(\rho - 1\right)^{3} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} - \frac{3 \left(\rho s\right)^{s}}{\rho s^{2} \left(\rho - 1\right)^{4} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} - \frac{\left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{\rho^{2} s \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} + \frac{2 \left(\rho s\right)^{s}}{\rho^{2} s \left(\rho - 1\right)^{3} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} + \frac{\left(\rho s\right)^{s} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right)^{2} s!} + \sum_{n=0}^{s - 1} \frac{n \left(\rho s\right)^{n}}{\rho n!} - \frac{s \left(\rho s\right)^{s}}{\rho \left(\rho - 1\right) s!}\right)}{\rho^{2} s^{2} \left(\rho - 1\right)^{2} \left(\left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right)^{2}\right) s!} - \frac{2 \left(\rho s\right)^{s}}{\rho^{2} s^{2} \left(\rho - 1\right)^{3} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} - \frac{\left(\rho s\right)^{s}}{2 \rho^{3} \left(\rho - 1\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} + \frac{3 \left(\rho s\right)^{s}}{2 \rho^{3} s \left(\rho - 1\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!} - \frac{\left(\rho s\right)^{s}}{\rho^{3} s^{2} \left(\rho - 1\right)^{2} \left(\frac{\left(\rho s\right)^{s}}{\left(\rho - 1\right) s!} - \sum_{n=0}^{s - 1} \frac{\left(\rho s\right)^{n}}{n!}\right) s!}$$

import sympy as sy
sy.init_printing()

rho = sy.symbols('rho', real=True)
n, s = sy.symbols('n s', integer= True)

f = ((rho*s)**s / (2*sy.factorial(s)*s**2*rho*(1-rho)**2
*(sy.Sum((s*rho)**n/sy.factorial(n), (n,0,s-1))
+ (s*rho)**s/(sy.factorial(s)*(1-rho)))))
sy.simplify(sy.diff(sy.diff(f, rho), rho))

• It does appear to be convex on the stated interval for any positive integer s. I'll get you started on proving convexity. Look at just the first term in the sum in the denominator. Ater bringing the numerator into the denominator, that comes out to 1/(positive_number * rho * (1-rho)), which is 1/(positive_concave) which is convex. If you can show that the 2nd term (after bringing the numerator into the denominator) is also concave (I leave that as an exercise for you), that would complete the convexity proof, because the whole netted out denominator would be positive concave.. Mar 22 '21 at 21:10
• @MarkL.Stone a complete answer would be very much appreciated. Mar 23 '21 at 10:01
• I haven't done the part I left for you, nor do I know that it is doable. Mar 23 '21 at 10:48