Métodos de eliminação de Gauss
Após o sistema estar na sua forma escalonada reduzida, é a vez de gerar a solução.
Fase de solução
Partindo da matriz escalonada:
\[ \left[\begin{matrix} 1& -2& -1& 2 \\ 0& 1& 1& 1 \\ 0& 0& 1& 0 \\ 0& 0& 0& 1 \end{matrix} \right. \left| \begin{matrix} 1 \\6 \\ 3 \\2 \end{matrix} \right] \]Essa fase também é chamada também de substituição retroativa, pois busca encontrar o resultado da linha última linha para a primeira, acompanhe a resolução do exemplo proposto:
| Matriz | Operação |
|---|---|
| \( \left[\begin{matrix} 1& -2& -1& 2 \\ 0& 1& 1& 1 \\ 0& 0& 1& 0 \\ 0& 0& 0& \color{blue} 1 \end{matrix} \right. \left| \begin{matrix} 1 \\6 \\ 3 \\ \color{red} 2 \end{matrix} \right] \) | \( \begin{matrix} \textrm{ } \\ \textrm{ } \\ \textrm{ } \\ \large x_4 = \frac{\color{red} 2}{\color{blue} 1} = 2\end{matrix} \) |
| \( \left[\begin{matrix} 1& -2& -1& 2 \\ 0& 1& 1& 1 \\ 0& 0& \color{blue} 1& \color{magenta}0 \\ 0& 0& 0& 1 \end{matrix} \right. \left| \begin{matrix} 1 \\6 \\ \color{red} 3 \\ 2 \end{matrix} \right] \) | \( \begin{matrix} \textrm{ }\\ \textrm{ } \\ \large x_3 = \frac{\color{red} 3 - \color{magenta} (0\times x_4)}{\color{blue} 1} = 3 \\ \textrm{ } \end{matrix} \) |
| \( \left[\begin{matrix} 1& -2& -1& 2 \\ 0& \color{blue}1& \color{magenta}1& \color{green}1 \\ 0& 0& 1&0 \\ 0& 0& 0& 1 \end{matrix} \right. \left| \begin{matrix} 1 \\ \color{red} 6 \\ 3 \\ 2 \end{matrix} \right] \) | \( \begin{matrix} \textrm{ } \\ \large x_2 = \frac{\color{red} 6 - \color{black} (\color{green} 1\times x_4 + \color{magenta} 1\times x_3 \color{black} )}{\color{blue} 1} = \frac{\color{red} 6 - \color{black} (\color{green}2 + \color{magenta}3\color{black})}{\color{blue} 1} = 1 \\ \textrm{ } \\ \textrm{ } \end{matrix} \) |
| \( \left[\begin{matrix} \color{blue}1& \color{orange}-2& \color{magenta}-1& \color{green}2 \\ 0& 1& 1& 1 \\ 0& 0& 1&0 \\ 0& 0& 0& 1 \end{matrix} \right. \left| \begin{matrix} \color{red}1 \\ 6 \\ 3 \\ 2 \end{matrix} \right] \) | \( \begin{matrix} \large x_1 = \frac{\color{red} 1 - \color{black} (\color{green} 2\times x_4 + \color{magenta} (-1)\times x_3 +\color{orange} (-2)\times x_2 \color{black} )}{\color{blue} 1} = \frac{\color{red} 1 - \color{black} (\color{green}4 + \color{magenta}(-3) + \color{orange} (-2)\color{black})}{\color{blue} 1} = 2 \\ \textrm{ } \\ \textrm{ } \\ \textrm{ } \end{matrix} \) |
Na última linha, temos uma equação chave para o desenvolvimento da solução, ela pode ser reescrita como:
\[x_1 = \frac{ M_{15} - ( M_{14}\times x_4 + M_{13}\times x_3 + M_{12}\times x_2 )}{ M_{11}}\]Ainda:
\[x_1 = \frac{ M_{15} - ( \sum\limits_{j=2}^{4}{M_{1j}\times x_j} )}{ M_{11}} \]De forma genérica e armazenando os resultados num vetor:
\[ x(i) = \frac{ M_{i5} - ( \sum\limits_{j=i+1}^{4}{M_{ij}\times x(j)} )}{ M_{ii}} \]
Aplicando para as linhas:
| Operação | \(i\) | \(j\) |
|---|---|---|
| \[ x(4) = \frac{ M_{45} - (0)}{ M_{44}} \] | \(4\) | \(\) |
| \[ x(3) = \frac{ M_{35} - ( M_{34}\times x(4) )} { M_{33}} \] | \(3\) | \(4\) |
| \[ x(2) = \frac{ M_{25} - ( M_{24}\times x(4) + M_{23}\times x(3) )} { M_{22}} \] | \(2\) | \(4,3\) |
| \[ x(1) = \frac{ M_{15} - ( M_{14}\times x(4) + M_{13}\times x(3) + M_{12}\times x(2) )} { M_{11}} \] | \(1\) | \(4,3,2\) |
A implementação do laço de repetição para percorrer os valores de \(i \textrm{ e } j \)
EXPORT gauss()
BEGIN
PRINT();
LOCAL DIMENSAO := 4;
FOR I FROM DIMENSAO DOWNTO 1 DO
// Valor de I
FOR J FROM DIMENSAO DOWNTO I+1 DO
// Valor de J;
END;
END;
END;
Atividade 1
Conclua a resolução dos sistemas lineares a seguir:
- \[ \left[\begin{matrix} 2 & -4 & 2 \\ 0 & 2 & 0 \\ 0 & 0 & 2 \end{matrix} \right. \left| \begin{matrix} 2 \\ 6 \\ 8 \end{matrix} \right] \]
- \[ \left[\begin{matrix} 1 & -1 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{matrix} \right. \left| \begin{matrix} 8 \\ -1 \\ 2 \end{matrix} \right] \]
- \[ \left[\begin{matrix} 1 & -1 & 3 & 7 \\ 0 & 1 & -2 & -4 \\ 0 & 0 & 1 & 1 \\ 0 & 0 & 0 & 1 \end{matrix} \right. \left| \begin{matrix} -19 \\ 14 \\ -6 \\ -2 \end{matrix} \right] \]
- \[ \left[\begin{matrix} 2 & -1 & 2 & 6 & -2 \\ 0 & 1 & -1 & -2 & 0 \\ 0 & 0 & 1 & 2 & -1 \\ 0 & 0 & 0 & 2 & -1 \\ 0 & 0 & 0 & 0 & 1 \end{matrix} \right. \left|\begin{matrix} 17 \\ -3 \\ 9 \\ 9 \\ -5 \end{matrix} \right] \]