finding the maxima/minima using lagrange mutlipliers
이전 댓글 표시
I was told to Find (numerically) the location and value of the absolute maximum and minimum of the function f(x, y) = e^x − sin y on the ellipse g(x, y) = x^2 + 3*y^2 = 1 using lagrange multipliers. Then check my answer by drawing a picture illustrating that the maximum and minimum occur where the level curves of f are tangent to the ellipse. I was able to find the minimum, but I'm having trouble with the absolute maximum. Here's what I have so far:
syms x y lambda
f = exp(x) - sin (y);
g = x^2 + 3*y^2 - 1 == 0;
L = f - lambda * lhs(g);
dL_dx = (diff(L,x) == 0);
dL_dy = (diff(L,y) == 0);
dL_dlambda = (diff(L,lambda) == 0);
system = [dL_dx; dL_dy; dL_dlambda];
[x_val, y_val, lambda_val] = solve(system, [x y lambda], 'Real', true);
results_numeric = double([x_val, y_val, lambda_val])
fmin= exp(-0.6893) - sin(0.4183)
댓글 수: 1
John D'Errico
2022년 4월 2일
편집: John D'Errico
2022년 4월 2일
When you insert a picture of your code, then for someone to help you, they need to retype ALL of your code from scratch. Worse, the picture you inserted, is fuzzy, and difficult to read.
Given that you can more easily paste in the actual code directly into the question (Just use the code formatting icons on top of the box to format the code, is there a good reason why you want to make it more difficult for someone to answer you? Is that really your goal here?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 AI for Signals에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!