Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Help with defining constraints in Lagrangian

I am trying to maximize the function P, with constraints of x >= 75,000 and y >= 200,000. However, I do not think I am defining them correctly. I attempt to define them as arguments of the solve() function.

var('x','y', 'lam')

P = (0.05*x*(1-(x/150000) - 0.0000008*x*y)) + (0.08*y*(1-(y/200000) - 0.0000008*x*y))

diff(P, x)
-(4.00000000000000e-8)*x*y - (6.40000000000000e-8)*y^2 - (3.33333333333333e-7)*x*(0.120000000000000*y + 1) - (3.33333333333333e-7)*x + 0.0500000000000000

diff(P, y)
-(4.00000000000000e-8)*x^2 - (6.40000000000000e-8)*x*y - (4.00000000000000e-7)*(0.160000000000000*x + 1)*y - (4.00000000000000e-7)*y + 0.0800000000000000

solve([diff(P,x) == 0, diff(P,y) == 0, x >= 75000, y >= 200000], x, y, lam)
[[75000 < x, 200000 < y, -(4e-08)*x*y - (6.4e-08)*y^2 - (3.33333333333333e-07)*x*(0.12*y + 1) - (3.33333333333333e-07)*x + 0.05 == 0, -(4e-08)*x^2 - (6.4e-08)*x*y - ((6.4e-08)*x + 4e-07)*y - (4e-07)*y + 0.08 == 0], [x == 75000, 200000 < y, -(6.4e-08)*y^2 - 0.006*y == 0, -0.0096008*y - 224.92 == 0], [x == 75000, y == 200000, -3760.0 == 0, -2145.08 == 0], [y == 200000, 75000 < x, -0.01600066666666667*x - 2559.949999999999 == 0, -(4e-08)*x^2 - 0.0256*x - 0.08 == 0]]