TITLE: Second derivative of Kullback–Leibler divergence
QUESTION [6 upvotes]: The Kullback-Leibler divergence is defined here. I have to find the second derivative of $\textrm{KL}(p(s, \theta)||\mu(s) q(\theta, s))$ regarding $p(s, \theta)$, where $p(s, \theta)$ is a joint probability (and therefore, $\frac{1}{p(s, \theta)} \geq 0$), and $\frac{\partial^2 p(s, \theta)}{\partial p(s,\theta)} = 0$. 
By definition, $\textrm{KL}(p(s, \theta)||\mu(s) q(\theta, s)) = \sum\limits_{i} P(i) \log \frac{P(i)}{Q(i)}$, where $Q(s,\theta)=\mu(s) q(\theta, s)$. The final result of the derivation must show that the second derivative of $\textrm{KL}(p(s, \theta)||\mu(s) q(\theta, s))$ is non-negative. My colleague scribbled these steps before leaving:
$ \frac{\partial^2 \sum\limits_{i} p(s, \theta) \log \frac{p(s,\theta)}{Q(s, \theta)}}{\partial p(s,\theta)|s,\theta} = \\
 P(s,\theta) \log P(s,\theta)-P(s,\theta) \log Q(s,\theta) = \\
 \log P(s,\theta) * \frac{1}{P(s,\theta)} = \\
 \log P(s,\theta) - \log Q(s,\theta) = \\
 \frac{1}{P(s,\theta)} \geq 0.$
But this was really fast, and his handwriting isn't the best. Therefore, there might be some details wrong (and he might also have made a mistake). I'm guessing in the second line, some of terms must be derivated (as if it were a first derivation of a multiplication $(fg)' = f'g + fg'$), but the minus sign doesn't correspond and we are doing a second derivation. I'm also assuming he omitted the $\sum$. On the third line, I guess the second half of the equation equals $0$ and he derived the $\log$ into $\frac{1}{P(s,\theta)}$, but why is there a $\log$ still? On the fourth line there are other $\log$s, which I have no idea where they came from, but if we derive everything, we reach the final line, which we know is positive, and the proof ends.
I tried to reach the solution on my own, like this
$ \frac{\partial^2 \sum\limits_{i} P(i) \log \frac{P(i)}{Q(i)}}
 {\partial P(i)} = \sum\limits_{i} P'' \log \frac{P}{Q} + 2 P' \log '\frac{P}{Q} + P \log '' \frac{P}{Q} = \sum\limits_{i} 0 + 2\frac{Q}{P} + P \frac{PQ'-QP'}{P^2} = \sum\limits_{i} 2\frac{Q}{P} + \frac{PQ'-QP'}{P} = \sum\limits_{i} 2\frac{Q}{P} - \frac{Q}{P} = \sum\limits_{i} \frac{Q}{P}
 $
But I can't really move from here to the final solution. What did I do wrong? What was my colleague doing?

REPLY [6 votes]: Found it. I was missing the fact that $\log(\frac{A}{B})=\log(A)-\log(B)$. From there, we can easily do
\begin{align}
 & \!\!\!\!\!\!\!\!\frac{\partial^2 \textrm{KL}(p(s, \theta)||\mu(s) q(\theta|s))}{\partial p(s,\theta)^2} =   \\ 
 & = \frac{\partial^2 p(s, \theta) \log \frac{p(s,\theta)}{Q(s,\theta)}}{\partial p(s,\theta)^2} = \nonumber\\
 & = \frac{\partial^2 p(s, \theta) \log p(s,\theta) - p(s, \theta) \log Q(s,\theta)}{\partial p(s,\theta)^2}  = \nonumber\\
 & = \frac{\partial^2 p(s, \theta) \log p(s,\theta)}{\partial p(s,\theta)^2} - \frac{\partial^2 p(s, \theta) \log Q(s,\theta)}{\partial p(s,\theta)^2} = \nonumber\\
 & = \frac{\partial^2 p(s, \theta)}{\partial p(s,\theta)^2} \log p(s,\theta) + 2 \frac{\partial p(s, \theta) \log p(s,\theta)}{\partial p(s,\theta)} + p(s, \theta) \frac{\partial^2 \log p(s,\theta)}{\partial p(s,\theta)^2} - 0 = \nonumber\\
 & = 0 + \frac{2}{p(s,\theta)} + p(s, \theta) \frac{\partial \frac{1}{p(s,\theta)}}{\partial p(s,\theta)} = \nonumber\\
 & = \frac{2}{p(s,\theta)} - \frac{1}{p(s,\theta)} = \nonumber\\
 & = \frac{1}{p(s,\theta)} \geq 0 \nonumber\\
\end{align}