8.11.13 problem 23

Internal problem ID [881]
Book : Differential equations and linear algebra, 3rd ed., Edwards and Penney
Section : Section 5.5, Nonhomogeneous equations and undetermined coefficients Page 351
Problem number : 23
Date solved : Tuesday, March 04, 2025 at 11:57:27 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

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