function y = prob3sec(guess1, guess2)

% Problem 3 in secant method
%
% exp(-x) - x = 0
%
% Returns an array containing all of the successive approximations.

%
tolerance = 1e-10;

x0 = guess1;
x1 = guess2;

% Swap if necessary
if (abs(prob3eq2(x0)) < abs(prob3eq2(x1)))
	temp = x0;
	x0 = x1;
	x1 = x0;
end
ret = [x0 x1] % Starting value


continue = 1;
% Now iterate.
while (continue) 
	x2 = x0 - prob3eq2(x0) * (x0 - x1)/(prob3eq2(x0)-prob3eq2(x1))
	ret = [ret x2];
	x0 = x1;
	x1 = x2;
	if (abs(prob3eq2(x2)) < tolerance)
		continue = 0;
	end
end

y = ret;
