Keep remote branch up to date

This commit is contained in:
PolishPigeon 2021-11-06 00:26:00 +01:00
parent 31a5680446
commit 159ae4e1e9
19 changed files with 549 additions and 60 deletions

71
ENUME/projectA/debilMode Normal file
View File

@ -0,0 +1,71 @@
% ------- Solving a system of n linear equations Ax = b. ------- %
% -------------------- The Indicated Method -------------------- %
function x = Indicated_Method(A, b)
[M,N] = size(A);
if M ~= N
error ('A is not square matrix!');
end
for j = 1 : N - 1
%--- Find the greatest value within column ---%
m = max(A(j:N,j));
%--- Find row whitin greatest value occure ---%
for k = j : N
if A(k,j) == m
%--- SwapRow in matrix A ---%
tempRow = A(j , :);
A(j , :) = A(k, :);
A(k, :) = tempRow;
%--- SwapValue in vector b ---%
tempVal = b(j);
b(j) = b(k);
b(k) = tempVal;
break;
end
end
for i = j + 1 : N
l = A(i,j) / A(j,j);
b(i,1) = b(i,1) - l * b(j, 1);
for t = 1 : N
A(i,t) = A(i,t) - l * A(j, t);
end
end
end
x = zeros(N,1);
% -------------------- The back-substitution phase -------------------- %
for k = N : -1 : 1
E = 0;
for iter = k+1 : N
E = E + A(k,iter) * x(iter,1);
end
x(k, 1) = (b(k,1) - E) / A(k,k);
end
euclideanNormOfR = norm(r);
r = A*x - b;
euclideanNormOfR = norm(r);
new_euclideanNormOfR = euclideanNormOfR;
while new_euclideanNormOfR <= euclideanNormOfR
euclideanNormOfR = new_euclideanNormOfR;
r = A*x - b;
x = x - r;
new_euclideanNormOfR = norm(r);
end

View File

@ -0,0 +1,71 @@
% ------- Solving a system of n linear equations Ax = b. ------- %
% -------------------- The Indicated Method -------------------- %
function x = debilMode(A, b)
[M,N] = size(A);
if M ~= N
error ('A is not square matrix!');
end % end if
for j = 1 : N - 1
%--- Find the greatest value within column ---%
m = max(A(j:N,j));
%--- Find row whitin greatest value occure ---%
for k = j : N
if A(k,j) == m
%--- SwapRow in matrix A ---%
tempRow = A(j , :);
A(j , :) = A(k, :);
A(k, :) = tempRow;
%--- SwapValue in vector b ---%
tempVal = b(j);
b(j) = b(k);
b(k) = tempVal;
break;
end % end if
end % end for
for i = j + 1 : N
l = A(i,j) / A(j,j);
b(i,1) = b(i,1) - l * b(j, 1);
for t = 1 : N
A(i,t) = A(i,t) - l * A(j, t);
end % end for
end % end for
end
x = zeros(N,1);
% -------------------- The back-substitution phase -------------------- %
for k = N : -1 : 1
E = 0;
for iter = k+1 : N
E = E + A(k,iter) * x(iter,1);
end
x(k, 1) = (b(k,1) - E) / A(k,k);
end
r = A*x - b;
euclideanNormOfR = norm(r);
new_euclideanNormOfR = euclideanNormOfR;
while new_euclideanNormOfR <= euclideanNormOfR
euclideanNormOfR = new_euclideanNormOfR;
r = A*x - b;
x = x - r;
new_euclideanNormOfR = norm(r);
end
end % end function

View File

