xmin = -1.0;
xmax = +3.0;
ymin = -2.5;
ymax = +2.5;

x = linspace ( xmin, xmax, 101 );
y = cos(x-1) - (x-1);
%
%  Plot function and zero.
%
figure ( 1 )
clf ( );
hold ( 'on' );
plot ( x, y, 'b-', 'linewidth', 4 );
plot ( [xmin,xmax], [0,0], 'k-' );
plot ( [0,0], [ymin,ymax], 'k-' );
x0 = 0.73 + 1.0;
y0 = 0.0;
plot ( x0, y0, 'r.', 'Markersize', 60 );
grid ( 'on' );
hold ( 'off' );
print ( '-dpng', 'secant1.png' );
%
%  Plot function and samples
%
figure ( 2 )
clf ( );
hold ( 'on' );
plot ( x, y, 'b-', 'linewidth', 2 );
plot ( [xmin,xmax], [0,0], 'k-' );
plot ( [0,0], [ymin,ymax], 'k-' );
x1 = 0.0;
y1 = cos(x1-1)-(x1-1);
x2 = 1.0;
y2 = cos(x2-1)-(x2-1);
plot ( x0, y0, 'r.', 'Markersize', 40 );
plot ( x1, y1, 'm.', 'Markersize', 60 );
plot ( x2, y2, 'm.', 'Markersize', 60 );
grid ( 'on' );
hold ( 'off' );
print ( '-dpng', 'secant2.png' );
%
%  Plot function and samples and estimate
%
figure ( 3 )
clf ( );
hold ( 'on' );
plot ( x, y, 'b-', 'linewidth', 2 );
plot ( [xmin,xmax], [0,0], 'k-' );
plot ( [0,0], [ymin,ymax], 'k-' );
plot ( x0, y0, 'r.', 'Markersize', 40 );
plot ( x1, y1, 'm.', 'Markersize', 40 );
plot ( x2, y2, 'm.', 'Markersize', 40 );
ys = y1 + ( y2 - y1 ) / ( x2 - x1 ) .* ( x - x1 );
plot ( x, ys, 'm-', 'linewidth', 4 );
x3 = 2.88;
y3 = 0.0;
plot ( x3, y3, 'c.', 'Markersize', 60 );
grid ( 'on' );
hold ( 'off' );
print ( '-dpng', 'secant3.png' );
