|
Hey guys, I am attempting to find the backward error of this program. This m-file I am showing here is showing an answer of a 100 X 1 matrix with the answer being 1.0000 for each entry . My thinking is I can find the backward error if I can multiply my (a) matrix times this 100 x 1 matrix ( my answer from this m-file) I think, even though the correct answer is a 100 x 1 matrix of all ones, that when I multiply my (a) matrix by the answer I and then subtract that from my (b) I will be able to see my backward error.
So my big problem I think is trying to define my answer which I believe to be some form of x or x(i) from my m-file.
Please help me define my answer ( the last line of my m-file is one of my many attempts at defining my answer) If you have any questions to help make this clearer please let me know.
Btw my I am trying to iterate this until my error is < .5 x 10^-6 , I think I set that part up right
My m-file is below:
function x = jacobigstol(a,b,k)
n=length (b); % find n
d=diag(diag(a));
u=triu(a,1);
l=tril(a,-1);
x=zeros (n,1); % initialize vector x
tol=.5e-6; %
for j=1:k % loop for Jacobigs iteration
bl=b-u*x;
for i=1:n
x(i)=(bl(i)-l(i,:)*x)/d(i,i);
end
if norm(x-1,inf)<tol %
break %
end %
end % End of Jacobi iteration loop
disp(j); %keeping track of iterations
disp(x(i)); % trying to define ans =
any suggestions would be appreciated so much, thank you!!
|