69.33.17 problem 846

Internal problem ID [18586]
Book : A book of problems in ordinary differential equations. M.L. KRASNOV, A.L. KISELYOV, G.I. MARKARENKO. MIR, MOSCOW. 1983
Section : Chapter 3. Section 24.2. Solving the Cauchy problem for linear differential equation with constant coefficients. Exercises page 249
Problem number : 846
Date solved : Thursday, October 02, 2025 at 03:15:07 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Using Laplace method With initial conditions

\begin{align*} x \left (0\right )&=-1 \\ x^{\prime }\left (0\right )&=1 \\ \end{align*}
Maple. Time used: 0.103 (sec). Leaf size: 15
ode:=diff(diff(x(t),t),t)+x(t) = 2*cos(t); 
ic:=[x(0) = -1, D(x)(0) = 1]; 
dsolve([ode,op(ic)],x(t),method='laplace');
 
\[ x = -\cos \left (t \right )+\sin \left (t \right ) \left (1+t \right ) \]
Mathematica. Time used: 0.016 (sec). Leaf size: 51
ode=D[x[t],{t,2}]+x[t]==2*Cos[t]; 
ic={x[0]==-1,Derivative[1][x][0 ]==1}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\begin{align*} x(t)&\to -\sin (t) \int _1^02 \cos ^2(K[1])dK[1]+\sin (t) \int _1^t2 \cos ^2(K[1])dK[1]+\sin (t)+\cos ^3(t)-2 \cos (t) \end{align*}
Sympy. Time used: 0.049 (sec). Leaf size: 12
from sympy import * 
t = symbols("t") 
x = Function("x") 
ode = Eq(x(t) - 2*cos(t) + Derivative(x(t), (t, 2)),0) 
ics = {x(0): -1, Subs(Derivative(x(t), t), t, 0): 1} 
dsolve(ode,func=x(t),ics=ics)
 
\[ x{\left (t \right )} = \left (t + 1\right ) \sin {\left (t \right )} - \cos {\left (t \right )} \]