> restart;
> with( DEtools ):
> with( plots ):
>
> VAR := { y(t) }:
> MODEL := diff( y(t), t$2 ) + 2 * y(t) = 3*sin( omega*t );
> IC := y(0)=1, D(y)(0)=0;
>
> dsolve( { MODEL, IC }, VAR );
> combine( rhs(%) );
> SOLN := collect( %, { cos( sqrt(2)*t ), sin( sqrt(2)*t) } );
Note that this solution contains two terms which appear in the homogeneous solution and one term that is a particular solution to the nonhomogeneous equation.
>
> Omega := [ 0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.1, 1.2, 1.3, 1.4 ]:
> P := seq( plot( subs( omega=w, SOLN ), t=0..50 ), w=Omega ):
> display( P, insequence=true );
>
> dsolve( subs( omega=sqrt(2), { MODEL, IC } ), VAR );
> simplify( % );
>