This commit is contained in:
Janita Willumsen 2023-09-08 13:18:39 +02:00
parent 8ebd561f0d
commit fc492b5cbf
2 changed files with 40 additions and 0 deletions

Binary file not shown.

View File

@ -3,6 +3,46 @@
\subsection*{a)}
% Use Gaussian elimination, and then use backwards substitution to solve the equation
Renaming the sub-, main-, and supdiagonal of matrix $\boldsymbol{A}$
\begin{align*}
\vec{a} &= [a_{2}, a_{3}, ..., a_{n-1}, a_{n}] \\
\vec{b} &= [b_{1}, b_{2}, b_{3}, ..., b_{n-1}, b_{n}] \\
\vec{c} &= [c_{1}, c_{2}, c_{3}, ..., c_{n-1}] \\
\end{align*}
Following Thomas algorithm for gaussian elimination, we first perform a forward sweep
\begin{algorithm}[H]
\caption{Foreward sweep}\label{algo:foreward}
\begin{algorithmic}
\State Create new vector \vec{\hat{b}} of length n.
\State \hat{b}[0] &= b[0] \Comment{Handle first element in main diagonal outside loop}
\For{$i = 1, ..., n-1$}
\State d = \frac{a[i-1]}{b[i-1]}
\State b -= d*(*sup_diag)(i-1);
(*g_vec)(i) -= d*(*g_vec)(i-1);
\EndFor
\While{Some condition}
\State Do something more here
\EndWhile
\State Maybe even some more math here, e.g $\int_0^1 f(x) \dd x$
\end{algorithmic}
\end{algorithm}
Here the index i does not refer to the element in the vector, ie. $b_{i}$, but to the index in the vector where the element is found ie. $b[i] = b_{i+1}$.
\begin{align*}
\hat{b}_{1} &= b_{1} \\
\hat{b}_{2} &= b_{2} - \frac{a_{2}}{\hat{b}_{1}} \cdot c_{1} \\
\vdots & \\
\hat{b}_{i} &= b_{i} - \frac{a_{i}}{\hat{b}_{i-1}} \cdot c_{i-1} \\
\vdots & \\
\end{align*}
% as g_hat also make use of the ratio (ai/bi-1_hat) it only needs to be calculated once
% for n steps we have n+1 points, that is values of x to evaluate u(x) at, when boundary values are known
% we have to perform (n+1)-2 = n-1 calculations (equal number of col in matrix). Dealing
% with a quadratic matrix number of col = number of rows
\subsection*{b)}