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!