Analisis-practica6 - x=x0; r=b-A*x; p=r; while norm(r)...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
An´ alisis Num´ erico etodo de Gauss- Seidel, Descenso m´ as profundo y Gradiente conjugado 26 de marzo de 2011 Ejercicio 1. Implemente en matlab el m´ etodo de Gauss- Seidel, descenso m´ as profundo y gradiente conjugado para la soluci´ on de sistemas lineales. Descenso m´as profundo function z=dmp(x0,A,b,tol) x=x0; r=b-A*x; while norm(r) > tol a=(r’*r)/(r’*A*r); x=x+a*r; r=b-A*x; end z=x; Gradiente conjugado function z=gc(x0,A,b,tol)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x=x0; r=b-A*x; p=r; while norm(r) > tol a=(p*r)/(p*A*p); x=x+a*p; r=r-a*A*p; b=-(r*A*p)/(p*A*p); p=r+b*p; end z=x; Gauss-Seidel 1 function z=gausseidel(x0,A,b,tol) u=size(A); n=u(1); L=tril(A)-diag(diag(A)); D=diag(diag(A)); U=triu(A)-diag(diag(A)); y=x0; C=inv(D+L); B=eye(n)-C*A; x=B*y+C*b; k=1; while (norm(x-y)/norm(y)) > tol y=x; x=B*y+C*b; k=k+1; end z=x; 2...
View Full Document

Page1 / 2

Analisis-practica6 - x=x0; r=b-A*x; p=r; while norm(r)...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online