function [f,G]=evenft(t, g, fmax, df)
%function [f,G]=evenft(t, g, fmax, df);
%Calculates the Fourier Transform of an even function of time;
%[t,g]=even time function;
%fmax=upperlimit on frequency;
%df=freq step;

%assume even time spacing;
dt=t(2)-t(1);
%initialize frequency counter and freq vector;
n=1;
f=0:df:fmax;
%initialize transform vector;
G=zeros(size(f));
%generate integral of cos * g *dt for each frequency;
while f(n)<fmax
  cosvect=cos(2*pi*f(n)*t);
  G(n)=sum(cosvect.*g)*dt;
  n=n+1;
end
