15.11.13 problem 13

Internal problem ID [3123]
Book : Differential Equations by Alfred L. Nelson, Karl W. Folley, Max Coral. 3rd ed. DC heath. Boston. 1964
Section : Exercise 19, page 86
Problem number : 13
Date solved : Tuesday, March 04, 2025 at 04:00:38 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.004 (sec). Leaf size: 26
ode:=diff(diff(y(x),x),x)+4*y(x) = x*sin(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (2 x \right ) c_2 +\cos \left (2 x \right ) c_{1} -\frac {2 \cos \left (x \right )}{9}+\frac {x \sin \left (x \right )}{3} \]
Mathematica. Time used: 0.02 (sec). Leaf size: 33
ode=D[y[x],{x,2}]+4*y[x]==x*Sin[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to \frac {1}{3} x \sin (x)+c_1 \cos (2 x)+\cos (x) \left (-\frac {2}{9}+2 c_2 \sin (x)\right ) \]
Sympy. Time used: 0.095 (sec). Leaf size: 29
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x*sin(x) + 4*y(x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{1} \sin {\left (2 x \right )} + C_{2} \cos {\left (2 x \right )} + \frac {x \sin {\left (x \right )}}{3} - \frac {2 \cos {\left (x \right )}}{9} \]