Demo entry 6328710

A20

   

Submitted by anonymous on Nov 29, 2016 at 05:38
Language: Matlab. Code size: 933 Bytes.

clear all;
close all;
%% A 
f = @(X,Y) 25*X.^2 + Y.^2;
gradf = @(x) [50*x(1);2*x(2)];
hessef = [50, 0; 0, 2];
x0 = [1;1];
[xk] = SteilsterAbstieg(gradf,hessef,x0,10e-10);
PlotIT(xk,f);

%% B (i)
f = @(X,Y) X.^2 + 10*Y.^2;
gradf = @(x) [1*x(1);10*x(2)];
hessef = [1, 0; 0, 10];
x0 = [1;.1];
[xk] = SteilsterAbstieg(gradf,hessef,x0,10e-5);
length(xk)
PlotIT(xk,f);
%% B (ii)
%TODO

%% C
f = @(X,Y) 1/4*(X-5).^2 + (Y-6).^2;
gradf = @(x) [1/2*(x(1)-5);2*(x(2)-6)];
hessef = [1/2, 0; 0, 2];
x0i = [9;7];
[xki] = SteilsterAbstieg(gradf,hessef,x0i,10e-10);
x0ii = [9;10];
[xkii] = SteilsterAbstieg(gradf,hessef,x0ii,10e-10);
PlotIT(xki,f,-5,15,xkii)
l_i = length(xki);
l_ii = length(xkii);
% $f(\bar{x}) = 0$ daher: 
cki = f(xki(1,2:l_i),xki(2,2:l_i))./f(xki(1,1:l_i-1),xki(2,1:l_i-1));
ckii = f(xkii(1,2:l_ii),xkii(2,2:l_ii))./f(xkii(1,1:l_ii-1),xkii(2,1:l_ii-1));
figure
hold on 
plot(cki)
plot(ckii)

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).