- #1
mathmari
Gold Member
MHB
- 5,049
- 7
We have the linear system of equations $Ax=b$ with \begin{equation*}A=\begin{pmatrix}0 & 1 & 1 \\ 0.5 & 1.0001 & 3 \\ 1 & 2 & 4\end{pmatrix} \ \ \ \text{ und } \ \ \ b=\begin{pmatrix}2 \\ 3 \\ 4\end{pmatrix}\end{equation*}
First, I want to calculate the solution using the Gauss algorithm with complete pivoting, with accuracy $\text{eps}=5\cdot 10^{-5}$ and floating-point arithmetic with $4$ decimal places.
I have done the following:
The maximal element of the matrix is $a_{3,3}$. We exchange the first and the last column and the first and last row (we make also the respective changes at the vector x and b)
So, we have the following:
\begin{align*}\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
3 & 1.0001 & 0.5 \\
1 & 1 & 0
\end{matrix}\right| \begin{matrix}
4 \\ 3 \\ 2
\end{matrix}
\end{bmatrix} \ \overset{ 2.\text{Row } : \ 2.\text{Row } - \frac{3}{4}\cdot 1.\text{Row}}{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
1 & 1 & 0
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 2
\end{matrix}
\end{bmatrix}\ \\ \overset{ 3.\text{Row } : \ 3.\text{Row } -\frac{1}{4}\cdot 1.\text{Row}}{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
0 & \frac{1}{2} & -\frac{1}{4}
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 1
\end{matrix}
\end{bmatrix} \ \\ \overset{ 3.\text{Row } : \ 4\cdot 3.\text{Row } }{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
0 & 2 & -1
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 4
\end{matrix}
\end{bmatrix} \ \\ \overset{ 3.\text{Row } : \ 3.\text{Zeile }+\frac{2}{0.4999}\cdot 2.\text{Row }}{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
0 & 0 & -2.0002
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 4
\end{matrix}
\end{bmatrix} \end{align*}
So, we get the equations:
\begin{align*}4x_3+2x_2+x_1 & = 4 \\ -0.4999x_2 -0.25 x_1 &=0 \\ -2.0002x_1 &= 4\end{align*}
From the last equation we get $x_1=-\frac{4}{2.0002}\approx -1.9998$.
From the second equationwe get $-0.4999x_2 =0.25 x_1 \Rightarrow -0.4999x_2 =0.25 \cdot \left (-1.9998\right )\Rightarrow -0.4999x_2 =-0.5000 \Rightarrow x_2=\frac{0.5000}{0.4999}\Rightarrow x_2\approx 1.0002$.
From the first equation we get $4x_3 = 4-2x_2-x_1 \Rightarrow 4x_3 = 4-2\cdot 1.0002-\left (-1.9998\right )\Rightarrow 4x_3 = 4-2.0004+1.9998\Rightarrow 4x_3 = 3.9994\Rightarrow x_3\approx 0.9999$.
So we get the solution \begin{equation*}x=\begin{pmatrix}-1.9998 \\ 1.0002 \\ 0.9999\end{pmatrix}\end{equation*}
The exact solution is (according to Wolfram) \begin{equation*}x=\begin{pmatrix}-1.9998\ldots \\ 1.0001\ldots \\ 0.9999\ldots\end{pmatrix}\end{equation*} To check the accuracy of $\text{eps}=5\cdot 10^{-5}$ do we have to calculate the difference between the exact solution and the solution that we found? (Wondering)
I also have to calculate an estimate of the relative error using the condition number in respect of $\|\cdot \|_{\infty}$.
Do we have to use forthat the following inequality?
\begin{equation*}\frac{\|\delta x\|}{\|x\|}\leq \frac{\operatorname{cond}(A)}{1-\operatorname{cond}(A)\frac{\|\delta A\|}{\|A\|}}\left (\frac{\|\delta b\|}{\|b\|}+\frac{\|\delta A\|}{\|A\|}\right )\end{equation*}
(Wondering)
First, I want to calculate the solution using the Gauss algorithm with complete pivoting, with accuracy $\text{eps}=5\cdot 10^{-5}$ and floating-point arithmetic with $4$ decimal places.
I have done the following:
The maximal element of the matrix is $a_{3,3}$. We exchange the first and the last column and the first and last row (we make also the respective changes at the vector x and b)
So, we have the following:
\begin{align*}\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
3 & 1.0001 & 0.5 \\
1 & 1 & 0
\end{matrix}\right| \begin{matrix}
4 \\ 3 \\ 2
\end{matrix}
\end{bmatrix} \ \overset{ 2.\text{Row } : \ 2.\text{Row } - \frac{3}{4}\cdot 1.\text{Row}}{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
1 & 1 & 0
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 2
\end{matrix}
\end{bmatrix}\ \\ \overset{ 3.\text{Row } : \ 3.\text{Row } -\frac{1}{4}\cdot 1.\text{Row}}{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
0 & \frac{1}{2} & -\frac{1}{4}
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 1
\end{matrix}
\end{bmatrix} \ \\ \overset{ 3.\text{Row } : \ 4\cdot 3.\text{Row } }{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
0 & 2 & -1
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 4
\end{matrix}
\end{bmatrix} \ \\ \overset{ 3.\text{Row } : \ 3.\text{Zeile }+\frac{2}{0.4999}\cdot 2.\text{Row }}{ \longrightarrow } &\begin{bmatrix}
\left.\begin{matrix}
4 & 2 & 1 \\
0 & -0.4999 & -0.25 \\
0 & 0 & -2.0002
\end{matrix}\right| \begin{matrix}
4 \\ 0 \\ 4
\end{matrix}
\end{bmatrix} \end{align*}
So, we get the equations:
\begin{align*}4x_3+2x_2+x_1 & = 4 \\ -0.4999x_2 -0.25 x_1 &=0 \\ -2.0002x_1 &= 4\end{align*}
From the last equation we get $x_1=-\frac{4}{2.0002}\approx -1.9998$.
From the second equationwe get $-0.4999x_2 =0.25 x_1 \Rightarrow -0.4999x_2 =0.25 \cdot \left (-1.9998\right )\Rightarrow -0.4999x_2 =-0.5000 \Rightarrow x_2=\frac{0.5000}{0.4999}\Rightarrow x_2\approx 1.0002$.
From the first equation we get $4x_3 = 4-2x_2-x_1 \Rightarrow 4x_3 = 4-2\cdot 1.0002-\left (-1.9998\right )\Rightarrow 4x_3 = 4-2.0004+1.9998\Rightarrow 4x_3 = 3.9994\Rightarrow x_3\approx 0.9999$.
So we get the solution \begin{equation*}x=\begin{pmatrix}-1.9998 \\ 1.0002 \\ 0.9999\end{pmatrix}\end{equation*}
The exact solution is (according to Wolfram) \begin{equation*}x=\begin{pmatrix}-1.9998\ldots \\ 1.0001\ldots \\ 0.9999\ldots\end{pmatrix}\end{equation*} To check the accuracy of $\text{eps}=5\cdot 10^{-5}$ do we have to calculate the difference between the exact solution and the solution that we found? (Wondering)
I also have to calculate an estimate of the relative error using the condition number in respect of $\|\cdot \|_{\infty}$.
Do we have to use forthat the following inequality?
\begin{equation*}\frac{\|\delta x\|}{\|x\|}\leq \frac{\operatorname{cond}(A)}{1-\operatorname{cond}(A)\frac{\|\delta A\|}{\|A\|}}\left (\frac{\|\delta b\|}{\|b\|}+\frac{\|\delta A\|}{\|A\|}\right )\end{equation*}
(Wondering)