54.1.1 problem 1

Internal problem ID [8529]
Book : Elementary differential equations. Rainville, Bedient, Bedient. Prentice Hall. NJ. 8th edition. 1997.
Section : CHAPTER 8. Nonhomogeneous Equations: Undetermined Coefficients. Exercises Page 142
Problem number : 1
Date solved : Wednesday, March 05, 2025 at 06:02:42 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

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