function []=blatt8() n=20; u0=zeros(1,n^2); for i=1:n for j=1:n u0((i-1)*n+j) = sin( (j-1)/(n-1)*(i-1)/(n-1)*pi ); end end u0; gradinhalt( u0,n); B0=1/n*eye(n^2); %B0=eye(n^2); [u,fu] =quanew(u0,B0,n); length(fu); length(u); u(:,length(fu)) fu(length(fu)) X=0:1/(n-1):1; Y=0:1/(n-1):1; [X,Y]=meshgrid(X,Y); Z=reshape(u(:,length(fu)),n,n); surf(X,Y,Z) end function gra = gradinhalt(U,n) gra=zeros(1,n^2); for i=1:(n-2) for j=1:(n-2) gra( i*n + j+1 ) = 1/(2*(n-1))*( ( U(i*n + j +1) - U((i-1)*n + j +1))/(sqrt(( U((i-1)*n+j+1)-U((i-1)*n + j))^2 + (U((i-1)*n+j+1) - U(i*n+j+1))^2+1/(n-1)^2)) + (U(i*n+j+1)-U(i*n+j))/sqrt( (U(i*n+j+1)-U(i*n+j))^2+(U(i*n+j)-U((i-1)*n+j))^2 + 1/(n-1)^2)+ (2*U(i*n+j+1) - U(i*n+j+2)-U((i-1)*n+j+1))/sqrt((U(i*n+j+2)-U(i*n+j+1))^2+(U(i*n+j+1)-U((i-1)*n+j+1))^2+1/(n-1)^2) + (2*U(i*n+j+1)-U(i*n+j)-U((i+1)*n+j+1))/sqrt((U(i*n+j+1)-U(i*n+j))^2+(U(i*n+j+1)-U((i+1)*n+j+1))^2+1/(n-1)^2)+ (U(i*n+j+1)-U(i*n+j+2))/sqrt((U(i*n+j+2)-U(i*n+j+1))^2+(U(i*n+j+2)-U((i+1)*n+j+2))^2+1/(n-1)^2) + (U(i*n+j+1)-U((i+1)*n+j+1))/sqrt((U((i+1)*n+j+2)-U((i+1)*n+j+1))^2+(U((i+1)*n+j+1)-U(i*n+j+1))^2+1/(n-1)^2) ); end end end function [A] = inhalt(U,n) for i=1:n for j=1:n x( (i-1)*n+j ) = (j-1)/(n-1); y( (i-1)*n+j ) = (i-1)/(n-1); z( (i-1)*n+j ) = U( (i-1)*n+j ); end end for i=1:(n-1) for j=1:(n-1) t1( 2*(n-1)*(i-1)+j ) = (i-1)*n+j ; t2( 2*(n-1)*(i-1)+j ) = (i-1)*n+j+1; t3( 2*(n-1)*(i-1)+j ) = i*n+j+1; t1( 2*(n-1)*(i-1)+(n-1)+j ) = (i-1)*n+j; t2( 2*(n-1)*(i-1)+(n-1)+j ) = i*n+j; t3( 2*(n-1)*(i-1)+(n-1)+j ) = i*n+j+1; end end A=0; for i=1:2*(n-1)^2 A = A + 1/2*norm( [ ( z(t2(i)) - z(t1(i)))*(y(t3(i))-y(t1(i))) - (y(t2(i)) - y(t1(i)))*(z(t3(i))-z(t1(i))); (x(t2(i))-x(t1(i)))*(z(t3(i))-z(t1(i))) - (z(t2(i))-z(t1(i)))*(x(t3(i))-x(t1(i)));(x(t2(i))-x(t1(i)))*(y(t3(i))-y(t1(i))) - (y(t2(i))-y(t1(i)))*(x(t3(i))-x(t1(i)))] ); end end function [u,fu] = quanew(u0,B0,n) i=1; u(:,i) = u0; fu(:,i) = inhalt(u0,n); grafu(:,i) = gradinhalt(u(:,i),n); B=B0; while norm( grafu(:,i) ) > 10^(-10) grafu(:,i); d= - B*grafu(:,i); u(:,i+1)= u(:,i) + d; fu(:,i+1)= inhalt( u(:,i),n); grafu(:,i+1) = gradinhalt(u(:,i+1),n); B=B + ( (d-B*(grafu(:,i+1)-grafu(:,i)))*(d)' + d*(d-B*(grafu(:,i+1)-grafu(:,i)))' )/(d'*(grafu(:,i+1)-grafu(:,i)))- (d-B*(grafu(:,i+1)-grafu(:,i)))'*(grafu(:,i+1)-grafu(:,i))/(d'*(grafu(:,i+1)-grafu(:,i)))^2*d*d'; i=i+1; end end