Multivariate Newton Method - Numerical Aproximation in Matlab
Show older comments
I have to use Newton Method for a function goes R^5 to R^5 and gives an matrix's approximate eigenvalues and eigenvectors but whatever I did (even every step looks perfectly right) my answers are not even close to original eigenvalues and eigenvectors. (I checked it by using [m,n]=eig(B) code) Any help would be appreciated!
Matrix B and my initial guess is below;
%Using loop to create a matrix with two condition
for k=1:4
for l=1:4
if abs(k-l)==1
B(k,l)=-1/2;
else
B(k,l)=0;
end
end
end
B;
x=[-.5; -.5; -.5; -.5; -1]
My code is below:
%Definition of Matlab function
function [y]=new(n,x,B)
%Creating eigenvector as v=(v(1),v(2),v(3),v(4))
v=zeros(4,1);
v(1)=x(1);
v(2)=x(2);
v(3)=x(3);
v(4)=x(4);
%Defining function as desired to be
y=[B*v-x(5)*v;v'*v-1];
J=[B-x(5)*eye(4) -v; 2*v' 0];
%Using loop to end iteration as to error
for k=1:n
if max(abs(y))>1e-4
x=x-J\y
else
break
x
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!