Trying to use Lagrange Multipliers to find potential critical points along the boundary g(w,x,y,z) = 1 but have a question if I am doing this right or wrong.

5 visualizaciones (últimos 30 días)
The code I have so far for my problem is :
%Storing the function f and g
syms w x y z;
f(w,x,y,z) = 2.0*w*x - 4.0*y - 5.0*w*y + 4.0*y*z + w^2 + 4.0*z^2;
g(w,x,y,z) = 0.4723*w*x + 0.6455*w*y + 0.1187*x*y + 0.8042*w^2 + 0.08831*x^2 + 0.2568*y^2 + 0.06482*z^2;
%Getting the derivatives of both functions
Dfw = diff(f,w);
Dfx = diff(f,x);
Dfy = diff(f,y);
Dfz = diff(f,z);
Dgw = diff(g,w);
Dgx = diff(g,x);
Dgy = diff(g,y);
Dgz = diff(g,z);
%Using Langrange Multipliers to determine potential critical points
syms L;
assume(L, 'real');
[LSols2, wSols2, xSols2, ySols2, zSols2] = solve([Dfw == L*Dgw,Dfx == L*Dgx, Dfy == L*Dgy, Dfz == L*Dgz, g == 1], [L,w,x,y,z]);
After, I end up with the output:
LSols2 =
88.02707682424968634219788390865
wSols2 =
2.3279803669807613809220624954167
xSols2 =
-4.2003960084583074147714380592078
ySols2 =
-2.5673025621149244822032895411313
zSols2 =
-3.0098831206729364367248909573655
However, I am running this message also where it says: "Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve. "

Respuestas (1)

Walter Roberson
Walter Roberson el 22 de Nov. de 2019
MATLAB limitation. There are closed form solutions (sort of). The different variables are polynomials of degree 7 in the roots of a polynomial of degree 8 that has all real roots.
You can get further by doing step-by-step solve() and substitutions, but at some point you hit the fact that MATLAB is not very good at finding solutions to polynomials of degree 5 or more.
  2 comentarios
Peter Pyrka
Peter Pyrka el 22 de Nov. de 2019
Oh okay. At the end if only one critical point falls within the constraint of the boundary, would it be considered the max or min?(since there is only one point and I can't compare it to other values)
Walter Roberson
Walter Roberson el 22 de Nov. de 2019
Perhaps only one critical point falls within the constraint boundaries, but other points might fall within the boundaries, and you can compare the values for them.
Or as usual you could use the double-differential evaluated at the point: positive for a minimum, negative for a maximum.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by