function x = exactOscillator( w, x0, v0, dt, tmax )
%
% Exact solution for a harmonic oscillator of frequency w:
%   x(t) = x0*cos(w*t) + v0/w*sin(w*t)
% J.M.Soler, Jan.2011
%
% Input:
%   w    : oscillator's angular frequency, in s^-1
%   x0   : initial position, in m
%   v0   : initial velocity, in m/s
%   dt   : integration time interval, in s
%   tmax : maximum time of solutions, in s

t = (0:dt:tmax);
x = x0*cos(w*t) + v0/w*sin(w*t);

end % function


