I was reading the section on finding optimal codes through the lagrange multiplier and saw this expression at page 16 of http://web.ntpu.edu.tw/~phwang/teaching/2012s/IT/slides/chap05.pdf
The goal is to minimize $ \sum p_i l_i $ subject to $ \sum D^{-li} \le 1$ The formulation using langrange multipliers thus becomes
$ \min( J = \sum p_i l_i + \lambda(\sum D^{-li})) $
The first step is to differentiate the equation wrt $l_i$ and $\lambda$ and set it to zero.
$ \frac{dJ}{dl_i} = p_i - \lambda D^{-li}ln \ D = 0 \\ D^{-li} = \frac{p_i}{\lambda \ ln \ D} \\ \frac{dJ}{d\lambda} = \sum D^{-li} = 0 $
But then my next steps would not be the same as the slides. This is what I would do.
$ \sum D^{-li} = 0 \\ \sum \frac{p_i}{\lambda \ ln \ D} = 0 \\ \frac{1}{\lambda \ ln \ D} = 0 $
Im stuck here. This is where I learned the lagrange multiplier. I hope someone can hint me on where I made a mistake. https://www.youtube.com/watch?gl=SG&hl=en-GB&v=ry9cgNx1QV8
EDIT: Oops it seems like there might be an issue with the notes ? Shouldn't the formulation be
$ \min ( J = \sum p_i l_i + \lambda (\sum D^{-li} - 1))$ ? Only then can I get then arrive at the same solution.
Yes, you have figured out correctly. The objective function should be $$J = \lambda\left(\sum_{i}D^{-l_i}-1\right) + \sum_{i}p_i l_i $$