@ -0,0 +1,67 @@
% ------- Solving a system of n linear equations Ax = b. ------- %
% -------------------- The Indicated Method -------------------- %
function x = debilMode(A, b)
[M,N] = size(A);
if M ~= N
error ('A is not square matrix!');
end % end if
for j = 1 : N - 1
%--- Find the greatest value within column ---%
m = max(A(j:N,j));
%--- Find row whitin greatest value occure ---%
for k = j : N
if A(k,j) == m
%--- SwapRow in matrix A ---%
tempRow = A(j , :);
A(j , :) = A(k, :);
A(k, :) = tempRow;
%--- SwapValue in vector b ---%
tempVal = b(j);
b(j) = b(k);
b(k) = tempVal;
break;
end % end if
end % end for
for i = j + 1 : N
l = A(i,j) / A(j,j);
b(i,1) = b(i,1) - l * b(j, 1);
for t = 1 : N
A(i,t) = A(i,t) - l * A(j, t);
end % end for
end % end for
end % end for
x = zeros(N,1);
% -------------------- The back-substitution phase -------------------- %
for k = N : -1 : 1
E = 0;
for iter = k+1 : N
E = E + A(k,iter) * x(iter,1);
end % end for
x(k, 1) = (b(k,1) - E) / A(k,k);
end % end for
r = A*x - b;
euclideanNormOfR = norm(r);
new_euclideanNormOfR = euclideanNormOfR;
while new_euclideanNormOfR <= euclideanNormOfR
euclideanNormOfR = new_euclideanNormOfR;
r = A*x - b;
x = x - r;
new_euclideanNormOfR = norm(r);
end % end while
end % end function

View File

@ -1,9 +1,9 @@
macheps = 1;
while 1.0 + macheps / 2 > 1.0;
while 1.0 + macheps / 2 > 1.0
macheps = macheps/2;
end;
end
format long;
format long;
disp("Display calculated macheps:")
disp(macheps)
disp("Display actual eps:")

View File

@ -0,0 +1,61 @@
function x = gaussianElimination(A, b) % A - matrix, b - vector
[~, Height] = size(A);
% Find column with greatest value element
for i = 1 : Height - 1
m = max(A(i:Height, i));
% Find row with greatest value element
for k = i : Height
if A(k, i) == m % If the element has the biggest value we now
% have the value of two rows that we want to swap
% Swap row in matrix A %
swapRow(A, i, k);
swapValue(b, i, k);
break;
end % end if
end % end for
% Swap value in vector B %
end % end for
for j = i + 1 : Height
l = A(j, i) / A(i, i);
b(j, 1) = b(j, 1) - l * b(i, 1);
for t = 1 : Height
A(j, t) = A(j, t) - l * A(i, t);
end % end for
end % end for
x = zeros(Height, 1);
for k = Height: -1:1
E = 0;
for iter = k + 1 : Height
E = E + A(k, iter) * x(iter, 1);
end
x(k, 1) = (b(k, 1) - E) / A(k, k);
end
end % end function
function swapRow(A, j, k)
temp = A(j, :);
A(j, :) = A(k, :);
A(k, :) = temp;
end % end function
function swapValue(b, j, k)
temp = b(j);
b(j) = b(k);
b(k) = temp;
end % end function

View File

@ -0,0 +1,61 @@
function x = gaussianElimination(A, b) % A - matrix, b - vector
[~, Height] = size(A);
% Find column with greatest value element
for i = 1 : Height - 1
m = max(A(i:Height, i));
% Find row with greatest value element
for k = i : Height
if A(k, i) == m % If the element has the biggest value we now
% have the value of two rows that we want to swap
% Swap row in matrix A %
swapRow(A, i, k);
swapValue(b, i, k);
break;
end % end if
end % end for
% Swap value in vector B %
end % end for
for j = i + 1 : Height
l = A(j, i) / A(i, i);
b(j, 1) = b(j, 1) - l * b(i, 1);
for t = 1 : Height
A(j, t) = A(j, t) - l * A(i, t);
end % end for
end % end for
x = zeros(Height, 1);
for k = Height: -1:1
E = 0;
for iter = k + 1 : Height
E = E + A(k, iter) * x(iter, 1);
end
x(k, 1) = (b(k, 1) - E) / A(k, k);
end
end % end function
function swapRow(A, j, k)
temp = A(j, :);
A(j, :) = A(k, :);
A(k, :) = temp;
end % end function
function swapValue(b, j, k)
temp = b(j);
b(j) = b(k);
b(k) = temp;
end % end function

14
ENUME/projectA/matrixA.m Normal file
View File

@ -0,0 +1,14 @@
function a = matrixA(n) % We want n rows and columns in the matrix
a = zeros(n, n); % in order to save speed we preallocate zeros to the vector
for i = 1 : n % we iterate through rows
for j = 1 : n % we iterate through columns
if i == j % as per problem description on how to fill the matrix
a(i, j) = 9;
elseif i == j - 1 || i == j + 1
a(i, j) = -3;
else
a(i, j) = 0;
end % end if
end % end column for
end % end row for
end % end function

