(* Mathematica system homework. 
   This program can be used to simulate the response
   of a second order system towards most forcing functions. *)

(* Load the Laplace package *)
   Needs["Calculus`LaplaceTransform`"]

(* USER - Input your forcing function here! *)

   f[t_] := 0.5 Sin[5 t]

(* Laplace transform the forcing function *)
   fbar[s_] := LaplaceTransform[f[t],t,s]

(* Define the second order transfer function *)
   gain2 = .
   tau2 = .
   zeta2 = .
   G2[s_] := gain2/(tau2^2 s^2 + 2 tau2 zeta2 s + 1)

(* Define the Laplace transform of the second order
   output in terms of the transfer function and input *)
   y2bar[s_] := G2[s] fbar[s]

(* Find the time domain solution *)
   y2[t_,gain2_,tau2_,zeta2_] = InverseLaplaceTransform[y2bar[s],s,t];

(* Define the second order response as a plot *)
second[gain2_,tau2_,zeta2_] := Plot[y2[t,gain2,tau2,zeta2]/gain2, 
                               {t,0.01,15},AxesLabel->{TIME,OUTPUT}]

second[2,1,2]