clear all; close all; clc;
% x=sym('x',[2,1]);
% f=(x(1)+2*x(2)-7)^2+(2*x(1)+x(2)-5)^2;
% df=gradient(f);
% H=hessian(f);
% f=matlabFunction(f,'Vars',([x(1);x(2)]));
% df=matlabFunction(df,'Vars',([x(1);x(2)]));
% H=matlabFunction(H,'Vars',([x(1);x(2)]));
f=@(x)(x(1)+2*x(2)-7)^2+(2*x(1)+x(2)-5)^2;
df=@(x)[10*x(1)+8*x(2)-34;
8*x(1)+10*x(2)-38];
H=[10,8;8,10];
xmin=[-10;10];
xmax=[10;10];
x1=linspace(xmin(1),xmax(1),50);
x2=linspace(xmin(2),xmax(2),50);
y=zeros(50);
for i=1:50
for j=1:50
y(j,i)=f([x1(i);x2(j)]);
end
end
surf(x1,x2,y);
x0=20*rand(2,1)-10;
h=0.05;
epsilon=1e-3;
Nmax=1e3;
delta=1e-6;
x_opt=[];
i=1;
while true
[h,x0]=naj_spadek(df,x0,x_opt);
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}