Escolar Documentos
Profissional Documentos
Cultura Documentos
28 de Março de 2012
Estes primeiros exercícios devem ser feitos sem usar as funções do scilab
para solução de sistemas lineares. Eles são pequenos e simples para que você
resolva-os diretamente fazendo as contas com papel e lápis.
1
resultante da eliminação gaussiana. Finalmente, escreva o sistema Ax = b
na forma da decomposição LU x = b usando os multiplicadores da eliminação
gaussiana.
ou ainda
1 6 2 4 x1 8
0 1 −2 3 x2 1
= .
0 0 2 −10 x3 12
0 0 0 −1 x4 −1
Logo,
x4 = 1,
x3 = 6 + 5x4 = 6 + 5 × 1 = 11,
x2 = 1 − 3x4 + 2x3 = 1 − 3 × 1 + 2 × 11 = 20,
x1 = 8 − 4x4 − 2x3 − 6x2 = 8 − 4 × 1 − 2 × 11 − 6 × 20 = −138.
2
1 0 0 0
3 1 0 0
L= .
1 −2 1 0
5 3 25 1
1 0 0 0 1 6 2 4 x1 8
3 1 0 0 0
1 −2 3 x2 25
= .
1 −2 1 0 0 0 2 −10 x3 18
5 3 52 1 0 0 0 −1 x4 72
4 −6 5 x3 29
0 0 1 4 −6 5
P1 = 0 1 0 ⇒ P1 A −2 8 −1
1 0 0 1 −3 2
1 0 0 4 −6 5
M1 = 1/2 1 0 ⇒ M1 P1 A 0 5 3/2
−1/4 0 1 0 −3/2 3/4
3
1 0 0 4 −6 5
M2 = 0
1 0 ⇒ M2 M1 P1 A 0 5 3/2
=U
0 3/10 1 0 0 6/5
1 0 0
−1
L = (M2 M1 ) −1/2 1 0
1/4 −3/10 1
Onde P = P1 .
Resolver primeiro o sistema triangular inferior Lc = P b,
1 0 0 c1 29
−1/2 1 0
c
2
=
−15
1/4 −3/10 1 c3 11
Logo,
c1 = 29,
c2 = −1/2,
c3 = 18/5.
Depois, resolver o sistema triangular superior U x = c,
4 −6 5 x1 29
0 5 3/2 x2 = −1/2
0 0 6/5 x3 18/5
Logo,
x3 = 3,
x2 = −1,
x1 = 2
4
Solução: Calculamos a descomposição A = LLt da matriz A,
9 6 −3 3 3 0 0 0 3 0 0 0
6 20 2 22 2 20 0 0 2 16 0 0
⇒ ⇒
−3 2 6 2 −1 2 6 0 −1 4 5 0
3 22 2 28 1 22 2 28 1 20 3 27
3 0 0 0 3 0 0 0
2 4 0 0 2 4 0 0
⇒ ⇒ =L
−1 1 4 0 −1 1 2 0
1 5 −2 2 1 5 −1 1
Logo,
3 2 −1 1
0 4 1 5
Lt =
0 0 2 −1
0 0 0 1
3 0 0 0 y1 12
2 4 0 0 y2 64
=
−1 1 2 0 y3 4
1 5 −1 1 y4 82
Logo,
y1 = 4,
y2 = 14,
y3 = −3
y4 = 5.
Depois, resolver o sistema triangular superior Lt x = y ,
3 2 −1 1 x1 4
0 4 1 5 x2 14
=
0 0 2 −1 x3 −3
0 0 0 1 x4 5
5
Logo,
x4 =5
x3 = 1,
x2 = −3,
x1 =2
Solução: Comandos:
3. 2. - 1. 1.
0. 4. 1. 5.
0. 0. 2. - 1.
0. 0. 0. 1.
Solução: Comandos:
6
-->[L U P]=lu(A)
P =
0. 0. 1.
0. 1. 0.
1. 0. 0.
U =
4. - 6. 5.
0. 5. 1.5
0. 0. 1.2
L =
1. 0. 0.
- 0.5 1. 0.
0.25 - 0.3 1.
Solução:
%FORWARD Forward substitution for lower triangular systems
% Written by <YOUR NAME> on <TODAYS DATE>
function x = forward( A, b )
[m,n] = size(A);
if m \~= n,
% check if # rows \~= # columns in A
error('The input matrix, A, is not a square matrix.')
end
x(1) = b(1)/A(1,1);
for i = 2:1:m, % i starts at 2, end at 4, w/ steps of 1
x(i) = (b(i)-A(i,1:i-1)*x(1:i-1)')/A(i,i);
end
x = x'; % convert and display result as column
7
Exercício 0.8 Completar o código para fazer a decomposição LU.
Solução:
% LU4 - The function in this M-file computes the L-U factorization
% (without pivoting) of a 4x4 matrix. To use this function,
% create a 4x4 matrix A and type [L,U]=LU4(A).
function [L,U]=LU4(A)
L = eye(4);
U = A;
for j=1:3
for i=j+1:4
L(i,j)=U(i,j)/U(j,j);
U(i,j:4)=U(i,j:4) - L(i,j)*U(j,j:4);
end
end