74.21.5 problem 21 (a)

Internal problem ID [16572]
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 (a)
Date solved : Monday, March 31, 2025 at 02:59:21 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 )&=0 \end{align*}

Maple. Time used: 0.014 (sec). Leaf size: 9
ode:=diff(diff(x(t),t),t)+x(t) = cos(t); 
ic:=x(0) = 0, D(x)(0) = 0; 
dsolve([ode,ic],x(t), singsol=all);
 
\[ x = \frac {\sin \left (t \right ) t}{2} \]
Mathematica. Time used: 0.026 (sec). Leaf size: 44
ode=D[x[t],{t,2}]+x[t]==Cos[t]; 
ic={x[0]==0,Derivative[1][x][0 ]==0}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\[ 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)\right ) \]
Sympy. Time used: 0.093 (sec). Leaf size: 8
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): 0} 
dsolve(ode,func=x(t),ics=ics)
 
\[ x{\left (t \right )} = \frac {t \sin {\left (t \right )}}{2} \]