23.2.24 problem 9

Internal problem ID [4141]
Book : Theory and solutions of Ordinary Differential equations, Donald Greenspan, 1960
Section : Chapter 3. Linear differential equations of second order. Exercises at page 31
Problem number : 9
Date solved : Tuesday, March 04, 2025 at 05:53:29 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+2 n y^{\prime }+n^{2} y&=A \cos \left (p x \right ) \end{align*}

With initial conditions

\begin{align*} y \left (0\right )&=9\\ y^{\prime }\left (0\right )&=0 \end{align*}

Maple. Time used: 0.069 (sec). Leaf size: 109
ode:=diff(diff(y(x),x),x)+2*n*diff(y(x),x)+n^2*y(x) = A*cos(p*x); 
ic:=y(0) = 9, D(y)(0) = 0; 
dsolve([ode,ic],y(x), singsol=all);
 
\[ y \left (x \right ) = \frac {\left (9 n^{5} x +9 n^{4}-x \left (-18 p^{2}+A \right ) n^{3}+\left (18 p^{2}-A \right ) n^{2}-p^{2} x \left (-9 p^{2}+A \right ) n +p^{2} \left (9 p^{2}+A \right )\right ) {\mathrm e}^{-n x}+\left (\left (n^{2}-p^{2}\right ) \cos \left (p x \right )+2 \sin \left (p x \right ) n p \right ) A}{\left (n^{2}+p^{2}\right )^{2}} \]
Mathematica. Time used: 0.046 (sec). Leaf size: 76
ode=D[y[x],{x,2}]+2*n*D[y[x],x]+n^2*y[x]==A*Cos[p*x]; 
ic={y[0]==0,Derivative[1][y][0] ==0}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to -\frac {A e^{-n x} \left (n^3 x-\left (n^2-p^2\right ) e^{n x} \cos (p x)+n^2+n p^2 x-2 n p e^{n x} \sin (p x)-p^2\right )}{\left (n^2+p^2\right )^2} \]
Sympy. Time used: 0.374 (sec). Leaf size: 153
from sympy import * 
x = symbols("x") 
A = symbols("A") 
n = symbols("n") 
p = symbols("p") 
y = Function("y") 
ode = Eq(-A*cos(p*x) + n**2*y(x) + 2*n*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {y(0): 9, Subs(Derivative(y(x), x), x, 0): 0} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \frac {A n^{2} \cos {\left (p x \right )}}{n^{4} + 2 n^{2} p^{2} + p^{4}} + \frac {2 A n p \sin {\left (p x \right )}}{n^{4} + 2 n^{2} p^{2} + p^{4}} - \frac {A p^{2} \cos {\left (p x \right )}}{n^{4} + 2 n^{2} p^{2} + p^{4}} + \left (\frac {x \left (- A n + 9 n^{3} + 9 n p^{2}\right )}{n^{2} + p^{2}} + \frac {- A n^{2} + A p^{2} + 9 n^{4} + 18 n^{2} p^{2} + 9 p^{4}}{n^{4} + 2 n^{2} p^{2} + p^{4}}\right ) e^{- n x} \]