多変数関数の条件付き極致について

조회 수: 4 (최근 30일)
mizuguti
mizuguti 2024년 5월 9일
답변: Akira Agata 2024년 5월 10일
z=x*y*cos(x^2+y^2)という多変数関数が、x^2+y^2<(pi/2),x>0,y>0という条件がある時の極大値と極小値の値を表示させる方法がわかりません。

답변 (1개)

Akira Agata
Akira Agata 2024년 5월 10일
たとえば Optimization Toolboxを使って、以下のようにすると極大値を与える x,y を求めることができます(極小値も同様)。
% 最適化問題の作成 (極大値を求める場合)
prob = optimproblem('ObjectiveSense', 'max');
% 制約条件
x = optimvar('x', 'LowerBound', 0);
y = optimvar('y', 'LowerBound', 0);
prob.Constraints = x^2 + y^2 <= pi/2;
% 目的関数
prob.Objective = x*y*cos(x^2 + y^2);
% 初期値を設定
x0.x = 0.1;
x0.y = 0.1;
% 最適化問題を解く
sol = solve(prob, x0);
Solving problem using fmincon. Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
% 結果を表示
disp(sol)
x: 0.6559 y: 0.6559

카테고리

Help CenterFile Exchange에서 Global or Multiple Starting Point Search에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!