%
%  trust-region trajectory for a convex quadratic
%
%  Nick Gould

lambda0 = 0:0.001:1;
lambda1 = 1.01:100;
lambda2 = 100;1;1000;
lambda = [lambda0 lambda1 lambda2];
inc = 0.005 ;
x = -1.5:inc:0.5;
y = -1:inc:1;
side = length( x );
[X,Y]  = meshgrid(x,y);
ll0 = -1:0.2:5;
levels = [ll0];
F = 0.5 * X.^2 + 1.5 * Y.^2 + X + Y;
contour(x,y,F,levels);
axis( [ -1.5 0.5 -1 1 ] )
axis( 'square')

hold on

sx = - 1 ./ ( 1 + lambda ) ;
sy = - 1 ./ ( 3 + lambda ) ;

plot(sx, sy, 'r','LineWidth',2 );

xsd = -0.5:0.01:0;
ysd = -0.5:0.01:0;

xstart = 0:0.1:0;
ystart = 0:0.1:0;

third = -1/3;
xsol = -1:0.1:-1 ;
ysol = third;0.01;third;

plot(xsd, ysd, ':k', 'MarkerSize', 2 )
plot(xsol, ysol, 'ok', 'MarkerFaceColor','g', 'MarkerSize', 5 )
plot(xstart, ystart, 'ok', 'MarkerFaceColor','c', 'MarkerSize', 5 )

hold off

grid off

print -depsc eps/trpath

