0001 function nleqs_master_ex1(alg)
0002 if nargin < 1
0003 alg = 'DEFAULT';
0004 end
0005 problem = struct( ...
0006 'fcn', @f1, ...
0007 'x0', [0; 0], ...
0008 'opt', struct('verbose', 2, 'alg', alg) ...
0009 );
0010 [x, f, exitflag, output, jac] = nleqs_master(problem);
0011 fprintf('\nexitflag = %d\n', exitflag);
0012 fprintf('\nx = \n');
0013 fprintf(' %2g\n', x);
0014 fprintf('\nf = \n');
0015 fprintf(' %12g\n', f);
0016 fprintf('\njac =\n');
0017 fprintf(' %2g %2g\n', jac');
0018
0019 function [f, J] = f1(x)
0020
0021 f = [ x(1) + x(2) - 1;
0022 -x(1)^2 + x(2) + 5 ];
0023 if nargout > 1
0024 J = [1 1; -2*x(1) 1];
0025 end