Buscar

jacobi

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

function [x, it]= jacobi(A, b, x0, e, N)
 [lin col] = size(A);
 erro = 1;
 x = x0; it = 0;
 while erro > e & it < N
 x0 = x; it = it + 1;
 for i = 1:lin
 soma = 0;
 for j = 1:lin
 if j ~= i 
 soma = soma + A(i,j).*x0(j)
 end
 end
 x(i) = (b(i) - soma)/A(i,i); 
 end 
 erro = max(abs(x- x0))./max(abs(x));
 end 
endfunction
x0=[4 1.9 4.6 -5.8]
A=[53 4.6 -5.8 4.6;1.9 57 0 4;4 4.6 87 0 ;0 0 1.9 57]
b=[87;4;57;6]
[x, it]= jacobi(A, b,x0,10^(-6),21)

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Outros materiais