1
$\begingroup$

I am trying to solve the following optimisation problem, but Mathematica is not providing me with a solution:

$$\max_{x_{1},x_{2},e_{1},e_{2}}\theta_{1}\ln(x_{1})-e_{1} + \theta_{2}\ln(x_{2})-e_{2} \\ \text{s.t}\quad \theta_{1}\sqrt{e_{1}}+\theta_{2}\sqrt{e_{2}}=x_{1}+x_{2}$$

I am using the following Mathematica code, but it just returns the string I provide, rather than any attempt at a solution.

Maximize[{t Log[x] - e + T Log[X] - f, t Sqrt[e] + T Sqrt[f] == x + X},{x,X,e,f}]

This should be solvable by using Lagrange multipliers but it is just returning:

Maximize[{-e - f + t Log[x] + T Log[X], Sqrt[e] t + Sqrt[f] T == x + X}, {x, X, e, f}]
$\endgroup$
2
  • 1
    $\begingroup$ Why not try the Lagrange multiplier approach with Solve[], just for comparison's sake? $\endgroup$ Mar 7 '16 at 17:27
  • $\begingroup$ Also, is it sufficient to get numerical results using NMaximize or relatives? $\endgroup$
    – Lukas
    Mar 7 '16 at 17:34
2
$\begingroup$

One solution with NMaximize

NMaximize[{t Log[x] - e + T Log[X] - f, t Sqrt[e] + T Sqrt[f] == x + X 
&& x > 0 && X > 0 && e > 0 && f > 0}, {x, X, e, f, t, T}]
(* {49.9142, {e -> 0.247974, f -> 0.542274, t -> -2.79977, T -> 3.65042, 
  x -> 1.96201*10^-8, X -> 1.32159}} *)

A warning is reported:

NMaximize::nnum: "The function value Indeterminate is not a number at {e,f,t,T,x,X} = {0.209827,0.533031,-2.96546,3.74982,0.,1.41812}."

a supplement

If t and T are given parameters; this is a big relief!

NMaximize[{t Log[x] - e + T Log[X] - f, t Sqrt[e] + T Sqrt[f] == x + X 
&& x > 0 && X > 0 && e > 0 && f > 0} /. {t -> 1, T -> 1}, {x, X, e, f}]
(* {-1.69315, {x -> 0.707108, X -> 0.707108, e -> 0.500001, f -> 0.500001}} *)

{t -> 1, T -> 1} are freely chosen.

additional

ff = t Log[x] - e + T Log[X] - f;
g = t Sqrt[e] + T Sqrt[f] - x - X;
L = ff + \[Lambda] g;

Solve[Eliminate[{Grad[L, {x, X, e, f}] == 0, g == 0}, {\[Lambda]}], {x, X, e, f]}]

enter image description here

Solution is the term with x > 0 and X > 0.

% /. {t -> 1, T -> 1}
(* {x -> 1/Sqrt[2], X -> 1/Sqrt[2], e -> 1/2, f -> 1/2} *)
$\endgroup$
2
  • $\begingroup$ As I understand it, t and T are given parameters $\endgroup$ Mar 7 '16 at 17:55
  • $\begingroup$ @Dr. belisarius Thanks for the help. $\endgroup$
    – user36273
    Mar 7 '16 at 18:23

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.