Multivariate Newton Method - Numerical Aproximation in Matlab
古いコメントを表示
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
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!