code to find minimum of a quadratic function using newton method with exact line search
3 次查看(过去 30 天)
显示 更早的评论
I have wrote this code but I recieve an error meassage , what is the mistake and is the code correct to solve using newton method with exact line search
clearvars;
clc;
syms x y
% b= (x-2)^4 +(x-2*y)^2
b = (x - 2*y)^2 + (x - 2)^4
f = @(x)(x(1)-2)^4 +(x(1)-2*x(2))^2 ;
gradient (b)
b= @ (x,y) (x-2).^4 +(x-2*y).^2
g= @ (x,y)[2*x - 4*y + 4*(x - 2)^3 ; 8*y - 4*x]
B=@(x,y) [2+12*(x-2)^2 -4 ; -4 8 ]
x(1)=0;
y(1)=3;
i=1;
% p = rand(1,1) ;
p1= -B(x,y)\g(x,y);
for i=2:4
x(i) = x(i-1) + p1
y(i) = y(i-1) + p1
p(i) = -B(x(i),y(i))\g(x(i),y(i))
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Direct Search 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!