78.2.40 problem 16.b

Internal problem ID [20992]
Book : A FIRST COURSE IN DIFFERENTIAL EQUATIONS FOR SCIENTISTS AND ENGINEERS. By Russell Herman. University of North Carolina Wilmington. LibreText. compiled on 06/09/2025
Section : Chapter 2, Second order ODEs. Problems section 2.6
Problem number : 16.b
Date solved : Thursday, October 02, 2025 at 07:01:11 PM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

With initial conditions

\begin{align*} x \left (0\right )&=4 \\ x^{\prime }\left (0\right )&=0 \\ \end{align*}
Maple. Time used: 0.020 (sec). Leaf size: 23
ode:=diff(diff(x(t),t),t)+x(t) = 2*tan(t); 
ic:=[x(0) = 4, D(x)(0) = 0]; 
dsolve([ode,op(ic)],x(t), singsol=all);
 
\[ x = 2 \sin \left (t \right )+4 \cos \left (t \right )-2 \cos \left (t \right ) \ln \left (\sec \left (t \right )+\tan \left (t \right )\right ) \]
Mathematica. Time used: 0.011 (sec). Leaf size: 19
ode=D[x[t],{t,2}]+x[t]==2*tan(t); 
ic={x[0]==4,Derivative[1][x][0] ==0}; 
DSolve[{ode,ic},x[t],t,IncludeSingularSolutions->True]
 
\begin{align*} x(t)&\to 4 \cos (t)+2 \tan (t-\sin (t)) \end{align*}
Sympy. Time used: 0.206 (sec). Leaf size: 29
from sympy import * 
t = symbols("t") 
x = Function("x") 
ode = Eq(x(t) - 2*tan(t) + Derivative(x(t), (t, 2)),0) 
ics = {x(0): 4, Subs(Derivative(x(t), t), t, 0): 0} 
dsolve(ode,func=x(t),ics=ics)
 
\[ x{\left (t \right )} = \left (\log {\left (\sin {\left (t \right )} - 1 \right )} - \log {\left (\sin {\left (t \right )} + 1 \right )} + 4 - i \pi \right ) \cos {\left (t \right )} + 2 \sin {\left (t \right )} \]