필터 지우기
필터 지우기

ラグランジュの未定乗数法

조회 수: 30 (최근 30일)
Takafumi
Takafumi 2018년 5월 17일
답변: Takafumi 2018년 5월 17일
ラグランジュの未定乗数法による極値の導出におけるサンプルプログラムありますか?

채택된 답변

Takafumi
Takafumi 2018년 5월 17일
syms x y lambda real
% maxmize
f(x,y) = (x+y)^2;
% subject to
g(x,y) = x^2 + y ^2 - 1;
L(x,y,lambda) = f - lambda*g
eqn1 = diff(L,x) == 0;
eqn2 = diff(L,y) == 0;
eqn3 = diff(L,lambda) == 0;
ss = solve([eqn1,eqn2,eqn3],[x,y,lambda]);
T = table(double(ss.x),double(ss.y),double(ss.lambda),double(f(ss.x,ss.y)));
T.Properties.VariableNames = {'x','y','lambda','f'}
fsurf(f,[-2 2 -2 2],'FaceAlpha',0.3);shg;view(0,90)
hold on
plot3(double(ss.x),double(ss.y),f(double(ss.x),double(ss.y)),'r*')
hold off

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!