8
ENUME/projectA/matrixB.m Normal file
View File

@ -0,0 +1,8 @@
function a = matrixB(n) % We want n rows and columns in the matrix
a = zeros(n, n); % in order to save speed we preallocate zeros to the vector
for i = 1 : n % we iterate through rows
for j = 1 : n % we iterate through columns
a(i, j) = 5 / (8*(i + j + 1));
end % end column for
end % end row for
end % end function

View File

@ -32,23 +32,27 @@
\@writefile{toc}{\contentsline {section}{\numberline {2.1}Problem}{5}{section.2.1}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2.2}Theoretical Introduction}{5}{section.2.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.1}Transform system of equation into an upper-triangular matrix}{5}{subsection.2.2.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.2}Backward substitution}{6}{subsection.2.2.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.3}Partial Pivoting}{6}{subsection.2.2.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2.3}Solution}{6}{section.2.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2.4}Discussion of the result}{6}{section.2.4}\protected@file@percent }
\@writefile{toc}{\contentsline {chapter}{\numberline {3}Problem 3 - Solving a system of n linear equations - iterative algorithm}{7}{chapter.3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{Starting conditions}{5}{section*.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{Zeroing first column}{6}{section*.3}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{Zeroing second column}{6}{section*.4}\protected@file@percent }
\@writefile{toc}{\contentsline {subsubsection}{Zeroing next columns}{6}{section*.5}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.2}Backward substitution}{7}{subsection.2.2.2}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2.3}Partial Pivoting}{7}{subsection.2.2.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2.3}Solution}{7}{section.2.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2.4}Discussion of the result}{7}{section.2.4}\protected@file@percent }
\@writefile{toc}{\contentsline {chapter}{\numberline {3}Problem 3 - Solving a system of n linear equations - iterative algorithm}{8}{chapter.3}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {3.1}Problem}{7}{section.3.1}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3.2}Theoretical introduction}{7}{section.3.2}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3.3}Solution}{7}{section.3.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3.4}Discussion of the result}{7}{section.3.4}\protected@file@percent }
\@writefile{toc}{\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{8}{chapter.4}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3.1}Problem}{8}{section.3.1}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3.2}Theoretical introduction}{8}{section.3.2}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3.3}Solution}{8}{section.3.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3.4}Discussion of the result}{8}{section.3.4}\protected@file@percent }
\@writefile{toc}{\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{9}{chapter.4}\protected@file@percent }
\@writefile{lof}{\addvspace {10\p@ }}
\@writefile{lot}{\addvspace {10\p@ }}
\@writefile{toc}{\contentsline {section}{\numberline {4.1}Problem}{8}{section.4.1}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4.2}Theoretical introduction}{8}{section.4.2}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4.3}Solution}{8}{section.4.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4.4}Discussion of the result}{8}{section.4.4}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4.1}Problem}{9}{section.4.1}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4.2}Theoretical introduction}{9}{section.4.2}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4.3}Solution}{9}{section.4.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4.4}Discussion of the result}{9}{section.4.4}\protected@file@percent }
\bibcite{texbook}{1}
\gdef \@abspage@last{10}
\gdef \@abspage@last{11}

View File

