I have a problem on my homework with Lagrangian multipliers that Mathematica has now been bashing at fruitlessly for 10 minutes. I'm not sure whether I did something horribly wrong codewise, but it's definitely a big ugly function that it is trying to optimize with constraints.
Here's the problem: I need to maximize f
with regards to c
and n
if v
is held constant at 20000
.
p = 15 n (10 - c) - c^2;
v = 0.5 p + n*Sqrt[p];
f = c*p - v;
As you can probably tell, f
, when properly expanded, is huge. Its derivatives are even uglier, making maximization absolutely nasty. I tried having Mathematica solve Lagrangian Multipliers on its own, so that with values of c and n I could just plug in to see what f's max was:
g1 = D[v, c]
g2 = D[v, n]
f1 = D[f, c]
f2 = D[f, n]
Solve[f1 == lam*g1 && f2 == lam*g2 && v == 20000, {c, n}]
It's been sitting for 25 minutes. 5 minutes later, I ssh'd to another machine and started this:
Maximize[{f, v == 20000}, {c, n}]
And that one has been going for 15 now. Is there something I can do to make this go faster? I'm running on a machine with 4 cores, 8 gigs of ram and an i7, it should be able to handle this. I have a lot of problems like this, and don't have time to let it go overnight :(