Escolar Documentos
Profissional Documentos
Cultura Documentos
1. Se uma matriz An×n possui uma inversa, é uma matriz Xn×n tal que:
AX = I
Ax(j) = I (j) (1 ≤ j ≤ n)
Algoritmos Iterativos
• Voltemos ao sistema Ax = b :
n
aij xj = bi (1 ≤ i ≤ n)
X
j=1
(k) 1 n (k−1)
xi = bi − aij xj (1 ≤ i ≤ n)
X
aii
j=1
j6=i
• Método de Gauss-Seidel:
– Jacobi em que as equações são computadas em ordem
(k)
– Os novos valores de xj são usados assim que ficam disponı́veis
for k=1:kmax
for i=1:n
Pn
xi ← [bi − j=1 aij xj ]/aii
j6=i
end
end
• Método de Relaxações:
– Pode-se modificar (acelerar ou retardar) a convergência do G-S
– Para isto, usa-se um parâmetro de controle ω (= fator de “relaxação”)
• Exemplo: Sejam
2 −1 0
1
A = −1 3 −1
e b= 8
0 −1 2 −5
.
– Usando Jacobi:
(k) 1 (k−1) 1
x1 = x +
2 2 2
(k) 1 (k−1) 1 (k−1) 8
x2 = x + x3 +
3 1 3 3
(k) 1 (k−1) 5
x3 = x −
2 2 2
– Usando Gauss-Seidel:
(k) 1 (k−1) 1
x1 = x +
2 2 2
(k) 1 (k) 1 (k−1) 8
x2 = x + x3 +
3 1 3 3
(k) 1 (k) 5
x3 = x −
2 2 2
– Usando Relaxações:
1 (k−1) 1
(k) (k−1)
x1 = ω x2 + + (1 − ω)x1
2 2
1 (k) 1 (k−1) 8
(k) (k−1)
x2 = ω x1 + x3 + + (1 − ω)x2
3 3 3
1 (k) 5
(k) (k−1)
x3 = ω x2 − + (1 − ω)x3
2 2
.
function x=jacobif(A,b,tol,kmax)
n = size(A,1)
for k = 1:kmax
y = x
for i = 1:n
soma = b(i)
diag = A(i,i)
for j = 1:n
if j != i
soma = soma - A(i,j)*y(j)
end
end
x(i) = soma/diag
end
if norm(x-y,1) < tol
break
end
end
n
|aii| > |aij |
X
j=1
j6=i
x1 + x2 = 4
– Exemplo: −4x2 − 3x3 = 0
x1 + 2x3 = 0
• Método Iterativo:
Qx(k) = (Q − A)x(k−1) + b
• Consistência:
– Suponha que a sequência x(k) realmente converge para um x∗
– Tomando o limite k → ∞, temos:
Qx∗ = (Q − A)x∗ + b
• Em pseudocódigo (octave):
function x=metoditer(A,b,x0,tol,kmax)
x = x0
for k = 1:kmax
y = x
c = (Q - A)x + b
Resolva Qx = c
if norm(x-y,1) < tol
break
end
end
• É a escolha da matriz Q que leva aos 3 métodos vistos:
1. Método de Jacobi:
– Q é tomada como a diagonal principal de A
2. Método de Gauss-Seidel:
– Q vem da parte triangular inferior de A, incluindo a diagonal
2 0 0
1. Escolhendo Q: Q = 0 3 0
0 0 2