1 / 6

MÉTODO JACOBI

MÉTODO JACOBI. CÓDIGO JACOBI EM PASCAL. Program Metodo_de_Jacobi ; {$APPTYPE CONSOLE} uses SysUtils ; var i,j,n,ite,cont,nite,k:integer ; a:array[0..100,0..100] of real; b,x,soma:array [0..100] of real; e,c:real ;. CÓDIGO JACOBI EM PASCAL. Begin write ('Ordem da Matriz = ');

irving
Download Presentation

MÉTODO JACOBI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MÉTODO JACOBI

  2. CÓDIGO JACOBI EM PASCAL ProgramMetodo_de_Jacobi; {$APPTYPE CONSOLE} uses SysUtils; var i,j,n,ite,cont,nite,k:integer; a:array[0..100,0..100] of real; b,x,soma:array[0..100] of real; e,c:real;

  3. CÓDIGO JACOBI EM PASCAL Begin write('Ordem da Matriz = '); readln(n); for i:=1 to n do begin writeln(''); PULA UMA LINHA for j:=1 to n do begin write('a',i,j,'='); ESCREVE Aij É IGUAL A read(a[i,j]); LÊ Aij end; write('b',i,' ='); FAZ O MESMO COM O VETOR b read(b[i]); end;

  4. CÓDIGO JACOBI EM PASCAL writeln(''); write('Número de iteraçoes = ');PEDE O NÚMERO DE ITERAÇÕES read(ite); writeln(''); writeln('Soluçao inicial'); for i:=1 to n do LÊ O VETOR SOLUÇÃO OU O CHUTE INICIAL begin write('x',i,' = '); read(x[i]); end;

  5. CÓDIGO JACOBI EM PASCAL writeln(''); ESTE COMANDO ESCREVE UMA LINHA VAZIA E PULA PRA SEGUINTE write('Tolerância = '); ESTE COMANDO ESCREVE NA LINHA MAS NÃO PULA FICA COM O CURSOR ESPERANDO O DEVIDO COMANDO, QUE É A TOLERÂNCIA read(e); for k:=1 toite do begin cont:=0; for i:=1 to n do begin soma[i]:=0; for j:=1 to n do begin if j<>i then soma[i]:=soma[i] + a[i,j]*x[j]; end;

  6. CÓDIGO JACOBI EM PASCAL c:=x[i]; x[i]:= (b[i] - soma[i])/a[i,i]; if (abs(c-x[i])<e) thencont:=cont+1; end; nite:=nite+1; ifcont=n then break; SE O CONTADOR FOR IGUAL A n ENTÃO PARA end; writeln(''); writeln('Soluçao'); writeln(''); for i:=1 to n do writeln('x',i,'=',x[i]:10:2); writeln(''); writeln('Foram necessárias ',nite,' iteraçoes com a tolerância dada'); readln; readln; End.

More Related