Let $$I(u)=\frac{1}{2}\int_{(a,b)} u'^2\quad \text{and}\quad J(u)=\int_{(a,b)} u^2,$$ with $u\in W_0^2(a,b)$. I want to minimize $$H(u)=\frac{I(u)}{J(u)}.$$
Way 1 :
Using Lagrange multiplier, I know that there is a constant $\lambda $ s.t. $$\int_{(a,b)} u'v'=2\lambda \int_{(a,b)} uv,$$ for all $v\in H_0^1(a,b)$.
Way 2 :
I minimize $\log(H(u))=\log(I(u))-\log(J(u))$. $$\frac{H'(u)}{H(u)}=\frac{\int_{(a,b)} u'v'}{\int_{(a,b)}u'^2}-\frac{2\int_{(a,b)}uv}{\int_{(a,b)}u^2},$$ and thus a necessary condition is $$\frac{H'(u)}{H(u)}=0\iff \int_{(a,b)}u'v'=2\frac{\int_{(a,b)}u'^2}{\int_{(a,b)}u^2}\int_{(a,b)}uv.$$
So, to be coherent with the way 1 I suppose that I can set $\lambda =\frac{\int_{(a,b)} u'^2}{\int_{(a,b)} u^2}.$ But my problem is that such a $\lambda $ depending on $u$, and thus I don't really understand why we can say that $\lambda $ is constant.