# Function [x,niter]=gausseidel(A,b,e,N,x0) n=length(b); x=x0; xk=x0; for niter=1:N for i=1:n; Sum1=A(i,1:i-1)*x(1:i-1); Sum2=A(i,i+1:n)*xk(i+1:n); x(i)=(1/A(i,i))*(b(i)-Sum1-Sum2);

## Presentation on theme: "Function [x,niter]=gausseidel(A,b,e,N,x0) n=length(b); x=x0; xk=x0; for niter=1:N for i=1:n; Sum1=A(i,1:i-1)*x(1:i-1); Sum2=A(i,i+1:n)*xk(i+1:n); x(i)=(1/A(i,i))*(b(i)-Sum1-Sum2);"— Presentation transcript:

function [x,niter]=gausseidel(A,b,e,N,x0) n=length(b); x=x0; xk=x0; for niter=1:N for i=1:n; Sum1=A(i,1:i-1)*x(1:i-1); Sum2=A(i,i+1:n)*xk(i+1:n); x(i)=(1/A(i,i))*(b(i)-Sum1-Sum2); end if ((x-xk)'*(x-xk)/(x'*x)) { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/12/3875293/slides/slide_1.jpg", "name": "function [x,niter]=gausseidel(A,b,e,N,x0) n=length(b); x=x0; xk=x0; for niter=1:N for i=1:n; Sum1=A(i,1:i-1)*x(1:i-1); Sum2=A(i,i+1:n)*xk(i+1:n); x(i)=(1/A(i,i))*(b(i)-Sum1-Sum2); end if ((x-xk) *(x-xk)/(x *x))

function [x,i]=newton(foncjac,e,N,x0) x=x0; for i=1:N [F,J]=foncjac(x); h=-J\F // on resout Jh=-F x=x+h; if ((h'*h)/(x'*x+%eps) { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/12/3875293/slides/slide_2.jpg", "name": "function [x,i]=newton(foncjac,e,N,x0) x=x0; for i=1:N [F,J]=foncjac(x); h=-J\F // on resout Jh=-F x=x+h; if ((h *h)/(x *x+%eps)

function [F,J]=foncjac2(v) alpha=5; betta=5; deff('x=g(v)','x=10*v/(1+v)'); deff('x=g1(v)','x=10/((1+v)^2)'); n=length(v); x=linspace(0,1,n); F=zeros(n-1,1); d=zeros(n-1,1); h=1/n; F(1)=-alpha+2*v(1)+h*h*g(v(1))-v(2)-h^2*(-x(1)*(x(1)-1)); for i=2:n-2 F(i-1)=-v(i-1)+2*v(i)+h^2*g(v(i))-v(i+1)-h^2*(-x(i)*(x(i)-1)); end F(n-1)=-v(n-3)+2*v(n-2)+h^2*g(v(n-2))-betta-h^2*(-x(n-2)*(x(n-2)-1)); d=2+h^2.*g1(v(1:n-1)); J=diag(-1*ones(n-2,1),-1)+diag(-1*ones(n-2,1),1)+diag(d); endfunction

function [x,i]=newton(foncjac,e,N,x0) x=x0; for i=1:N [F,J]=foncjac(x); h=[0;-J\F;0] // on resout Jh=-F x=x+h; if ((h'*h)/(x'*x) { "@context": "http://schema.org", "@type": "ImageObject", "contentUrl": "http://images.slideplayer.com/12/3875293/slides/slide_4.jpg", "name": "function [x,i]=newton(foncjac,e,N,x0) x=x0; for i=1:N [F,J]=foncjac(x); h=[0;-J\F;0] // on resout Jh=-F x=x+h; if ((h *h)/(x *x)

Download ppt "Function [x,niter]=gausseidel(A,b,e,N,x0) n=length(b); x=x0; xk=x0; for niter=1:N for i=1:n; Sum1=A(i,1:i-1)*x(1:i-1); Sum2=A(i,i+1:n)*xk(i+1:n); x(i)=(1/A(i,i))*(b(i)-Sum1-Sum2);"

Similar presentations