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

13 ビュー (過去 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 Center および File ExchangeGlobal or Multiple Starting Point Search についてさらに検索

Community Treasure Hunt

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

Start Hunting!