(* Copy these commands into your own notebook. *)

Pendulum[{θ0_,ω0_},tmax_]:=
Module[{θ},
θ/.First[
NDSolve[{
θ''[t]==-Sin[θ[t]],
θ[0]==θ0,
θ'[0]==ω0},
θ,{t,0,tmax}]
]]

DDPendulum[{θ0_,ω0_},tmax_]:=
Module[{θ},
θ/.First[
NDSolve[{
θ''[t]==-Sin[θ[t]]-0.05θ'[t]+2.5Sin[t],
θ[0]==θ0,
θ'[0]==ω0},
θ,{t,0,tmax}]
]]

(* Example use. *)
f =Pendulum[{π/4,0},30];
Plot[f[t],{t,0,30}]

(* Don't use values for t greater than tmax. *)
f = Pendulum[{π/4,0},30];
f[40]