Finding the optimal combination for the Cobb-Douglas function given a budget I am trying to figure out to find the optimal combination of the Cobb-Douglas function given some budget. An example question is:

Output can be produced with labour and capital according to $Q = L^{\frac{1}{2}}K^{\frac{1}{2}}.$ If labour costs \$25 per unit and capital costs \$40 per unit, what is the optimal combination of labour and capital if your budget is \$800?

I am having trouble finding the answer mathematically. I suspect we have to find the partial derivatives and do some manipulations but I don't know how! Can someone please point me in the correct direction? 
Thanks
 A: One method you can apply is the lagrange-multiplier method. The lagrange function is:
$\mathcal L=Q(L,K)+\lambda (B-C(L,K))$
$\mathcal L=L^{0.5}\cdot K^{0.5}+\lambda (800-25L-40K)$
The partial dervatives, w.r.t L and K, are:
$\frac{\partial \mathcal L}{\partial L}=0.5\cdot L^{-0.5}\cdot K^{0.5}-\lambda\cdot 25=0 $
$\frac{\partial \mathcal L}{\partial K}=0.5\cdot L^{0.5}\cdot K^{-0.5}-\lambda\cdot 40=0 $
Bringing the terms with $\lambda$ on the RHS
$0.5\cdot L^{-0.5}\cdot K^{0.5}=\lambda\cdot 25 $
$0.5\cdot L^{0.5}\cdot K^{-0.5}=\lambda\cdot 40 $
Dividing the first equation by the second equation:
$\Large{\frac{0.5\cdot L^{-0.5}\cdot K^{0.5}}{0.5\cdot L^{0.5}\cdot K^{-0.5}}=\frac{\lambda\cdot 25}{\lambda\cdot 40}}$
Cancelling out 0.5 and $\lambda$
$\Large{\frac{ L^{-0.5}\cdot K^{0.5}}{ L^{0.5}\cdot K^{-0.5}}=\frac{ 25}{ 40}}$
$\frac{ L^{-0.5}}{ L^{0.5}}=L^{-0.5}\cdot  L^{-0.5}=L^{-0.5-0.5}=L^{-1}=\frac{1}{L}$
$\frac{ K^{0.5}}{ K^{-0.5}}=K^{0.5}\cdot  K^{-(-0.5)}=K^{0.5+0.5}=K^{1}=K$
This gives for the RHS $\frac{K}{L}$
$\frac{K}{L}=\frac{ 25}{ 40} \ \ \Rightarrow \ \ K=\frac{5}{8}L \quad \color{blue}{(*)}$
Partial derivative w.r.t $\lambda$
$\frac{\partial \mathcal L}{\partial \lambda}=800-25L-40K=0$
Now you can insert the expression for K, which is in $\color{blue}{(*)}$.
$800-25L-40\frac{5}{8}L=0$
$800-25L-25L=0 \ \ \Rightarrow \ \ 800=50L \ \ \Rightarrow \ \ L^*=16$
Finally you can use $\color{blue}{(*)}$ again to calculate $K^*$
