Analisis-practica6

# Analisis-practica6 - x=x0 r=b-A*x p=r while norm(r> tol...

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

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)

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

View Full Document
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

## This note was uploaded on 03/27/2011 for the course MATHEMATIC 504 taught by Professor Carlostrujillo during the Winter '09 term at Buena Vista.

### Page1 / 2

Analisis-practica6 - x=x0 r=b-A*x p=r while norm(r> tol...

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

View Full Document
Ask a homework question - tutors are online