  function dStar = InvEig(lambda)
% lambda is a column n-vector with the property that
%     lambda(1) < lambda(2) < ... < lambda(n)
% and |lambda(k) - lambda(k+1)| > 1, k=1:n-1
% d is a column n-vector with the property that if T is a symmetric
% tridiagonal matrix with diagonal d and sub (super) diagonal entries 
% equal to 1, then its eigenvalues are lambda(1),...,lambda(n)

dStar = fsolve(@(d) F(d,lambda),lambda);

  function e = F(d,lambda)
% This function returns the value of lambda - eig(T)
n = length(d);
T = diag(d) + diag(ones(n-1,1)/10,-1) + diag(ones(n-1,1)/10,1);
e = eig(T)-lambda;

% Grading:
% 2 for using fsolve correctly
% 3 for a working objective function
%
% -1 for not using eig in the objective function