Solve an Initial Value Problem Using a Green's Function
Solve an initial value problem for an inhomogeneous differential equation using GreenFunction.
First, compute the Green's function.
In[1]:=
![Click for copyable input](assets.en/solve-an-initial-value-problem-using-a-greens-func/In_114.png)
gf[s_, t_] =
GreenFunction[{-u''[t] + u'[t] - 37/4 u[t], u[0] == 0, u'[0] == 0},
u[t], {t, 0, \[Infinity]}, s]
Out[1]=
![](assets.en/solve-an-initial-value-problem-using-a-greens-func/O_61.png)
Define a forcing function.
In[2]:=
![Click for copyable input](assets.en/solve-an-initial-value-problem-using-a-greens-func/In_115.png)
f[t_] := Cos[a t]
Convolving the Green's function with the forcing function yields the solution.
In[3]:=
![Click for copyable input](assets.en/solve-an-initial-value-problem-using-a-greens-func/In_116.png)
sol = Integrate[gf[s, t] f[s], {s, 0, \[Infinity]},
Assumptions -> t > 0]
Out[3]=
![](assets.en/solve-an-initial-value-problem-using-a-greens-func/O_62.png)
Compare with the result given by DSolveValue.
In[4]:=
![Click for copyable input](assets.en/solve-an-initial-value-problem-using-a-greens-func/In_117.png)
DSolveValue[{-u''[t] + u'[t] - 37/4 u[t] == f[t], u[0] == 0,
u'[0] == 0}, u[t], t] // FullSimplify
Out[4]=
![](assets.en/solve-an-initial-value-problem-using-a-greens-func/O_63.png)
Plot the solution for different values of the parameter .
In[5]:=
![Click for copyable input](assets.en/solve-an-initial-value-problem-using-a-greens-func/In_118.png)
Plot[Table[sol, {a, 1, 4, 0.8}] // Evaluate, {t, 3, 6}]
Out[5]=
![](assets.en/solve-an-initial-value-problem-using-a-greens-func/O_64.png)