Inaccuracy in solving simultaneous equations using matrix
Ältere Kommentare anzeigen
So i was solving a system of n linear equations. My coefficient matrix is a tridiagonal one.
However as i was decreasing the values inside matrix or increasing n the error was increasing rapidly.
clear
n=1000;
B=(1:n);
B=B';
A=full(gallery('tridiag',n,0.341,0.232,0.741));
x=A\B;
c=A*x-B;
error=0;
for i=1:n
error=error+abs(c(i,1));
end
error
%error = 2.174626266011847e+155
Here the system is in the form Ax=B
ideally c should contain only zero.
Can anyone a suggest a method so that i can decrease the net error.
NOTE: I also tried the Thomas Algorithm even that gave an error of similar order .
3 Kommentare
Walter Roberson
am 3 Jun. 2020
>> rcond(A)
ans =
5.96371748872238e-170
Much too small for reliable numeric solution. rank(A) says 999 rather than 1000.
Switching to symbolic toolbox is able to get full rank and exact solution.
Susmit Kumar Mishra
am 3 Jun. 2020
Walter Roberson
am 3 Jun. 2020
Bearbeitet: Walter Roberson
am 3 Jun. 2020
n = 1000;
B = (1:n).';
A = sym( full(gallery('tridiag',n,0.341,0.232,0.741)) ); %11 seconds
x = A\B; %not fast!! 43 seconds
c = A*x-B;
error = sum(abs(c));
disp(error)
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Linear Algebra finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!