68.21.6 problem 21 (b)

Internal problem ID [17931]
Book : INTRODUCTORY DIFFERENTIAL EQUATIONS. Martha L. Abell, James P. Braselton. Fourth edition 2014. ElScAe. 2014
Section : Chapter 5. Applications of Higher Order Equations. Exercises 5.3, page 249
Problem number : 21 (b)
Date solved : Thursday, October 02, 2025 at 02:30:03 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

\begin{align*} x \left (0\right )&=0 \\ x^{\prime }\left (0\right )&=1 \\ \end{align*}
Maple. Time used: 0.018 (sec). Leaf size: 12
ode:=diff(diff(x(t),t),t)+x(t) = cos(t); 
ic:=[x(0) = 0, D(x)(0) = 1]; 
dsolve([ode,op(ic)],x(t), singsol=all);
 
\[ x = \sin \left (t \right ) \left (1+\frac {t}{2}\right ) \]
Mathematica. Time used: 0.014 (sec). Leaf size: 45
ode=D[x[t],{t,2}]+x[t]==Cos[t]; 
ic={x[0]==0,Derivative[1][x][0 ]==1}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\begin{align*} x(t)&\to -\frac {1}{4} \sin (t) \left (-4 \int _1^t\cos ^2(K[1])dK[1]+4 \int _1^0\cos ^2(K[1])dK[1]+\sin (2 t)-4\right ) \end{align*}
Sympy. Time used: 0.053 (sec). Leaf size: 10
from sympy import * 
t = symbols("t") 
x = Function("x") 
ode = Eq(x(t) - cos(t) + Derivative(x(t), (t, 2)),0) 
ics = {x(0): 0, Subs(Derivative(x(t), t), t, 0): 1} 
dsolve(ode,func=x(t),ics=ics)
 
\[ x{\left (t \right )} = \left (\frac {t}{2} + 1\right ) \sin {\left (t \right )} \]