85.53.2 problem 1 (b)

Internal problem ID [22815]
Book : Applied Differential Equations. By Murray R. Spiegel. 3rd edition. 1980. Pearson. ISBN 978-0130400970
Section : Chapter 4. Linear differential equations. A Exercises at page 197
Problem number : 1 (b)
Date solved : Thursday, October 02, 2025 at 09:14:53 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

\begin{align*} y^{\prime \prime }+y&=x^{2}+\sin \left (x \right ) \end{align*}
Maple. Time used: 0.002 (sec). Leaf size: 22
ode:=diff(diff(y(x),x),x)+y(x) = x^2+sin(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = \sin \left (x \right ) c_2 +\cos \left (x \right ) c_1 +x^{2}-2-\frac {\cos \left (x \right ) x}{2} \]
Mathematica. Time used: 0.09 (sec). Leaf size: 26
ode=D[y[x],{x,2}]+y[x]==x^2+Sin[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\begin{align*} y(x)&\to x^2+\left (-\frac {x}{2}+c_1\right ) \cos (x)+c_2 \sin (x)-2 \end{align*}
Sympy. Time used: 0.074 (sec). Leaf size: 20
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(-x**2 + y(x) - sin(x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = C_{2} \sin {\left (x \right )} + x^{2} + \left (C_{1} - \frac {x}{2}\right ) \cos {\left (x \right )} - 2 \]