How can I use while or for in first gradient method?

1 回表示 (過去 30 日間)
Sebestyén Adrian
Sebestyén Adrian 2021 年 1 月 8 日
コメント済み: Jan 2021 年 1 月 8 日
syms x1;
syms x2;
f = 2*x1^2 + 3*x2^2 - 5*x1*x2 + 10*x1 + 5*x2
gr1=diff(f, x1);
x0=[2;2];
gr1=subs(gr1, x1, x0(1));
gr1=subs(gr1, x2, x0(2));
gr2=diff(f, x2);
gr2=subs(gr2, x1, x0(1));
gr2=subs(gr2, x2, x0(2));
gr=[gr1; gr2]
D=(gr)/(sqrt(gr1^2 + gr2^2));
D=[8*113^(1/2)/113; 7*113^(1/2)/113]
S=1;
x01=x0-S*D
fx01= 2*x01(1)^2 + 3*x01(2)^2 - 5*x01(1)*x01(2) + 10*x01(1) + 5*x01(2)
prm=sqrt(D(1)^1 + D(2)^2)
fx0=2*x0(1)^2 + 3*x0(2)^2 - 5*x0(1)*x0(2) + 10*x0(1) + 5*x0(2);
doa=fx0-fx01
epsilon=0.1;
  1 件のコメント
Jan
Jan 2021 年 1 月 8 日
The question is not clear, because you did not mention the purpose of the loop. Then it is impossible to guess reliably, where it has to be inserted with which conditions. Please edit the question an add the details.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

タグ

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by