mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 14:43:08 +02:00
Adding gauss seidel method
This commit is contained in:
parent
ec05aa206f
commit
08c4979227
85
ENUME/projectA/gaussSeidelMethod.asv
Normal file
85
ENUME/projectA/gaussSeidelMethod.asv
Normal file
@ -0,0 +1,85 @@
|
||||
function x = gaussSeidelMethod(Matrix, Vector)
|
||||
[L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, flag, Rows] = initializeValues(Matrix);
|
||||
[x, whichIterationAreWeOn, demandedTolerance] = jacobiLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, flag, Rows);
|
||||
dispFinalResults(x, demandedTolerance, whichIterationAreWeOn, Matrix, Vector);
|
||||
end
|
||||
|
||||
function [L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, flag, Rows] = initializeValues(Matrix)
|
||||
[Rows, ~] = size(Matrix);
|
||||
[L, D, U] = decomposeMatrix(Matrix);
|
||||
initial_x = ones(Rows, 1);
|
||||
whichIterationAreWeOn = 0;
|
||||
demandedTolerance = 10e-10; % as per task description
|
||||
% Minimal values I got: 3.202372833989376e-15 for both system of
|
||||
% equations - original and task 2a)
|
||||
flag = 0;
|
||||
end
|
||||
|
||||
function [L, D, U] = decomposeMatrix(Matrix)
|
||||
D = diag(diag(Matrix));
|
||||
U = triu(Matrix, 1); % Generates upper triangular part of matrix
|
||||
% where the second variable denotes on which diagonal of matrix should we
|
||||
% start
|
||||
L = tril(Matrix, -1); % Generates lower triangular part of matrix
|
||||
% where the second variable denotes on which diagonal of matrix should we
|
||||
% start
|
||||
end
|
||||
|
||||
function [x, whichIterationAreWeOn, demandedTolerance] = jacobiLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, flag, Rows)
|
||||
while flag ~= 1 % flag denotes whether norm(Matrix*x-Vector) <= demandedTolerance
|
||||
[x, whichIterationAreWeOn, demandedTolerance, flag, initial_x] = jacobiInsideLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, Rows);
|
||||
end
|
||||
end
|
||||
|
||||
function [x, whichIterationAreWeOn, demandedTolerance, flag, initial_x] = jacobiInsideLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, Rows)
|
||||
x = jacobiEquation(D, L, U, initial_x, Vector, Rows);
|
||||
[flag, demandedTolerance] = checkError(x, initial_x, demandedTolerance, Matrix, Vector);
|
||||
[initial_x, whichIterationAreWeOn] = endOfLoop(x, whichIterationAreWeOn);
|
||||
end
|
||||
|
||||
function x = jacobiEquation(D, L, U, initial_x, Vector, Rows)
|
||||
W = U*initial_x - Vector;
|
||||
x(1, 1) = -W(1) / D(1,1);
|
||||
for i = 2 : Rows
|
||||
nominator = 0;
|
||||
for j = 1 : i - 1
|
||||
nominator = nominator L(i, j) * x(j);
|
||||
end
|
||||
nominator = nominator - W(j);
|
||||
x(i, 1) = nominator / D(i, i);
|
||||
end
|
||||
end
|
||||
|
||||
function [flag, demandedTolerance] = checkError(x, initial_x, demandedTolerance, Matrix, Vector)
|
||||
flag = 0;
|
||||
currentError = norm(x - initial_x);
|
||||
disp(currentError);
|
||||
if currentError <= demandedTolerance
|
||||
currentError = norm(Matrix*x-Vector);
|
||||
|
||||
if currentError <= demandedTolerance % if sequence as per textbook
|
||||
flag = 1;
|
||||
else
|
||||
demandedTolerance = demandedTolerance * 2; % arbitrary value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function [initial_x, whichIterationAreWeOn, flag] = endOfLoop(x, whichIterationAreWeOn)
|
||||
initial_x = x;
|
||||
whichIterationAreWeOn = whichIterationAreWeOn + 1;
|
||||
flag = 0;
|
||||
end
|
||||
|
||||
function dispFinalResults(x, demandedTolerance, whichIterationAreWeOn, Matrix, Vector)
|
||||
disp("Final demandedTolerance");
|
||||
disp(demandedTolerance);
|
||||
disp("Final Iteration: ");
|
||||
disp(whichIterationAreWeOn);
|
||||
disp("A\b matlab:");
|
||||
disp(Matrix \ Vector);
|
||||
disp("Error:");
|
||||
disp(norm(Matrix*x - Vector));
|
||||
disp("A\b error:");
|
||||
disp(norm(Matrix * (Matrix\Vector) - Vector));
|
||||
end
|
||||
83
ENUME/projectA/gaussSeidelMethod.m
Normal file
83
ENUME/projectA/gaussSeidelMethod.m
Normal file
@ -0,0 +1,83 @@
|
||||
function x = gaussSeidelMethod(Matrix, Vector)
|
||||
[L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, flag, Rows] = initializeValues(Matrix);
|
||||
[x, whichIterationAreWeOn, demandedTolerance] = jacobiLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, flag, Rows);
|
||||
dispFinalResults(x, demandedTolerance, whichIterationAreWeOn, Matrix, Vector);
|
||||
end
|
||||
|
||||
function [L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, flag, Rows] = initializeValues(Matrix)
|
||||
[Rows, ~] = size(Matrix);
|
||||
[L, D, U] = decomposeMatrix(Matrix);
|
||||
initial_x = zeros(Rows, 1);
|
||||
whichIterationAreWeOn = 0;
|
||||
demandedTolerance = 10e-10; % as per task description
|
||||
flag = 0;
|
||||
end
|
||||
|
||||
function [L, D, U] = decomposeMatrix(Matrix)
|
||||
D = diag(diag(Matrix));
|
||||
U = triu(Matrix, 1); % Generates upper triangular part of matrix
|
||||
% where the second variable denotes on which diagonal of matrix should we
|
||||
% start
|
||||
L = tril(Matrix, -1); % Generates lower triangular part of matrix
|
||||
% where the second variable denotes on which diagonal of matrix should we
|
||||
% start
|
||||
end
|
||||
|
||||
function [x, whichIterationAreWeOn, demandedTolerance] = jacobiLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, flag, Rows)
|
||||
while flag ~= 1 % flag denotes whether norm(Matrix*x-Vector) <= demandedTolerance
|
||||
[x, whichIterationAreWeOn, demandedTolerance, flag, initial_x] = jacobiInsideLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, Rows);
|
||||
end
|
||||
end
|
||||
|
||||
function [x, whichIterationAreWeOn, demandedTolerance, flag, initial_x] = jacobiInsideLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, Rows)
|
||||
x = jacobiEquation(D, L, U, initial_x, Vector, Rows);
|
||||
[flag, demandedTolerance] = checkError(x, initial_x, demandedTolerance, Matrix, Vector);
|
||||
[initial_x, whichIterationAreWeOn] = endOfLoop(x, whichIterationAreWeOn);
|
||||
end
|
||||
|
||||
function x = jacobiEquation(D, L, U, initial_x, Vector, Rows)
|
||||
W = U*initial_x - Vector;
|
||||
x(1, 1) = -W(1, 1) / D(1,1);
|
||||
for i = 2 : Rows
|
||||
x(i, 1) = calculateNominator(i, L, x, W) / D(i, i);
|
||||
end
|
||||
end
|
||||
|
||||
function nominator = calculateNominator(i, L, x, W)
|
||||
nominator = 0;
|
||||
for j = 1 : i - 1
|
||||
nominator = nominator + L(i, j) * x(j);
|
||||
end
|
||||
nominator = - nominator - W(j + 1, 1);
|
||||
end
|
||||
|
||||
function [flag, demandedTolerance] = checkError(x, initial_x, demandedTolerance, Matrix, Vector)
|
||||
flag = 0;
|
||||
currentError = norm(x - initial_x);
|
||||
if currentError <= demandedTolerance
|
||||
currentError = norm(Matrix*x-Vector);
|
||||
|
||||
if currentError <= demandedTolerance % if sequence as per textbook
|
||||
flag = 1;
|
||||
else
|
||||
demandedTolerance = demandedTolerance * 2; % arbitrary value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function [initial_x, whichIterationAreWeOn, flag] = endOfLoop(x, whichIterationAreWeOn)
|
||||
initial_x = x;
|
||||
whichIterationAreWeOn = whichIterationAreWeOn + 1;
|
||||
flag = 0;
|
||||
end
|
||||
|
||||
function dispFinalResults(x, demandedTolerance, whichIterationAreWeOn, Matrix, Vector)
|
||||
disp("Final demandedTolerance");
|
||||
disp(demandedTolerance);
|
||||
disp("Final Iteration: ");
|
||||
disp(whichIterationAreWeOn);
|
||||
disp("Error:");
|
||||
disp(norm(Matrix*x - Vector));
|
||||
disp("A\b error:");
|
||||
disp(norm(Matrix * (Matrix\Vector) - Vector));
|
||||
end
|
||||
@ -1,7 +1,7 @@
|
||||
function x = jacobiMethod(Matrix, Vector)
|
||||
[L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, flag] = initializeValues(Matrix);
|
||||
[x, whichIterationAreWeOn, demandedTolerance] = jacobiLoop(Matrix, L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, Vector, flag);
|
||||
dispFinalResults(demandedTolerance, whichIterationAreWeOn, Matrix, Vector);
|
||||
dispFinalResults(x, demandedTolerance, whichIterationAreWeOn, Matrix, Vector);
|
||||
end
|
||||
|
||||
function [L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, flag] = initializeValues(Matrix)
|
||||
@ -9,7 +9,9 @@ function [L, D, U, initial_x, whichIterationAreWeOn, demandedTolerance, flag] =
|
||||
[L, D, U] = decomposeMatrix(Matrix);
|
||||
initial_x = ones(Rows, 1);
|
||||
whichIterationAreWeOn = 0;
|
||||
demandedTolerance = 1e-10; % as per task description
|
||||
demandedTolerance = 10e-10; % as per task description
|
||||
% Minimal values I got: 3.202372833989376e-15 for both system of
|
||||
% equations - original and task 2a)
|
||||
flag = 0;
|
||||
end
|
||||
|
||||
@ -46,10 +48,11 @@ function [flag, demandedTolerance] = checkError(x, initial_x, demandedTolerance,
|
||||
currentError = norm(x - initial_x);
|
||||
if currentError <= demandedTolerance
|
||||
currentError = norm(Matrix*x-Vector);
|
||||
|
||||
if currentError <= demandedTolerance % if sequence as per textbook
|
||||
flag = 1;
|
||||
else
|
||||
demandedTolerance = demandedTolerance * 2; % arbitrary value
|
||||
demandedTolerance = demandedTolerance * 1; % arbitrary value
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -60,11 +63,15 @@ function [initial_x, whichIterationAreWeOn, flag] = endOfLoop(x, whichIterationA
|
||||
flag = 0;
|
||||
end
|
||||
|
||||
function dispFinalResults(demandedTolerance, whichIterationAreWeOn, Matrix, Vector)
|
||||
function dispFinalResults(x, demandedTolerance, whichIterationAreWeOn, Matrix, Vector)
|
||||
disp("Final demandedTolerance");
|
||||
disp(demandedTolerance);
|
||||
disp("Final Iteration: ");
|
||||
disp(whichIterationAreWeOn);
|
||||
disp("A\b matlab:");
|
||||
disp(Matrix \ Vector);
|
||||
disp("Error:");
|
||||
disp(norm(Matrix*x - Vector));
|
||||
disp("A\b error:");
|
||||
disp(norm(Matrix * (Matrix\Vector) - Vector));
|
||||
end
|
||||
@ -38,8 +38,7 @@
|
||||
\@writefile{toc}{\contentsline {subsubsection}{Zeroing next columns}{7}{section*.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.2}Backward substitution}{8}{subsection.2.2.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.3}Partial Pivoting}{8}{subsection.2.2.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2.3}Solution}{9}{section.2.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2.4}Discussion of the result}{9}{section.2.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {2.3}Discussion of the result}{9}{section.2.3}\protected@file@percent }
|
||||
\@writefile{toc}{\newpage }
|
||||
\@writefile{toc}{\contentsline {chapter}{\numberline {3}Problem 3 - Solving a system of n linear equations - iterative algorithm}{11}{chapter.3}\protected@file@percent }
|
||||
\@writefile{lof}{\addvspace {10\p@ }}
|
||||
@ -54,40 +53,44 @@
|
||||
\@writefile{toc}{\contentsline {paragraph}{Converging}{15}{section*.10}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{Stop tests}{15}{section*.11}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{\textbf {A} and \textbf {b}}{15}{section*.12}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {3.3}Solution}{16}{section.3.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {3.4}Discussion of the result}{16}{section.3.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{17}{chapter.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {3.3}Discussion of the result}{16}{section.3.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {3.3.1}Jacobi method result}{16}{subsection.3.3.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsubsection}{Minimizing the demanded error}{18}{section*.13}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {paragraph}{For original system of equations:}{18}{section*.14}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {paragraph}{For task 2a) system of equations:}{19}{section*.15}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {paragraph}{Table}{19}{section*.16}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{20}{chapter.4}\protected@file@percent }
|
||||
\@writefile{lof}{\addvspace {10\p@ }}
|
||||
\@writefile{lot}{\addvspace {10\p@ }}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.1}Problem}{17}{section.4.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.2}Theoretical introduction}{17}{section.4.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.3}Solution}{17}{section.4.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.4}Discussion of the result}{17}{section.4.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {chapter}{\numberline {5}Code appendix}{18}{chapter.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.1}Problem}{20}{section.4.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.2}Theoretical introduction}{20}{section.4.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.3}Solution}{20}{section.4.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {4.4}Discussion of the result}{20}{section.4.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {chapter}{\numberline {5}Code appendix}{21}{chapter.5}\protected@file@percent }
|
||||
\@writefile{lof}{\addvspace {10\p@ }}
|
||||
\@writefile{lot}{\addvspace {10\p@ }}
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.1}Task 2 Code}{18}{section.5.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.1}Main function}{18}{subsection.5.1.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{18}{subsection.5.1.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{20}{subsection.5.1.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{20}{subsection.5.1.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{20}{subsection.5.1.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{20}{subsection.5.1.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{21}{subsection.5.1.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{21}{subsection.5.1.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.9}substractRows}{21}{subsection.5.1.9}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{22}{subsection.5.1.10}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{22}{subsection.5.1.11}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.12}improveSolution}{22}{subsection.5.1.12}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.2}Task 3e code}{23}{section.5.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.1}jacobiMethod}{23}{subsection.5.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.2}initializeValues}{23}{subsection.5.2.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.3}decomposeMatrix}{23}{subsection.5.2.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.4}jacobiLoop}{24}{subsection.5.2.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.5}jacobiInsideLoop}{24}{subsection.5.2.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.6}jacobiEquation}{24}{subsection.5.2.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.7}checkError}{24}{subsection.5.2.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.8}endOfLoop}{25}{subsection.5.2.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.9}dispFinalResults}{25}{subsection.5.2.9}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.1}Task 2 Code}{21}{section.5.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.1}Main function}{21}{subsection.5.1.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{21}{subsection.5.1.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{23}{subsection.5.1.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{23}{subsection.5.1.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{23}{subsection.5.1.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{23}{subsection.5.1.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{24}{subsection.5.1.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{24}{subsection.5.1.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.9}substractRows}{24}{subsection.5.1.9}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{25}{subsection.5.1.10}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{25}{subsection.5.1.11}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.1.12}improveSolution}{25}{subsection.5.1.12}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {section}{\numberline {5.2}Task 3e code}{26}{section.5.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.1}jacobiMethod}{26}{subsection.5.2.1}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.2}initializeValues}{26}{subsection.5.2.2}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.3}decomposeMatrix}{26}{subsection.5.2.3}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.4}jacobiLoop}{27}{subsection.5.2.4}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.5}jacobiInsideLoop}{27}{subsection.5.2.5}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.6}jacobiEquation}{27}{subsection.5.2.6}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.7}checkError}{27}{subsection.5.2.7}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.8}endOfLoop}{28}{subsection.5.2.8}\protected@file@percent }
|
||||
\@writefile{toc}{\contentsline {subsection}{\numberline {5.2.9}dispFinalResults}{28}{subsection.5.2.9}\protected@file@percent }
|
||||
\bibcite{texbook}{1}
|
||||
\gdef \@abspage@last{27}
|
||||
\gdef \@abspage@last{30}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
# Fdb version 3
|
||||
["pdflatex"] 1636657884 "projectA.tex" "projectA.pdf" "projectA" 1636657885
|
||||
["pdflatex"] 1636674250 "projectA.tex" "projectA.pdf" "projectA" 1636674251
|
||||
"/etc/texmf/web2c/texmf.cnf" 1635008344 475 c0e671620eb5563b2130f56340a5fde8 ""
|
||||
"/usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc" 1165713224 4850 80dc9bab7f31fb78a000ccfed0e27cab ""
|
||||
"/usr/share/texlive/texmf-dist/fonts/map/fontname/texfonts.map" 1577235249 3524 cb3e574dea2d1052e39280babc910dc8 ""
|
||||
@ -150,13 +150,13 @@
|
||||
"/usr/share/texmf/web2c/texmf.cnf" 1613593815 38841 799d1dd9682a55ce442e10c99777ecc1 ""
|
||||
"/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map" 1635008389 5160710 ecf427ae8fa19139d8691f526e47bb9b ""
|
||||
"/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1635008460 2570450 6e12b1c097cbda0f70015645294afd24 ""
|
||||
"projectA.aux" 1636657885 8782 fe9b7a83c04a3411a9aabb9a6e36b06b "pdflatex"
|
||||
"projectA.out" 1636657885 3574 babd9dea9523219ec1d0de08283e32b8 "pdflatex"
|
||||
"projectA.tex" 1636657884 26895 00aae171a2d5f1aaa7d100bb1c2e6447 ""
|
||||
"projectA.toc" 1636657885 5132 e847c6fab76c656dfe514609ebbf1504 "pdflatex"
|
||||
"projectA.aux" 1636674251 9147 1c781f2a95bf085eea7f5be3d50ec764 "pdflatex"
|
||||
"projectA.out" 1636674251 3538 6fde6de672cc75e5d00cd405f1e383f3 "pdflatex"
|
||||
"projectA.tex" 1636674249 32686 d604dcc57cb90d2b237ac93e70e272eb ""
|
||||
"projectA.toc" 1636674251 5374 c3b887a47cd715424c93c048cb129139 "pdflatex"
|
||||
(generated)
|
||||
"projectA.aux"
|
||||
"projectA.pdf"
|
||||
"projectA.log"
|
||||
"projectA.out"
|
||||
"projectA.toc"
|
||||
"projectA.pdf"
|
||||
"projectA.aux"
|
||||
"projectA.log"
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.10.23) 11 NOV 2021 20:11
|
||||
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.10.23) 12 NOV 2021 00:44
|
||||
entering extended mode
|
||||
restricted \write18 enabled.
|
||||
file:line:error style messages enabled.
|
||||
@ -470,7 +470,7 @@ File: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
|
||||
{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./projectA.tocpdfTeX warning (ext4): destination with the same identifier (name{page.1}) has been already used, duplicate ignored
|
||||
<to be read again>
|
||||
\relax
|
||||
l.21 \newpage
|
||||
l.20 \newpage
|
||||
[1
|
||||
|
||||
])
|
||||
@ -515,13 +515,13 @@ Overfull \hbox (2.71124pt too wide) detected at line 162
|
||||
[]
|
||||
[]
|
||||
|
||||
[7] [8]
|
||||
Overfull \hbox (33.13576pt too wide) detected at line 268
|
||||
[7]
|
||||
Overfull \hbox (33.13576pt too wide) detected at line 265
|
||||
\OML/cmm/m/it/10 x[] \OT1/cmr/m/n/10 = [] \OML/cmm/m/it/10 x[] \OT1/cmr/m/n/10 = []
|
||||
[]
|
||||
|
||||
[9]
|
||||
Overfull \hbox (33.13576pt too wide) detected at line 311
|
||||
[8] [9]
|
||||
Overfull \hbox (33.13576pt too wide) detected at line 308
|
||||
\OML/cmm/m/it/10 x[] \OT1/cmr/m/n/10 = [] \OML/cmm/m/it/10 x[] \OT1/cmr/m/n/10 = []
|
||||
[]
|
||||
|
||||
@ -529,96 +529,91 @@ Overfull \hbox (33.13576pt too wide) detected at line 311
|
||||
Chapter 3.
|
||||
[11
|
||||
|
||||
] [12]
|
||||
./projectA.tex:472: Extra }, or forgotten $.
|
||||
l.472 l_{n1} & l_{n2} & l_{n3} & \cdots & 0}
|
||||
|
||||
I've deleted a group-closing symbol because it seems to be
|
||||
spurious, as in `$x}$'. But perhaps the } is legitimate and
|
||||
you forgot something else, as in `\hbox{$x}'. In such cases
|
||||
the way to recover is to insert both the forgotten and the
|
||||
deleted material, e.g., by typing `I$}'.
|
||||
] [12] [13] [14] [15] [16] [17]
|
||||
Overfull \hbox (5.74863pt too wide) in paragraph at lines 668--671
|
||||
\T1/cmr/m/n/10 low as $\OT1/cmr/m/n/10 1\OML/cmm/m/it/10 :\OT1/cmr/m/n/10 776356839400250\OML/cmm/m/it/10 e \OMS/cmsy/m/n/10 ^^@ \OT1/cmr/m/n/10 15$ \T1/cmr/m/n/10 with de-manded tol-er-ance = $\OT1/cmr/m/n/10 3\OML/cmm/m/it/10 :\OT1/cmr/m/n/10 202372833989376\OML/cmm/m/it/10 e \OMS/cmsy/m/n/10 ^^@
|
||||
[]
|
||||
|
||||
[13] [14] [15] [16]
|
||||
[18] [19]
|
||||
Chapter 4.
|
||||
[17
|
||||
[20
|
||||
|
||||
]
|
||||
Chapter 5.
|
||||
LaTeX Font Info: Trying to load font information for TS1+fvm on input line 590.
|
||||
LaTeX Font Info: Trying to load font information for TS1+fvm on input line 759.
|
||||
(/usr/share/texlive/texmf-dist/tex/latex/bera/ts1fvm.fd
|
||||
File: ts1fvm.fd 2004/09/07 scalable font definitions for TS1/fvm.
|
||||
)
|
||||
LaTeX Font Info: Font shape `TS1/fvm/m/n' will be
|
||||
(Font) scaled to size 8.50006pt on input line 590.
|
||||
[18
|
||||
(Font) scaled to size 8.50006pt on input line 759.
|
||||
[21
|
||||
|
||||
] [19] [20]
|
||||
] [22] [23]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 695.
|
||||
(textcomp) Default family used instead on input line 864.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 697.
|
||||
[21]
|
||||
(textcomp) Default family used instead on input line 866.
|
||||
[24]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 708.
|
||||
(textcomp) Default family used instead on input line 877.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 709.
|
||||
(textcomp) Default family used instead on input line 878.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 718.
|
||||
(textcomp) Default family used instead on input line 887.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 730.
|
||||
(textcomp) Default family used instead on input line 899.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 743.
|
||||
(textcomp) Default family used instead on input line 912.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 744.
|
||||
[22]
|
||||
(textcomp) Default family used instead on input line 913.
|
||||
[25]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 771.
|
||||
(textcomp) Default family used instead on input line 940.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 785.
|
||||
[23]
|
||||
(textcomp) Default family used instead on input line 954.
|
||||
[26]
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 796.
|
||||
(textcomp) Default family used instead on input line 965.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 819.
|
||||
(textcomp) Default family used instead on input line 988.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 831.
|
||||
(textcomp) Default family used instead on input line 1000.
|
||||
Package textcomp Info: Symbol \textminus not provided by
|
||||
(textcomp) font family fvm in TS1 encoding.
|
||||
(textcomp) Default family used instead on input line 833.
|
||||
[24] [25] [26
|
||||
(textcomp) Default family used instead on input line 1002.
|
||||
[27] [28] [29
|
||||
|
||||
] (./projectA.aux)
|
||||
Package rerunfilecheck Info: File `projectA.out' has not changed.
|
||||
(rerunfilecheck) Checksum: BABD9DEA9523219EC1D0DE08283E32B8;3574.
|
||||
(rerunfilecheck) Checksum: 6FDE6DE672CC75E5D00CD405F1E383F3;3538.
|
||||
)
|
||||
Here is how much of TeX's memory you used:
|
||||
12656 strings out of 479304
|
||||
219722 string characters out of 5869778
|
||||
945412 words of memory out of 5000000
|
||||
12665 strings out of 479304
|
||||
219803 string characters out of 5869778
|
||||
945400 words of memory out of 5000000
|
||||
29342 multiletter control sequences out of 15000+600000
|
||||
424556 words of font info for 76 fonts, out of 8000000 for 9000
|
||||
1141 hyphenation exceptions out of 8191
|
||||
81i,8n,88p,407b,2253s stack positions out of 5000i,500n,10000p,200000b,80000s
|
||||
{/usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-t1.enc}{/usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-ts1.enc}{/usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc}</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx7.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr5.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/bera/fvmr8a.pfb></usr/share/texmf/fonts/type1/pu
|
||||
blic/cm-super/sfbx1000.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfbx1200.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfbx1440.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfbx2074.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfbx2488.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm1000.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm1200.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfrm1728.pfb></usr/share/texmf/fonts/type1/public/cm-super/sfti1000.pfb>
|
||||
Output written on projectA.pdf (27 pages, 306614 bytes).
|
||||
Output written on projectA.pdf (30 pages, 315313 bytes).
|
||||
PDF statistics:
|
||||
738 PDF objects out of 1000 (max. 8388607)
|
||||
682 compressed objects within 7 object streams
|
||||
288 named destinations out of 1000 (max. 500000)
|
||||
409 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||
755 PDF objects out of 1000 (max. 8388607)
|
||||
696 compressed objects within 7 object streams
|
||||
297 named destinations out of 1000 (max. 500000)
|
||||
401 words of extra memory for PDF output out of 10000 (max. 10000000)
|
||||
|
||||
|
||||
@ -12,40 +12,39 @@
|
||||
\BOOKMARK [2][-]{subsection.2.2.1}{Transform matrix into upper-triangular matrix}{section.2.2}% 12
|
||||
\BOOKMARK [2][-]{subsection.2.2.2}{Backward substitution}{section.2.2}% 13
|
||||
\BOOKMARK [2][-]{subsection.2.2.3}{Partial Pivoting}{section.2.2}% 14
|
||||
\BOOKMARK [1][-]{section.2.3}{Solution}{chapter.2}% 15
|
||||
\BOOKMARK [1][-]{section.2.4}{Discussion of the result}{chapter.2}% 16
|
||||
\BOOKMARK [0][-]{chapter.3}{Problem 3 - Solving a system of n linear equations - iterative algorithm}{}% 17
|
||||
\BOOKMARK [1][-]{section.3.1}{Problem}{chapter.3}% 18
|
||||
\BOOKMARK [1][-]{section.3.2}{Theoretical introduction}{chapter.3}% 19
|
||||
\BOOKMARK [2][-]{subsection.3.2.1}{Procedure}{section.3.2}% 20
|
||||
\BOOKMARK [1][-]{section.3.3}{Solution}{chapter.3}% 21
|
||||
\BOOKMARK [1][-]{section.3.4}{Discussion of the result}{chapter.3}% 22
|
||||
\BOOKMARK [0][-]{chapter.4}{Problem 4 - QR method of finding eigenvalues}{}% 23
|
||||
\BOOKMARK [1][-]{section.4.1}{Problem}{chapter.4}% 24
|
||||
\BOOKMARK [1][-]{section.4.2}{Theoretical introduction}{chapter.4}% 25
|
||||
\BOOKMARK [1][-]{section.4.3}{Solution}{chapter.4}% 26
|
||||
\BOOKMARK [1][-]{section.4.4}{Discussion of the result}{chapter.4}% 27
|
||||
\BOOKMARK [0][-]{chapter.5}{Code appendix}{}% 28
|
||||
\BOOKMARK [1][-]{section.5.1}{Task 2 Code}{chapter.5}% 29
|
||||
\BOOKMARK [2][-]{subsection.5.1.1}{Main function}{section.5.1}% 30
|
||||
\BOOKMARK [2][-]{subsection.5.1.2}{checkIfMatrixIsSquareMatrix}{section.5.1}% 31
|
||||
\BOOKMARK [2][-]{subsection.5.1.3}{gaussianEliminationWithPartialPivoting}{section.5.1}% 32
|
||||
\BOOKMARK [2][-]{subsection.5.1.4}{partialPivoting}{section.5.1}% 33
|
||||
\BOOKMARK [2][-]{subsection.5.1.5}{partialPivotingSwapOneRow}{section.5.1}% 34
|
||||
\BOOKMARK [2][-]{subsection.5.1.6}{swapRowMatrix}{section.5.1}% 35
|
||||
\BOOKMARK [2][-]{subsection.5.1.7}{swapValueVector}{section.5.1}% 36
|
||||
\BOOKMARK [2][-]{subsection.5.1.8}{gaussianElimination}{section.5.1}% 37
|
||||
\BOOKMARK [2][-]{subsection.5.1.9}{substractRows}{section.5.1}% 38
|
||||
\BOOKMARK [2][-]{subsection.5.1.10}{backSubstitutionPhase}{section.5.1}% 39
|
||||
\BOOKMARK [2][-]{subsection.5.1.11}{iterativeResidualCorrection}{section.5.1}% 40
|
||||
\BOOKMARK [2][-]{subsection.5.1.12}{improveSolution}{section.5.1}% 41
|
||||
\BOOKMARK [1][-]{section.5.2}{Task 3e code}{chapter.5}% 42
|
||||
\BOOKMARK [2][-]{subsection.5.2.1}{jacobiMethod}{section.5.2}% 43
|
||||
\BOOKMARK [2][-]{subsection.5.2.2}{initializeValues}{section.5.2}% 44
|
||||
\BOOKMARK [2][-]{subsection.5.2.3}{decomposeMatrix}{section.5.2}% 45
|
||||
\BOOKMARK [2][-]{subsection.5.2.4}{jacobiLoop}{section.5.2}% 46
|
||||
\BOOKMARK [2][-]{subsection.5.2.5}{jacobiInsideLoop}{section.5.2}% 47
|
||||
\BOOKMARK [2][-]{subsection.5.2.6}{jacobiEquation}{section.5.2}% 48
|
||||
\BOOKMARK [2][-]{subsection.5.2.7}{checkError}{section.5.2}% 49
|
||||
\BOOKMARK [2][-]{subsection.5.2.8}{endOfLoop}{section.5.2}% 50
|
||||
\BOOKMARK [2][-]{subsection.5.2.9}{dispFinalResults}{section.5.2}% 51
|
||||
\BOOKMARK [1][-]{section.2.3}{Discussion of the result}{chapter.2}% 15
|
||||
\BOOKMARK [0][-]{chapter.3}{Problem 3 - Solving a system of n linear equations - iterative algorithm}{}% 16
|
||||
\BOOKMARK [1][-]{section.3.1}{Problem}{chapter.3}% 17
|
||||
\BOOKMARK [1][-]{section.3.2}{Theoretical introduction}{chapter.3}% 18
|
||||
\BOOKMARK [2][-]{subsection.3.2.1}{Procedure}{section.3.2}% 19
|
||||
\BOOKMARK [1][-]{section.3.3}{Discussion of the result}{chapter.3}% 20
|
||||
\BOOKMARK [2][-]{subsection.3.3.1}{Jacobi method result}{section.3.3}% 21
|
||||
\BOOKMARK [0][-]{chapter.4}{Problem 4 - QR method of finding eigenvalues}{}% 22
|
||||
\BOOKMARK [1][-]{section.4.1}{Problem}{chapter.4}% 23
|
||||
\BOOKMARK [1][-]{section.4.2}{Theoretical introduction}{chapter.4}% 24
|
||||
\BOOKMARK [1][-]{section.4.3}{Solution}{chapter.4}% 25
|
||||
\BOOKMARK [1][-]{section.4.4}{Discussion of the result}{chapter.4}% 26
|
||||
\BOOKMARK [0][-]{chapter.5}{Code appendix}{}% 27
|
||||
\BOOKMARK [1][-]{section.5.1}{Task 2 Code}{chapter.5}% 28
|
||||
\BOOKMARK [2][-]{subsection.5.1.1}{Main function}{section.5.1}% 29
|
||||
\BOOKMARK [2][-]{subsection.5.1.2}{checkIfMatrixIsSquareMatrix}{section.5.1}% 30
|
||||
\BOOKMARK [2][-]{subsection.5.1.3}{gaussianEliminationWithPartialPivoting}{section.5.1}% 31
|
||||
\BOOKMARK [2][-]{subsection.5.1.4}{partialPivoting}{section.5.1}% 32
|
||||
\BOOKMARK [2][-]{subsection.5.1.5}{partialPivotingSwapOneRow}{section.5.1}% 33
|
||||
\BOOKMARK [2][-]{subsection.5.1.6}{swapRowMatrix}{section.5.1}% 34
|
||||
\BOOKMARK [2][-]{subsection.5.1.7}{swapValueVector}{section.5.1}% 35
|
||||
\BOOKMARK [2][-]{subsection.5.1.8}{gaussianElimination}{section.5.1}% 36
|
||||
\BOOKMARK [2][-]{subsection.5.1.9}{substractRows}{section.5.1}% 37
|
||||
\BOOKMARK [2][-]{subsection.5.1.10}{backSubstitutionPhase}{section.5.1}% 38
|
||||
\BOOKMARK [2][-]{subsection.5.1.11}{iterativeResidualCorrection}{section.5.1}% 39
|
||||
\BOOKMARK [2][-]{subsection.5.1.12}{improveSolution}{section.5.1}% 40
|
||||
\BOOKMARK [1][-]{section.5.2}{Task 3e code}{chapter.5}% 41
|
||||
\BOOKMARK [2][-]{subsection.5.2.1}{jacobiMethod}{section.5.2}% 42
|
||||
\BOOKMARK [2][-]{subsection.5.2.2}{initializeValues}{section.5.2}% 43
|
||||
\BOOKMARK [2][-]{subsection.5.2.3}{decomposeMatrix}{section.5.2}% 44
|
||||
\BOOKMARK [2][-]{subsection.5.2.4}{jacobiLoop}{section.5.2}% 45
|
||||
\BOOKMARK [2][-]{subsection.5.2.5}{jacobiInsideLoop}{section.5.2}% 46
|
||||
\BOOKMARK [2][-]{subsection.5.2.6}{jacobiEquation}{section.5.2}% 47
|
||||
\BOOKMARK [2][-]{subsection.5.2.7}{checkError}{section.5.2}% 48
|
||||
\BOOKMARK [2][-]{subsection.5.2.8}{endOfLoop}{section.5.2}% 49
|
||||
\BOOKMARK [2][-]{subsection.5.2.9}{dispFinalResults}{section.5.2}% 50
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -50,12 +50,12 @@ Write a program finding macheps in the MATLAB environment
|
||||
\subsection{Definition of machine epsilion}
|
||||
Machine epsilion is the maximal possible relative error of the floating-point representation. (Tatjewski, p.14)
|
||||
Machine epsilion is equal to $2^{-t}$ where t is number of bits in the mantissa.
|
||||
In our case when we use IEEE Standard 754, mantissa is 53 bits long with first bit omitted as it is always equal to '1', so we technicaly work with 52 bits mantissa which makes the machine epsilion equal to: $2^{-52} = 2.220446\mathrm{e}{-16}$
|
||||
In our case when We use IEEE Standard 754, mantissa is 53 bits long with first bit omitted as it is always equal to '1', so We technicaly work with 52 bits mantissa which makes the machine epsilion equal to: $2^{-52} = 2.220446\mathrm{e}{-16}$
|
||||
|
||||
\subsection{Practical applications of machine epsilion}
|
||||
Since macheps is connected to IEEE754 standard it is always equal to the same number, which means that we can safely compare results from different machines without worrying about their individual errors.
|
||||
Since macheps is connected to IEEE754 standard it is always equal to the same number, which means that We can safely compare results from different machines without worrying about their individual errors.
|
||||
|
||||
Macheps is also essential when we calculate cumulation of errors of given mathematical operation.
|
||||
Macheps is also essential when We calculate cumulation of errors of given mathematical operation.
|
||||
|
||||
\newpage
|
||||
\section{Solution}
|
||||
@ -67,7 +67,7 @@ while 1.0 + macheps / 2 > 1.0
|
||||
macheps = macheps/2;
|
||||
end
|
||||
\end{lstlisting}
|
||||
Code above shifts macheps one bit to the right each iteration (by dividing by 2), it ends when we run out of mantissa bits which renders us unable to save smaller number. Due to underflow the value of macheps becomes 0 and therefore 1.0 > (macheps / 2) > 1.0 will become false.
|
||||
Code above shifts macheps one bit to the right each iteration (by dividing by 2), it ends when We run out of mantissa bits which renders us unable to save smaller number. Due to underflow the value of macheps becomes 0 and therefore 1.0 > (macheps / 2) > 1.0 will become false.
|
||||
|
||||
\section{Discussion of the result}
|
||||
\begin{simplechar}
|
||||
@ -135,7 +135,7 @@ We start with the system of linear equations looking like this:
|
||||
|
||||
In order for this method to work all the elements of "diagonal" line:
|
||||
\[ a_{11}, a_{22}, \dots, a_{nn} \]
|
||||
Must be different from zero since we will be dividing by them.
|
||||
Must be different from zero since We will be dividing by them.
|
||||
|
||||
We will denote rows as '$w_i$' where 'i' is number of the row.
|
||||
|
||||
@ -143,9 +143,9 @@ We will denote rows as '$w_i$' where 'i' is number of the row.
|
||||
We start transforming the system by "zeroing" elements in first column excluding first row element. We do it by multiplying first row by $l_{i1}$, where:
|
||||
\[ l_{i1} = \frac{ a_{i1}^{(1)} }
|
||||
{ a_{11}^{(1)} } \]
|
||||
And then substracting what we got ($ l_{i1}w_1 $), from \textit{i} row.
|
||||
And then substracting what We got ($ l_{i1}w_1 $), from \textit{i} row.
|
||||
|
||||
Doing so we obtain a system of linear equations:
|
||||
Doing so We obtain a system of linear equations:
|
||||
|
||||
\[
|
||||
\begin{matrix}
|
||||
@ -162,7 +162,7 @@ Doing so we obtain a system of linear equations:
|
||||
\]
|
||||
|
||||
\subsubsection{Zeroing second column}
|
||||
We continue onto the second column, this time we will zero all elements except first and second rows.
|
||||
We continue onto the second column, this time We will zero all elements except first and second rows.
|
||||
Row multiplier becomes:
|
||||
\[ l_{i2} = \frac{ a_{i2}^{(2)} }{ a_{22}^{(2)} } \]
|
||||
|
||||
@ -171,7 +171,7 @@ Where:
|
||||
And:
|
||||
\[ a_{i2}^{(2)} = (a_{i2} - a_{12}l_{i1}) \]
|
||||
They are modified values obtained from previous step.
|
||||
We continue as in the first step and we end up with:
|
||||
We continue as in the first step and We end up with:
|
||||
|
||||
\[
|
||||
\begin{matrix}
|
||||
@ -188,7 +188,7 @@ We continue as in the first step and we end up with:
|
||||
\]
|
||||
|
||||
\subsubsection{Zeroing next columns}
|
||||
We repeat this process $n-1$ times and we end up with upper triangular matrix:
|
||||
We repeat this process $n-1$ times and We end up with upper triangular matrix:
|
||||
|
||||
\[
|
||||
\begin{matrix}
|
||||
@ -205,8 +205,8 @@ We repeat this process $n-1$ times and we end up with upper triangular matrix:
|
||||
\]
|
||||
|
||||
\subsection{Backward substitution}
|
||||
After transforming the system we solve the system from last to first. \\
|
||||
First we calculate value of last element:
|
||||
After transforming the system We solve the system from last to first. \\
|
||||
First We calculate value of last element:
|
||||
\[ x_n = \frac{b_n}{a_{nn}} \]
|
||||
Then one "above":
|
||||
\[ x_{n-1} = \frac{ b_{n-1} - a_{n-1, n}x_n}{a_{n-1, n-1}} \]
|
||||
@ -216,15 +216,12 @@ And so on, for $x_k$:
|
||||
\subsection{Partial Pivoting}
|
||||
Gaussian elimination method has one flaw, where it can come into halt if:
|
||||
\[ a_{kk}^{(k)} = 0 \]
|
||||
To avoid it we use method of pivoting, in our case we will use partial pivoting method.
|
||||
To avoid it We use method of pivoting, in our case We will use partial pivoting method.
|
||||
We do it before each Gaussian elimination step since this will lead to smaller error.
|
||||
\\We first find a row $i$ such that:
|
||||
\[ |{a_{ik}^{k}}| = \underset{j}{max} \{ |{a_{kk}^{k}}|, |{a_{k+1, k}^{k}}|, \cdots, |{a_{nk}^{k}}|\} \]
|
||||
|
||||
Then we swap this row with k-th row. Since the matrix we use is assumed to be nonsingular then $|{a_{ik}^{k}}| \neq 0$ will be always true. After that we continue with the Gaussian elimination method.
|
||||
|
||||
\newpage
|
||||
\section{Solution}
|
||||
Then We swap this row with k-th row. Since the matrix We use is assumed to be nonsingular then $|{a_{ik}^{k}}| \neq 0$ will be always true. After that We continue with the Gaussian elimination method.
|
||||
|
||||
\section{Discussion of the result}
|
||||
Solutions vectors for matrix A and vector A and n = 16:
|
||||
@ -328,7 +325,7 @@ We are given following system:
|
||||
\systeme{10x_1-4x_2+x_3+2x_4=-8, 2x_1-6x_2+3x_3-x_4=-12, x_1+4x_2-12x_3+x_4=4, 2x_1+3x_2-3x_3-10x_4=1}
|
||||
\]
|
||||
|
||||
Then we need to compare the results of iterations plotting norm of the solution error versus the iteration number \textbf{k}, untill we get accuracy better than $10^{-10}$.
|
||||
Then We need to compare the results of iterations plotting norm of the solution error versus the iteration number \textbf{k}, untill We get accuracy better than $10^{-10}$.
|
||||
|
||||
We should also try to solve the equations from problem 2a) and 2b) for n = 10 using iterative method of our choice.
|
||||
|
||||
@ -337,13 +334,13 @@ We should also try to solve the equations from problem 2a) and 2b) for n = 10 us
|
||||
|
||||
We should also answer the question what happens if the sufficient condition is not fullfiled.
|
||||
|
||||
Itertaive methods differ from the Gauss elimination method since they are iterative, which means that our solution will improve with each iteration. Building on that we can cnclude that the number of iterations will depend on what accuracy we want to achieve. Since we are using iterative method we don't have the guarantee of how many iterations will be neeeded before we reach the solution,
|
||||
Itertaive methods differ from the Gauss elimination method since they are iterative, which means that our solution will improve with each iteration. Building on that We can cnclude that the number of iterations will depend on what accuracy We want to achieve. Since We are using iterative method We don't have the guarantee of how many iterations will be neeeded before We reach the solution,
|
||||
|
||||
In general:
|
||||
We start with:
|
||||
\textbf{$x^{(0)}$ } - being the best known approximation of the solution point
|
||||
|
||||
And we generate next vectors \textbf{$x^{i+1}$} in such way:
|
||||
And We generate next vectors \textbf{$x^{i+1}$} in such way:
|
||||
\[ \mathbf{x^{i+1}} = \mathbf{M}\mathbf{x^{(i)}} + \mathbf{w} \]
|
||||
|
||||
Where $\mathbf{M}$ is some matrix.
|
||||
@ -351,7 +348,7 @@ Where $\mathbf{M}$ is some matrix.
|
||||
\subsection{Procedure}
|
||||
|
||||
\subsubsection{Decomposing matrix}
|
||||
For both Jacobi and Gauss-Seidel method we first decompose starting matrix $ \mathbf{A} $ to:
|
||||
For both Jacobi and Gauss-Seidel method We first decompose starting matrix $ \mathbf{A} $ to:
|
||||
\[ \mathbf{A} = \mathbf{L} + \mathbf{D} + \mathbf{U} \]
|
||||
where:
|
||||
$ \mathbf{L} $ - Subdiagonal matrix
|
||||
@ -418,13 +415,13 @@ so:
|
||||
\]
|
||||
|
||||
\subsubsection{Jacobi's method}
|
||||
After decomposing matrix we can write the system of equations
|
||||
After decomposing matrix We can write the system of equations
|
||||
\[ \mathbf{A}\mathbf{x} = \mathbf{b} \]
|
||||
in the form:
|
||||
\[ \mathbf{D}\mathbf{x} = -(\mathbf{L}+\mathbf{U})\mathbf{x}+\mathbf{b}
|
||||
\]
|
||||
|
||||
If we assume that diagonal entries of matrix \textbf{A} are nonzero, then matrix \textbf{D} is nonsingular therefore we can propose such an iterative method:
|
||||
If We assume that diagonal entries of matrix \textbf{A} are nonzero, then matrix \textbf{D} is nonsingular therefore We can propose such an iterative method:
|
||||
\[ \mathbf{x}^{i+1} = -\mathbf{D}^{-1}(\mathbf{L}+\mathbf{U})\mathbf{x}^{(i)}+\mathbf{D}^{-1}\mathbf{x}
|
||||
\]
|
||||
This is the Jacobi's method.
|
||||
@ -436,23 +433,23 @@ We can rewritte this equation in the form of \textit{n} independent scalar equat
|
||||
) \]
|
||||
Where $d_{jj}$; $l_{jk}$; $u_{jk}$ are the elements of the respective matrixes \textbf{D}, \textbf{L}, \textbf{U}
|
||||
|
||||
Thanks to this we can do those computations in paraller, totally or partially if we are using a computer that enables a parallelization of the computations.
|
||||
Thanks to this We can do those computations in paraller, totally or partially if We are using a computer that enables a parallelization of the computations.
|
||||
|
||||
\paragraph{Converging}
|
||||
Jacobi's method is convergent if we have strong diagonal dominance of the matrix \textbf{A}
|
||||
Jacobi's method is convergent if We have strong diagonal dominance of the matrix \textbf{A}
|
||||
|
||||
|
||||
\subsubsection{Gauss-Seidel method}
|
||||
After decomposing matrix we can write the system of equations
|
||||
After decomposing matrix We can write the system of equations
|
||||
\[ \mathbf{A}\mathbf{x} = \mathbf{b} \]
|
||||
in the form:
|
||||
\[ (\mathbf{L}+\mathbf{D})\mathbf{x} = -\mathbf{U}\mathbf{x}+\mathbf{b}
|
||||
\]
|
||||
Again we assume that \textbf{D} is nonsingular, in doing so we propose following iterative method:
|
||||
Again We assume that \textbf{D} is nonsingular, in doing so We propose following iterative method:
|
||||
\[ \mathbf{D}\mathbf{x}^{(i+1)} = -\mathbf{L}\mathbf{x}^{(i+1)}-\mathbf{U}\mathbf{x}^{(i)}+\mathbf{b}
|
||||
\]
|
||||
Since matrix \textbf{L} is subdiagonal, provided that we organse the calculation of elements of the vector $x^{(i_1)}$ in a proper way, it does not hurt that $x^{(i_1)}$ is on the right side of the equation.
|
||||
In order to organise the calculation in the correct way we:
|
||||
Since matrix \textbf{L} is subdiagonal, provided that We organse the calculation of elements of the vector $x^{(i_1)}$ in a proper way, it does not hurt that $x^{(i_1)}$ is on the right side of the equation.
|
||||
In order to organise the calculation in the correct way We:
|
||||
First take into account the structure of matrixes \textbf{D} and \textbf{L}:
|
||||
\[
|
||||
\begin{bmatrix}
|
||||
@ -469,7 +466,7 @@ d_{nn}x_n^{(i_1)}
|
||||
l_{21} & 0 & 0 & \cdots & 0\\
|
||||
l_{32} & l_{32} & 0 & \cdots & 0\\
|
||||
\vdots & \vdots & \vdots & \vdots & \vdots\\
|
||||
l_{n1} & l_{n2} & l_{n3} & \cdots & 0}
|
||||
l_{n1} & l_{n2} & l_{n3} & \cdots & 0
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
x_1^{(i_1)}\\
|
||||
@ -497,18 +494,18 @@ As opposed to Jacobi's method, Gauss-Seidel method computations must be performe
|
||||
Gauss-Seidel method is convergent if the matrix \textbf{A} is strongly row or column diagonnaly dominant. If the matrix is symmetric, the method is also convergent if the matrix \textbf{A} is positive definite. This method is also usually faster convergent compared to Jacobi's method.
|
||||
|
||||
\subsubsection{Stop tests}
|
||||
There are two ways to check when to terminate iterations of the methods we just discussed:
|
||||
There are two ways to check when to terminate iterations of the methods We just discussed:
|
||||
\begin{enumerate}
|
||||
\item Check differences between two subsequent iteration points
|
||||
\[
|
||||
\| \mathbf{x}^{(i+1)} - \mathbf{x}^{(i)} \| \leq \delta
|
||||
\]
|
||||
Where $\delta$ is an assumed tolerance, (in our case $10^{-10}$). What we are really interested in though is whether the solution of the system of equation has required accuracy. If we want to check that we can additionaly check (higher level, more computationally demanding test):
|
||||
Where $\delta$ is an assumed tolerance, (in our case $10^{-10}$). What We are really interested in though is whether the solution of the system of equation has required accuracy. If We want to check that We can additionaly check (higher level, more computationally demanding test):
|
||||
\item Check differences between two subsequent iteration points
|
||||
\[
|
||||
\| \mathbf{A}\mathbf{x}^{(i+1)} - \mathbf{b}\| \leq \delta_2
|
||||
\]
|
||||
Where $\delta_2$ is an assumed tolerance. If this test is not passed then we can diminish the value of $\delta_2$ and continue with the iterations. Value of $\delta_2$ can not be too small since we are limited by the numerical errors.
|
||||
Where $\delta_2$ is an assumed tolerance. If this test is not passed then We can diminish the value of $\delta_2$ and continue with the iterations. Value of $\delta_2$ can not be too small since We are limited by the numerical errors.
|
||||
\end{enumerate}
|
||||
|
||||
\subsubsection{\textbf{A} and \textbf{b}}
|
||||
@ -562,11 +559,183 @@ So:
|
||||
\end{bmatrix}
|
||||
\]
|
||||
|
||||
|
||||
|
||||
\section{Solution}
|
||||
|
||||
\section{Discussion of the result}
|
||||
|
||||
\subsection{Jacobi method result}
|
||||
For system of equations We got in this task We got following results:
|
||||
\\
|
||||
Without the change in demanded tolerance:
|
||||
\[ x = \left( \begin{array}{cc}
|
||||
-0.076776098668341 \\
|
||||
2.105784262642568 \\
|
||||
0.395344797635474 \\
|
||||
0.397776619764909
|
||||
\end{array} \right)
|
||||
\]
|
||||
Error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 1.154375287358407e-10 \]
|
||||
We managed to do this in \textbf{38} iterations of our loop, and the demanded tolerance did not change. (This required small change in code where We ommited the part of code responsible for changing demandedTolerance if $ \| \mathbf{A}x-b \| > \delta_2) $ )
|
||||
|
||||
With the change in demanded tolerance:
|
||||
\[ x = \left( \begin{array}{cc}
|
||||
-0.076776098668341 \\
|
||||
2.105784262642568 \\
|
||||
0.395344797635474 \\
|
||||
0.397776619764909
|
||||
\end{array} \right)
|
||||
\]
|
||||
Error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 5.770361548895147e-11 \]
|
||||
We got this result in \textbf{37} iterations and demanded tolerance was equal to $2*10^{-10}$
|
||||
|
||||
Compared to matlab function
|
||||
\[ x_{matlab} = \left( \begin{array}{cc}
|
||||
-0.076776098662498 \\
|
||||
2.105784262636790 \\
|
||||
0.395344797637659 \\
|
||||
0.397776619767240 \\
|
||||
\end{array} \right)
|
||||
\]
|
||||
Matlab error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 4.070144838902081e-15 \]
|
||||
|
||||
For data from task 2a We got: \\
|
||||
Without change in demanded tolerance:
|
||||
\[ x_a = \left( \begin{array}{cc}
|
||||
-0.930024655108186 \\
|
||||
-1.223407298660663 \\
|
||||
-1.273530574212508 \\
|
||||
-1.230517757317628 \\
|
||||
-1.151356031082747 \\
|
||||
-1.056883669273682 \\
|
||||
-0.952628310081466 \\
|
||||
-0.834334594312996 \\
|
||||
-0.683708806198363 \\
|
||||
-0.450125157620744 \\
|
||||
\end{array} \right)
|
||||
\]
|
||||
Error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 6.955194519943778e-11 \]
|
||||
We managed to do this in \textbf{59} iterations of our loop, and the demanded tolerance did not change.
|
||||
|
||||
With change in demanded tolerance:
|
||||
\[ x_a = \left( \begin{array}{cc}
|
||||
-0.930024655104470 \\
|
||||
-1.223407298653515 \\
|
||||
-1.273530574202540 \\
|
||||
-1.230517757305602 \\
|
||||
-1.151356031069692 \\
|
||||
-1.056883669260597 \\
|
||||
-0.952628310069469 \\
|
||||
-0.834334594303006 \\
|
||||
-0.683708806191233 \\
|
||||
-0.450125157617020 \\
|
||||
\end{array} \right)
|
||||
\]
|
||||
Error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 1.699812218689508e-10 \]
|
||||
We managed to do this in \textbf{57} iterations of our loop, and the demanded tolerance changed to $4*10^{-10}$
|
||||
|
||||
Compared to matlab $ A \ b $ function
|
||||
\[ x_{matlab} = \left( \begin{array}{cc}
|
||||
-0.930024655110760 \\
|
||||
-1.223407298665612 \\
|
||||
-1.273530574219411 \\
|
||||
-1.230517757325956 \\
|
||||
-1.151356031091789 \\
|
||||
-1.056883669282743 \\
|
||||
-0.952628310089775 \\
|
||||
-0.834334594319914 \\
|
||||
-0.683708806203301 \\
|
||||
-0.450125157623323 \\
|
||||
\end{array} \right)
|
||||
\]
|
||||
Matlab error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 3.662053438817790e-15 \]
|
||||
|
||||
For Matrix and Vector from task 2b) error of
|
||||
\[ \| x^{(i+1)} - x^{(i)} \| \]
|
||||
grew to infinity, therefore We could never achieve demanded tolerance, therefore the program executed infinite loop.
|
||||
|
||||
\subsubsection{Minimizing the demanded error}
|
||||
We tried to minimize the demanded error using this steps:
|
||||
\begin{enumerate}
|
||||
\item We copied error from matlab function and pasted it into demanded tolerance.
|
||||
\item If We did not get infinite loop We copied the newly acquired error and pasted it into demanded tolerance.
|
||||
\item If We got inifinite loop We used the previous error as "minimal" demanded error.
|
||||
\end{enumerate}
|
||||
\paragraph{For original system of equations:}
|
||||
We managed to get results with error as low as $1.776356839400250e-15$ with demanded tolerance = $3.202372833989376e-15$ for lower values program went into infinite loop.
|
||||
Results for demanded tolerance = $3.202372833989376e-15$
|
||||
For given matrix:
|
||||
\[ x = \left( \begin{array}{cc}
|
||||
-0.076776098662498 \\
|
||||
2.105784262636790 \\
|
||||
0.395344797637659 \\
|
||||
0.397776619767240
|
||||
\end{array} \right)
|
||||
\]
|
||||
Error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 3.108624468950438e-15 \]
|
||||
We got this result in \textbf{53} iterations and demanded tolerance did not change.
|
||||
|
||||
\paragraph{For task 2a) system of equations:}
|
||||
We managed to get results with error as low as
|
||||
\[ 3.108624468950438e-15 \] with demanded tolerance:
|
||||
\[ 3.202372833989376e-15 \]
|
||||
for lower values program went into infinite loop.
|
||||
|
||||
For demanded tolerance = $3.202372833989376e-15$:
|
||||
Results for 2a) system of equation
|
||||
|
||||
\[ x_a = \left( \begin{array}{cc}
|
||||
-0.930024655110760 \\
|
||||
-1.223407298665613 \\
|
||||
-1.273530574219411 \\
|
||||
-1.230517757325955 \\
|
||||
-1.151356031091788 \\
|
||||
-1.056883669282743 \\
|
||||
-0.952628310089775 \\
|
||||
-0.834334594319914 \\
|
||||
-0.683708806203301 \\
|
||||
-0.450125157623323
|
||||
\end{array} \right)
|
||||
\]
|
||||
Error:
|
||||
\[ r = \| \mathbf{A}\mathbf{x} - \mathbf{b}\| = 3.108624468950438e-15 \]
|
||||
We managed to do this in \textbf{84} iterations of our loop, and the demanded tolerance did not change.
|
||||
We managed to achieve slightly better (as in, the error was smaller) results than Matlab custom function.
|
||||
|
||||
\paragraph{Table}
|
||||
|
||||
\begin{center}
|
||||
\resizebox{\textwidth}{!}{
|
||||
\begin{tabular}{||c c c c c c||}
|
||||
\hline
|
||||
system of equations & method & demanded tolerance & final demanded tolerance & error & iterations \\
|
||||
\hline
|
||||
task 3 system & Jacobi method & 10e-10 & 10e-10 & 1.154375287358407e-10 & 38 \\
|
||||
\hline
|
||||
task 3 system & Jacobi method & 10e-10 & 20e-10 & 5.770361548895147e-11 & 37 \\
|
||||
\hline
|
||||
task 3 system & Jacobi method & 3.202372833989376e-15 & 3.202372833989376e-15 & 3.108624468950438e-15 & 53 \\
|
||||
\hline
|
||||
task 3 system & Matlab function & ? & ? & 4.070144838902081e-15 & ? \\
|
||||
\hline
|
||||
task 2a) system & Jacobi method & 10e-10 & 10e-10 & 6.955194519943778e-11 & 59 \\
|
||||
\hline
|
||||
task 2a) system & Jacobi method & 10e-10 & 40e-10 & 1.699812218689508e-10 & 57 \\
|
||||
\hline
|
||||
task 2a) system & Jacob method & 3.202372833989376e-15 & 3.202372833989376e-15 & 3.108624468950438e-15 & 84 \\
|
||||
\hline
|
||||
task 2a) system & Matlab function & ? & ? & 3.662053438817790e-15 & ? \\
|
||||
\hline
|
||||
|
||||
\end{tabular}}
|
||||
\end{center}
|
||||
|
||||
|
||||
|
||||
\chapter{Problem 4 - QR method of finding eigenvalues}
|
||||
|
||||
\section{Problem}
|
||||
@ -587,7 +756,7 @@ So:
|
||||
function x = indicatedMethod(Matrix, Vector) % Name of the method as in the textbook
|
||||
% x stands for obtained result
|
||||
[~,Columns] = size(Matrix); % We need to know how big the matrix is in next steps
|
||||
% notice the '~', since we assume we use square matrix, we do not need
|
||||
% notice the '~', since We assume We use square matrix, We do not need
|
||||
% to have another variable for number of rows since it is the same as
|
||||
% number of columns
|
||||
checkIfMatrixIsSquareMatrix(Matrix);
|
||||
@ -619,7 +788,7 @@ end % end function
|
||||
function [Matrix, Vector] = gaussianEliminationWithPartialPivoting(Columns, Matrix, Vector)
|
||||
for j = 1 : Columns
|
||||
centralElement = max(Matrix(j:Columns,j));
|
||||
% we stay in the same row (j) but we change columns, as in the
|
||||
% We stay in the same row (j) but We change columns, as in the
|
||||
% textbook
|
||||
[Matrix, Vector] = partialPivoting(Matrix, Vector, j, centralElement, Columns);
|
||||
% ensures that a_kk != 0 and reduces errors
|
||||
@ -706,18 +875,18 @@ end % end function
|
||||
\begin{lstlisting}
|
||||
function [Matrix, Vector, x] = backSubstitutionPhase(Columns, Matrix, Vector)
|
||||
for k = Columns : -1 : 1
|
||||
% Start at final column and move by -1 each iteration until we reach 1
|
||||
% Start at final column and move by -1 each iteration until We reach 1
|
||||
equation = 0;
|
||||
for j = k+1 : Columns
|
||||
equation = equation + Matrix(k,j) * x(j, 1);
|
||||
% even though x is a vector we still need to put '1' to ensure
|
||||
% even though x is a vector We still need to put '1' to ensure
|
||||
% that number of columns in the first matrix matches number of
|
||||
% rows in second matrix
|
||||
end % end for
|
||||
|
||||
x(k, 1) = (Vector(k,1) - equation) / Matrix(k,k);
|
||||
% even though x is a vector we still need to put '1' to ensure
|
||||
% that we do not exceed array bounds
|
||||
% even though x is a vector We still need to put '1' to ensure
|
||||
% that We do not exceed array bounds
|
||||
end % end for
|
||||
end % end function
|
||||
\end{lstlisting}
|
||||
@ -780,10 +949,10 @@ end
|
||||
function [L, D, U] = decomposeMatrix(Matrix)
|
||||
D = diag(diag(Matrix));
|
||||
U = triu(Matrix, 1); % Generates upper triangular part of matrix
|
||||
% where the second variable denotes on which diagonal of matrix should we
|
||||
% where the second variable denotes on which diagonal of matrix should We
|
||||
% start
|
||||
L = tril(Matrix, -1); % Generates lower triangular part of matrix
|
||||
% where the second variable denotes on which diagonal of matrix should we
|
||||
% where the second variable denotes on which diagonal of matrix should We
|
||||
% start
|
||||
end
|
||||
\end{lstlisting}
|
||||
|
||||
@ -16,8 +16,7 @@
|
||||
\contentsline {subsubsection}{Zeroing next columns}{7}{section*.5}%
|
||||
\contentsline {subsection}{\numberline {2.2.2}Backward substitution}{8}{subsection.2.2.2}%
|
||||
\contentsline {subsection}{\numberline {2.2.3}Partial Pivoting}{8}{subsection.2.2.3}%
|
||||
\contentsline {section}{\numberline {2.3}Solution}{9}{section.2.3}%
|
||||
\contentsline {section}{\numberline {2.4}Discussion of the result}{9}{section.2.4}%
|
||||
\contentsline {section}{\numberline {2.3}Discussion of the result}{9}{section.2.3}%
|
||||
\newpage
|
||||
\contentsline {chapter}{\numberline {3}Problem 3 - Solving a system of n linear equations - iterative algorithm}{11}{chapter.3}%
|
||||
\contentsline {section}{\numberline {3.1}Problem}{11}{section.3.1}%
|
||||
@ -30,34 +29,38 @@
|
||||
\contentsline {paragraph}{Converging}{15}{section*.10}%
|
||||
\contentsline {subsubsection}{Stop tests}{15}{section*.11}%
|
||||
\contentsline {subsubsection}{\textbf {A} and \textbf {b}}{15}{section*.12}%
|
||||
\contentsline {section}{\numberline {3.3}Solution}{16}{section.3.3}%
|
||||
\contentsline {section}{\numberline {3.4}Discussion of the result}{16}{section.3.4}%
|
||||
\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{17}{chapter.4}%
|
||||
\contentsline {section}{\numberline {4.1}Problem}{17}{section.4.1}%
|
||||
\contentsline {section}{\numberline {4.2}Theoretical introduction}{17}{section.4.2}%
|
||||
\contentsline {section}{\numberline {4.3}Solution}{17}{section.4.3}%
|
||||
\contentsline {section}{\numberline {4.4}Discussion of the result}{17}{section.4.4}%
|
||||
\contentsline {chapter}{\numberline {5}Code appendix}{18}{chapter.5}%
|
||||
\contentsline {section}{\numberline {5.1}Task 2 Code}{18}{section.5.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.1}Main function}{18}{subsection.5.1.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{18}{subsection.5.1.2}%
|
||||
\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{20}{subsection.5.1.3}%
|
||||
\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{20}{subsection.5.1.4}%
|
||||
\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{20}{subsection.5.1.5}%
|
||||
\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{20}{subsection.5.1.6}%
|
||||
\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{21}{subsection.5.1.7}%
|
||||
\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{21}{subsection.5.1.8}%
|
||||
\contentsline {subsection}{\numberline {5.1.9}substractRows}{21}{subsection.5.1.9}%
|
||||
\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{22}{subsection.5.1.10}%
|
||||
\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{22}{subsection.5.1.11}%
|
||||
\contentsline {subsection}{\numberline {5.1.12}improveSolution}{22}{subsection.5.1.12}%
|
||||
\contentsline {section}{\numberline {5.2}Task 3e code}{23}{section.5.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.1}jacobiMethod}{23}{subsection.5.2.1}%
|
||||
\contentsline {subsection}{\numberline {5.2.2}initializeValues}{23}{subsection.5.2.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.3}decomposeMatrix}{23}{subsection.5.2.3}%
|
||||
\contentsline {subsection}{\numberline {5.2.4}jacobiLoop}{24}{subsection.5.2.4}%
|
||||
\contentsline {subsection}{\numberline {5.2.5}jacobiInsideLoop}{24}{subsection.5.2.5}%
|
||||
\contentsline {subsection}{\numberline {5.2.6}jacobiEquation}{24}{subsection.5.2.6}%
|
||||
\contentsline {subsection}{\numberline {5.2.7}checkError}{24}{subsection.5.2.7}%
|
||||
\contentsline {subsection}{\numberline {5.2.8}endOfLoop}{25}{subsection.5.2.8}%
|
||||
\contentsline {subsection}{\numberline {5.2.9}dispFinalResults}{25}{subsection.5.2.9}%
|
||||
\contentsline {section}{\numberline {3.3}Discussion of the result}{16}{section.3.3}%
|
||||
\contentsline {subsection}{\numberline {3.3.1}Jacobi method result}{16}{subsection.3.3.1}%
|
||||
\contentsline {subsubsection}{Minimizing the demanded error}{18}{section*.13}%
|
||||
\contentsline {paragraph}{For original system of equations:}{18}{section*.14}%
|
||||
\contentsline {paragraph}{For task 2a) system of equations:}{19}{section*.15}%
|
||||
\contentsline {paragraph}{Table}{19}{section*.16}%
|
||||
\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{20}{chapter.4}%
|
||||
\contentsline {section}{\numberline {4.1}Problem}{20}{section.4.1}%
|
||||
\contentsline {section}{\numberline {4.2}Theoretical introduction}{20}{section.4.2}%
|
||||
\contentsline {section}{\numberline {4.3}Solution}{20}{section.4.3}%
|
||||
\contentsline {section}{\numberline {4.4}Discussion of the result}{20}{section.4.4}%
|
||||
\contentsline {chapter}{\numberline {5}Code appendix}{21}{chapter.5}%
|
||||
\contentsline {section}{\numberline {5.1}Task 2 Code}{21}{section.5.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.1}Main function}{21}{subsection.5.1.1}%
|
||||
\contentsline {subsection}{\numberline {5.1.2}checkIfMatrixIsSquareMatrix}{21}{subsection.5.1.2}%
|
||||
\contentsline {subsection}{\numberline {5.1.3}gaussianEliminationWithPartialPivoting}{23}{subsection.5.1.3}%
|
||||
\contentsline {subsection}{\numberline {5.1.4}partialPivoting}{23}{subsection.5.1.4}%
|
||||
\contentsline {subsection}{\numberline {5.1.5}partialPivotingSwapOneRow}{23}{subsection.5.1.5}%
|
||||
\contentsline {subsection}{\numberline {5.1.6}swapRowMatrix}{23}{subsection.5.1.6}%
|
||||
\contentsline {subsection}{\numberline {5.1.7}swapValueVector}{24}{subsection.5.1.7}%
|
||||
\contentsline {subsection}{\numberline {5.1.8}gaussianElimination}{24}{subsection.5.1.8}%
|
||||
\contentsline {subsection}{\numberline {5.1.9}substractRows}{24}{subsection.5.1.9}%
|
||||
\contentsline {subsection}{\numberline {5.1.10}backSubstitutionPhase}{25}{subsection.5.1.10}%
|
||||
\contentsline {subsection}{\numberline {5.1.11}iterativeResidualCorrection}{25}{subsection.5.1.11}%
|
||||
\contentsline {subsection}{\numberline {5.1.12}improveSolution}{25}{subsection.5.1.12}%
|
||||
\contentsline {section}{\numberline {5.2}Task 3e code}{26}{section.5.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.1}jacobiMethod}{26}{subsection.5.2.1}%
|
||||
\contentsline {subsection}{\numberline {5.2.2}initializeValues}{26}{subsection.5.2.2}%
|
||||
\contentsline {subsection}{\numberline {5.2.3}decomposeMatrix}{26}{subsection.5.2.3}%
|
||||
\contentsline {subsection}{\numberline {5.2.4}jacobiLoop}{27}{subsection.5.2.4}%
|
||||
\contentsline {subsection}{\numberline {5.2.5}jacobiInsideLoop}{27}{subsection.5.2.5}%
|
||||
\contentsline {subsection}{\numberline {5.2.6}jacobiEquation}{27}{subsection.5.2.6}%
|
||||
\contentsline {subsection}{\numberline {5.2.7}checkError}{27}{subsection.5.2.7}%
|
||||
\contentsline {subsection}{\numberline {5.2.8}endOfLoop}{28}{subsection.5.2.8}%
|
||||
\contentsline {subsection}{\numberline {5.2.9}dispFinalResults}{28}{subsection.5.2.9}%
|
||||
|
||||
@ -56,3 +56,5 @@ https://www.overleaf.com/learn/latex/Matrices - matrixes latex
|
||||
https://tex.stackexchange.com/questions/294561/using-textbf-vs-mathbf-in-math-mode - mathbf vs textbf
|
||||
|
||||
https://www.math-linux.com/latex-26/faq/latex-faq/article/how-to-get-dots-in-latex-ldots-cdots-vdots-and-ddots - Dots LaTeX
|
||||
|
||||
https://www.overleaf.com/learn/latex/Tables - Tables LaTeX
|
||||
|
||||
Loading…
Reference in New Issue
Block a user