code to find minimum of a quadratic function using newton method with exact line search

2 views (last 30 days)
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

Answers (0)

Community Treasure Hunt

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

Start Hunting!