This is a very interesting problem! Convolution of the loss term for the harmonic oscillator. I had been working on some extensions of the same approach that Sam posted so I will post these. To begin with I think it's better to redefine constants in the convolution loss term.
MODIFIED below to redfine constants so as to eliminate factors of (1/m) that were floating around
For the standard harmonic oscillator,
mu'' + Ru' + ku = F cos(wt)
and defining R/m = g (gamma) k/m = w0^2 then
u'' + g u' + w0^2 u = (F/m) cos(wt)
For the convolution version, start with a convolution integral involving a function R(t-tau) and define R/m = c. Then
u'' + G(t) + w0^2 u = (F/m) cos(wt)
G(t) = Int{0,t} c(t-tau) u'(tau) dtau
For the case at hand
then
(d/dt + a) G(t) = b u'(t)
and the system consists of that result combined with
u'' + G + w0^2 u = (F/m) cos(wt)
Let
The odefun is
0 b -a ] y + (F/m) cos(wt) [0 1 0]'
with initial condition G(0) = 0, all of which was covered by Sam. An advantage of this method is that as well as u and u' you get the convolution integral as a function of time.
In everything below, the initial condition for every G is zero.
Some generalizations of c are possible. These are sums of functions of the form
which include e.g.
and mixtures of those. If additional easily calculated c functions don't come around, then one task would be to fit an arbitrary c function to sums of these functions There are more possibilites for success there than it might seem. For example in addition to [ t e^(-at) ], the function [ e^(-a1 t) - e^(-a2 t) ] also equals 0 at the origin and has one peak.
a) For polynomials you can define the convolutions
G_n = Int{0,t} b (t-tau)^n e^(-a(t-tau)) u'(tau) dtau
in which case
(d/dt + a) G_n) = n G_(n-1)
For a fourth degree polynomial with
y = [u u' G4 G3 G2 G1 G0]'
then after a straightforward process the odefun looks like
0 24b0 0 0 0 0 -a] y + (F/m) cos(wt) [0 1 0 0 0 0 0]'
A better loooking result is obtained by rescaling the G's with
Gnew_n = Gold_n / (4-n)!
in which case
0 b0 0 0 0 0 -a] y + (F/m) cos(wt) [0 1 0 0 0 0 0]'
b) An easier process is the sums of terms of the same type. For e.g. three exponentials the odefun is
0 b3 0 0 -a3 ] y + (F/m) cos(wt) [0 1 0 0 0]'