Finding the minimizer using fminunc.

If I have function:
fv = @(x) x(1)^2 + x(1)*x(2) + (3/2)*x(2)^2 - 2*log(x(1)) - log(x(2));
How would I use the function fminunc to find the minimizer rather than the minimum value?

 採用された回答

Torsten
Torsten 2022 年 11 月 4 日

0 投票

fv = @(x) x(1)^2 + x(1)*x(2) + (3/2)*x(2)^2 - 2*log(x(1)) - log(x(2));
[minimizer,minimum_value] = fminunc(fv,[1; 1])
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
minimizer = 2×1
0.8944 0.4472
minimum_value = 2.5279

3 件のコメント

Howie
Howie 2022 年 11 月 5 日
編集済み: Howie 2022 年 11 月 5 日
So does this function just give you the minimizer as a 2x1?
Torsten
Torsten 2022 年 11 月 5 日
編集済み: Torsten 2022 年 11 月 5 日
What else do you expect for a function with two variables to be optimized ?
An analytic expression for x1 and x2 ?
Howie
Howie 2022 年 11 月 5 日
thank you!

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 11 月 4 日

0 投票

If you need to find a maximum rather than a minimum then construct
nfv = @(x) -fv(x)
now minimize nfv using fminunc.
If you need to display what the maximum is remember to evaluate fv at the location of the maximum.

1 件のコメント

Howie
Howie 2022 年 11 月 4 日
編集済み: Howie 2022 年 11 月 4 日
Sorry, I needed to find the minimizer rather than the minimum value Nor the maximum!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeOptimization についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 11 月 4 日

コメント済み:

2022 年 11 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by