function ys = fsApprox(fun, xs, numTerms, r_end = pi)
% function ys = fsApprox(fun, xs, N, r_end)
%
%   This routine computes the values of the truncated classical
%   Fourier series on [-r_end, r_end].  The values correspond to
%   the numbers (inputs) in the vector xs.
%
%   INPUTS:
%    fun     The function whose truncated classical Fourier series (CFS) is desired
%     xs     A vector of numbers at which the truncated CFS should be evaluated
%      N     The number of terms to keep before truncation
%  r_end     The right endpoint of the interval of approximation;
%            This defaults to pi.
%
%   OUTPUTS: A vector of values corresponding to those in xs

  [ak, bk] = fourierCoeffs(fun, numTerms, -r_end, r_end);
  ys = ak(1)/2*ones(size(xs));

  for kk = 1:numTerms
    ys = ys + ak(kk+1)*cos(kk*pi*xs/r_end) + bk(kk)*sin(kk*pi*xs/r_end);
  end

end

