28.2.63 problem 63

Internal problem ID [4506]
Book : Differential equations for engineers by Wei-Chau XIE, Cambridge Press 2010
Section : Chapter 4. Linear Differential Equations. Page 183
Problem number : 63
Date solved : Sunday, March 30, 2025 at 03:24:19 AM
CAS classification : [[_2nd_order, _linear, _nonhomogeneous]]

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

Maple. Time used: 0.002 (sec). Leaf size: 40
ode:=diff(diff(y(x),x),x)+4*y(x) = 2*tan(x); 
dsolve(ode,y(x), singsol=all);
 
\[ y = 2 \ln \left (\cos \left (x \right )\right ) \sin \left (x \right ) \cos \left (x \right )+\left (-2 x +2 c_1 \right ) \cos \left (x \right )^{2}+\sin \left (x \right ) \left (2 c_2 +1\right ) \cos \left (x \right )+x -c_1 \]
Mathematica. Time used: 0.047 (sec). Leaf size: 33
ode=D[y[x],{x,2}]+4*y[x]==2*Tan[x]; 
ic={}; 
DSolve[{ode,ic},y[x],x,IncludeSingularSolutions->True]
 
\[ y(x)\to (-x+c_1) \cos (2 x)+\sin (x) \cos (x) (2 \log (\cos (x))-1+2 c_2) \]
Sympy. Time used: 0.797 (sec). Leaf size: 22
from sympy import * 
x = symbols("x") 
y = Function("y") 
ode = Eq(4*y(x) - 2*tan(x) + Derivative(y(x), (x, 2)),0) 
ics = {} 
dsolve(ode,func=y(x),ics=ics)
 
\[ y{\left (x \right )} = \left (C_{1} - x\right ) \cos {\left (2 x \right )} + \left (C_{2} + \log {\left (\cos {\left (x \right )} \right )}\right ) \sin {\left (2 x \right )} \]