@ -1,5 +1,5 @@
# Fdb version 3
["pdflatex"] 1635348912 "projectA.tex" "projectA.pdf" "projectA" 1635348913
["pdflatex"] 1635438957 "projectA.tex" "projectA.pdf" "projectA" 1635449229
"/etc/texmf/web2c/texmf.cnf" 1624878795 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 ""
@ -36,6 +36,7 @@
"/usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmtt10.tfm" 1136768653 768 1321e9409b4137d6fb428ac9dc956269 ""
"/usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmtt12.tfm" 1136768653 772 9a936b7f5e2ff0557fce0f62822f0bbf ""
"/usr/share/texlive/texmf-dist/fonts/tfm/public/cm/cmtt8.tfm" 1136768653 768 d7b9a2629a0c353102ad947dc9221d49 ""
"/usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb" 1248133631 30251 6afa5cb1d0204815a708a080681d4674 ""
"/usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb" 1248133631 36299 5f9df58c2139e7edcf37c8fca4bd384d ""
"/usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb" 1248133631 36281 c355509802a035cadc5f15869451dcee ""
"/usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb" 1248133631 35752 024fb6c41858982481f6968b5fc26508 ""
@ -136,13 +137,13 @@
"/usr/share/texmf/web2c/texmf.cnf" 1613593815 38841 799d1dd9682a55ce442e10c99777ecc1 ""
"/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map" 1624878842 5160710 ecf427ae8fa19139d8691f526e47bb9b ""
"/var/lib/texmf/web2c/pdftex/pdflatex.fmt" 1624878876 2570852 ef2a47e64eb64912b01ccaedc81044b8 ""
"projectA.aux" 1635348913 4335 5c7a0e7f58354c8c6fe36e5eee5261a5 "pdflatex"
"projectA.out" 1635348913 1864 f5c30b186e6644a7cbcb08ae397fee3f "pdflatex"
"projectA.tex" 1635348912 4722 b9c01d45f187f57f7c08d016ba394bf1 ""
"projectA.toc" 1635348913 2257 b8728ad5a2d85be860fca1a5cddc7007 "pdflatex"
"projectA.aux" 1635438958 4771 f2c1e1e1b62e376e2ee3d41d6ebec6a2 "pdflatex"
"projectA.out" 1635438958 1864 f5c30b186e6644a7cbcb08ae397fee3f "pdflatex"
"projectA.tex" 1635449228 7751 93268bfae51173fe98c8d150f4220c3a ""
"projectA.toc" 1635438958 2529 683b89eb0e469a5b173eb23a111fbf71 "pdflatex"
(generated)
"projectA.pdf"
"projectA.aux"
"projectA.toc"
"projectA.out"
"projectA.log"
"projectA.toc"
"projectA.pdf"

View File

@ -821,6 +821,7 @@ INPUT ./projectA.out
INPUT /usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-t1.enc
INPUT /usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-ts1.enc
INPUT /usr/share/texlive/texmf-dist/fonts/enc/dvips/base/8r.enc
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb
INPUT /usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb

