2
$\begingroup$

I would like to solve constrained maximization problem by the Lagrangian.

$ max_{q(\omega)}\ U=\left(\int_{0}^{n} q(\omega)^{\rho} d \omega\right)^{\frac{1}{\rho}} \quad 0<\rho<1 $

$s.t.\ \int_{0}^{n} p(\omega) q(\omega) d \omega = w$

Setting the Lagrangian function, $\mathcal{L}=U^{\rho}-\lambda\left(\int_{0}^{n} p(\omega) q(\omega) d \omega-\mathrm{w}\right)$

Take the first derivatives, $\frac{\partial \mathcal{L}}{\partial q(\omega)}=\rho q(\omega)^{\rho-1}-\lambda p(\omega)=0$

Rearranging terms yields, $q(\omega)=\left(\frac{\lambda p(\omega)}{\rho}\right)^{\frac{1}{\rho-1}}$

I try the following code

U[i_] := Integrate[q[i]^rho, {i, 0, n}]^(1/rho)

L[n_, q_, p_] := 
 U[n]^rho - lambda*(Integrate[q[i]*p[i], {i, 0, n}

Solve[D[L[n, q, p], p]==0,q]

that is not working.

$\endgroup$
3
  • 1
    $\begingroup$ Exponent is p not $\rho$. What is utility? $\endgroup$ – OkkesDulgerci Jun 18 '20 at 4:17
  • 1
    $\begingroup$ A typo. It is U. @OkkesDulgerci $\endgroup$ – XJ.C Jun 18 '20 at 4:31
  • $\begingroup$ Derivative should be respect to q not p $\endgroup$ – OkkesDulgerci Jun 18 '20 at 4:43
3
$\begingroup$
U := Integrate[q^ρ, {w, 0, n}]^(1/ρ)
L[w_, q_, p_] :=  PowerExpand[U^ρ] - λ (Integrate[p q, {w, 0, n}] - w);

Solve[D[L[w, q, p], q] == 0, q] // Quiet

$\left\{q\to \left(\frac{\lambda p}{\rho }\right)^{\frac{1}{\rho -1}}\right\}$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.