38.4.7 problem 7

Internal problem ID [6493]
Book : Engineering Mathematics. By K. A. Stroud. 5th edition. Industrial press Inc. NY. 2001
Section : Program 25. Second order differential equations. Further problems 25. page 1094
Problem number : 7
Date solved : Wednesday, March 05, 2025 at 12:52:34 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.003 (sec). Leaf size: 22
ode:=diff(diff(y(x),x),x)+4*diff(y(x),x)+4*y(x) = 2*cos(x)^2; 
dsolve(ode,y(x), singsol=all);
 
\[ y = \frac {1}{4}+\left (c_1 x +c_2 \right ) {\mathrm e}^{-2 x}+\frac {\sin \left (2 x \right )}{8} \]
Mathematica. Time used: 0.124 (sec). Leaf size: 29
ode=D[y[x],{x,2}]+4*D[y[x],x]+4*y[x]==2*Cos[x]^2; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{8} \left (\sin (2 x)+8 e^{-2 x} (c_2 x+c_1)+2\right ) \]
Sympy. Time used: 0.768 (sec). Leaf size: 22
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(4*y(x) - 2*cos(x)**2 + 4*Derivative(y(x), x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (C_{1} + C_{2} x\right ) e^{- 2 x} + \frac {\sin {\left (2 x \right )}}{8} + \frac {1}{4} \]