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

6 次查看(过去 30 天)
mizuguti
mizuguti 2024-5-9
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 中查找有关 Optimization Toolbox 入門 的更多信息

Community Treasure Hunt

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

Start Hunting!