As mentioned in the title, I want to find the minimum / maximum of the following function with symbolic computation using the lagrange multipliers.
f(x,y) = x*y under the constraint x^3 + y^4 = 1.
syms x y lambdaf = x * y;g = x^3 + y^4 - 1 == 0; % constraint
L = f + lambda * lhs(g); % Lagrange function
dL_dx = diff(L,x) == 0; % derivative of L with respect to x
dL_dy = diff(L,y) == 0; % derivative of L with respect to y
dL_dlambda = diff(L,lambda) == 0; % derivative of L with respect to lambda
system = [dL_dx; dL_dy; dL_dlambda]; % build the system of equations
[x_val, y_val,lambda_val] = solve(system, [x y lambda], 'Real', true) % solve the system of equations and display the results
results_numeric = double([x_val, y_val, lambda_val]) % show results in a vector of data type double
>>results_numeric = 0.8298 0.8091 -0.3917 0.8298 -0.8091 0.3917
I tried approaching this with the matlab documentation on lagrange but only got so far. This does not represent my minimum/maximum, does it? Also is there a way to now differentiate between max and min? I know there is another aproach using fmincon, which is way easier, but I want to solve it this way.
Best Answer