View File

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.6.28) 27 OCT 2021 17:35
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020/Debian) (preloaded format=pdflatex 2021.6.28) 28 OCT 2021 18:35
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
@ -513,36 +513,46 @@ Overfull \hbox (11.5128pt too wide) in paragraph at lines 118--118
[]\T1/cmr/bx/n/12 Transform sys-tem of equa-tion into an upper-triangular
[]
Overfull \hbox (24.00998pt too wide) in paragraph at lines 137--138
[]\T1/cmr/m/n/10 In or-der for this method to work all the el-e-ments of [][][][] line - $\OML/cmm/m/it/10 a[]; a[]; [] ; a[]$
[]
[5
] [6]
]
Overfull \hbox (2.71124pt too wide) detected at line 161
[]
[]
[6] [7]
Chapter 3.
[7
[8
]
Chapter 4.
[8
[9
] [9
] [10
] (./projectA.aux)
Package rerunfilecheck Info: File `projectA.out' has not changed.
(rerunfilecheck) Checksum: F5C30B186E6644A7CBCB08AE397FEE3F;1864.
)
Here is how much of TeX's memory you used:
12267 strings out of 479304
214055 string characters out of 5869779
12275 strings out of 479304
214137 string characters out of 5869779
618030 words of memory out of 5000000
29194 multiletter control sequences out of 15000+600000
29197 multiletter control sequences out of 15000+600000
420242 words of font info for 68 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
81i,14n,88p,292b,1137s 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/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/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/public/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/ty
pe1/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 (10 pages, 213921 bytes).
81i,7n,88p,292b,1137s 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/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/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/public/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 (11 pages, 229855 bytes).
PDF statistics:
289 PDF objects out of 1000 (max. 8388607)
258 compressed objects within 3 object streams
58 named destinations out of 1000 (max. 500000)
302 PDF objects out of 1000 (max. 8388607)
269 compressed objects within 3 object streams
63 named destinations out of 1000 (max. 500000)
209 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

Binary file not shown.

View File

@ -116,17 +116,111 @@ Write a program solving a system of \textit{n} linear equations Ax = b using the
\section{Theoretical Introduction}
Gaussian elimination with partial pivoting consists of 3 main steps:
\subsection{Transform system of equation into an upper-triangular matrix}
\subsubsection{Starting conditions}
We start with the system of linear equations looking like this:
\begin{align*}
a_{11}^{(1)} x_1 + a_{12}^{(1)} x_2 + \cdots + a_{1n}^{(1)} x_n &= b_1^{(1)}, \\
a_{21}^{(1)} x_1 + a_{22}^{(1)} x_2 + \cdots + a_{2n}^{(1)} x_n &= b_2^{(1)}, \\
&\vdotswithin{=} \\
a_{n1}^{(1)} x_1 + a_{n2}^{(1)} x_2 + \cdots + a_{nn}^{(1)} x_n &= b_n^{(1)}, \\
\end{align*}
\[
\begin{matrix}
&a_{11}x_1 &{}+&a_{12}x_2&+&\dots&+&a_{1n}x_n &=&b_1,\\
&a_{21}x_1 &{}+&a_{22}x_2&+&\dots&+&a_{2n}x_n &=&b_2,\\
&\vdots &&\vdots & & & & \vdots & &\vdots\\
&a_{n1}x_1&{}+&a_{n2}x_2&+&\dots &+&a_{nn}x_n&=&b_n.
\end{matrix}
\]
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.
We will denote rows as '$w_i$' where 'i' is number of the row.
\subsubsection{Zeroing first column}
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.
Doing so we obtain a system of linear equations:
\[
\begin{matrix}
&a_{11}x_1 &{}+&a_{12}x_2&+&\dots&+&a_{1n}x_n &=&b_1,\\
&0 &{}+&(a_{22} - a_{12}l_{21})x_2&{}+&\dots&{}+&(a_{2n} - a_{1n}l_{21})x_n &=&b_2 - b_{1}l_{21},\\
&\vdots &&\vdots & & & & \vdots & &\vdots\\
&0&{}+&(a_{n2} - a_{12}l_{n1})x_2&+&\dots &+&(a_{nn} - a_{1n}l_{n1})x_n&=&b_n - b_{1}l_{n1}.
\end{matrix}
\]
\subsubsection{Zeroing second column}
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)} } \]
Where:
\[ a_{22}^{(2)} = (a_{22} - a_{12}l_{21}) \]
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:
\[
\begin{matrix}
&a_{11}x_1 &{}+&a_{12}x_2&+&\dots&+&a_{1n}x_n &=&b_1,\\
&0 &{}+& a_{22}^{(2)}x_2&{}+&\dots&{}+& a_{2n}^{(2)}x_n &=&b_2^{(2)},\\
&\vdots &&\vdots & & & & \vdots & &\vdots\\
&0 &{}+& 0 &{}+&\dots&{}+& a_{nn}^{(3)}x_n &=&b_2^{(3)},
\end{matrix}
\]
\subsubsection{Zeroing next columns}
We repeat this process $n-1$ times and we end up with upper triangular matrix:
\[
\begin{matrix}
&a_{11}x_1 &{}+&a_{12}x_2&+&\dots&+&a_{1n}x_n &=&b_1,\\
&0 &{}+& a_{22}^{(2)}x_2&{}+&\dots&{}+& a_{i2}^{(2)}x_n &=&b_2^{(2)},\\
&\vdots &&\vdots & & & & \vdots & &\vdots\\
&0 &{}+& 0 &{}+&\dots&{}+& a_{nn}^{(n)}x_n &=&b_2^{(n)},
\end{matrix}
\]
\subsection{Backward substitution}
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}} \]
And so on, for $x_k$:
\[ x_{k} = \frac{b_k - \sum_{j = k + 1}^n a_{kj}x_j}{a_{kk}} \]
\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.
Before each Gaussian elimination step, 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.
\section{Solution}

View File

@ -10,17 +10,21 @@
\contentsline {section}{\numberline {2.1}Problem}{5}{section.2.1}%
\contentsline {section}{\numberline {2.2}Theoretical Introduction}{5}{section.2.2}%
\contentsline {subsection}{\numberline {2.2.1}Transform system of equation into an upper-triangular matrix}{5}{subsection.2.2.1}%
\contentsline {subsection}{\numberline {2.2.2}Backward substitution}{6}{subsection.2.2.2}%
\contentsline {subsection}{\numberline {2.2.3}Partial Pivoting}{6}{subsection.2.2.3}%
\contentsline {section}{\numberline {2.3}Solution}{6}{section.2.3}%
\contentsline {section}{\numberline {2.4}Discussion of the result}{6}{section.2.4}%
\contentsline {chapter}{\numberline {3}Problem 3 - Solving a system of n linear equations - iterative algorithm}{7}{chapter.3}%
\contentsline {section}{\numberline {3.1}Problem}{7}{section.3.1}%
\contentsline {section}{\numberline {3.2}Theoretical introduction}{7}{section.3.2}%
\contentsline {section}{\numberline {3.3}Solution}{7}{section.3.3}%
\contentsline {section}{\numberline {3.4}Discussion of the result}{7}{section.3.4}%
\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{8}{chapter.4}%
\contentsline {section}{\numberline {4.1}Problem}{8}{section.4.1}%
\contentsline {section}{\numberline {4.2}Theoretical introduction}{8}{section.4.2}%
\contentsline {section}{\numberline {4.3}Solution}{8}{section.4.3}%
\contentsline {section}{\numberline {4.4}Discussion of the result}{8}{section.4.4}%
\contentsline {subsubsection}{Starting conditions}{5}{section*.2}%
\contentsline {subsubsection}{Zeroing first column}{6}{section*.3}%
\contentsline {subsubsection}{Zeroing second column}{6}{section*.4}%
\contentsline {subsubsection}{Zeroing next columns}{6}{section*.5}%
\contentsline {subsection}{\numberline {2.2.2}Backward substitution}{7}{subsection.2.2.2}%
\contentsline {subsection}{\numberline {2.2.3}Partial Pivoting}{7}{subsection.2.2.3}%
\contentsline {section}{\numberline {2.3}Solution}{7}{section.2.3}%
\contentsline {section}{\numberline {2.4}Discussion of the result}{7}{section.2.4}%
\contentsline {chapter}{\numberline {3}Problem 3 - Solving a system of n linear equations - iterative algorithm}{8}{chapter.3}%
\contentsline {section}{\numberline {3.1}Problem}{8}{section.3.1}%
\contentsline {section}{\numberline {3.2}Theoretical introduction}{8}{section.3.2}%
\contentsline {section}{\numberline {3.3}Solution}{8}{section.3.3}%
\contentsline {section}{\numberline {3.4}Discussion of the result}{8}{section.3.4}%
\contentsline {chapter}{\numberline {4}Problem 4 - QR method of finding eigenvalues}{9}{chapter.4}%
\contentsline {section}{\numberline {4.1}Problem}{9}{section.4.1}%
\contentsline {section}{\numberline {4.2}Theoretical introduction}{9}{section.4.2}%
\contentsline {section}{\numberline {4.3}Solution}{9}{section.4.3}%
\contentsline {section}{\numberline {4.4}Discussion of the result}{9}{section.4.4}%

View File

@ -29,3 +29,7 @@ https://tex.stackexchange.com/questions/32217/3-dots-in-matrix/32221 - 3 dots la
https://stackoverflow.com/questions/48240982/how-do-you-align-a-system-of-equations - System of equations latex
https://tex.stackexchange.com/questions/526025/problem-with-vdotswithin - vdots alligned to equal sign
https://www.overleaf.com/learn/latex/Brackets_and_Parentheses - Curly brackets latex
https://tex.stackexchange.com/questions/130516/how-to-write-something-vertically-below-another-math-symbol - Symbol vertically below another

8
ENUME/projectA/vectorA.m Normal file
View File

@ -0,0 +1,8 @@
function b = vectorA(n) % We want n elements in the vector
b = zeros(n, 1); % in order to save speed we preallocate zeros to the vector
for i = 1 : n % We loop from first element to the last element of the vector
b(i, 1) = -5 + 0.3 * i; % Formula as in the task description
% We need to put '1' in b(i, 1) so that matlab acknowledges that
% this is a column and not a row
end % end for
end % end function

10
ENUME/projectA/vectorB.m Normal file
View File

@ -0,0 +1,10 @@
function b = vectorB(n) % We want n elements in the vector
b = zeros(n, 1); % in order to save speed we preallocate zeros to the vector
for i = 1 : n % We loop from first element to the last element of the vector
if mod(i, 2) == 0 % as per problem description
b(i, 1) = 9 / (2*i);
else
b(i, 1) = 0;
end % end if
end % end for
end % end function