4.24.40 $$y''(x)+y(x)=\tan ^2(x)$$

ODE
$y''(x)+y(x)=\tan ^2(x)$ ODE Classiﬁcation

[[_2nd_order, _linear, _nonhomogeneous]]

Book solution method
TO DO

Mathematica
cpu = 0.22364 (sec), leaf count = 50

$\left \{\left \{y(x)\to c_1 \cos (x)+\sin (x) \left (-\log \left (\cos \left (\frac {x}{2}\right )-\sin \left (\frac {x}{2}\right )\right )+\log \left (\sin \left (\frac {x}{2}\right )+\cos \left (\frac {x}{2}\right )\right )+c_2\right )-2\right \}\right \}$

Maple
cpu = 0.498 (sec), leaf count = 27

$\left [y \left (x \right ) = \sin \left (x \right ) \textit {\_C2} +\textit {\_C1} \cos \left (x \right )-2+\sin \left (x \right ) \ln \left (\frac {1+\sin \left (x \right )}{\cos \left (x \right )}\right )\right ]$ Mathematica raw input

DSolve[y[x] + y''[x] == Tan[x]^2,y[x],x]

Mathematica raw output

{{y[x] -> -2 + C[1]*Cos[x] + (C[2] - Log[Cos[x/2] - Sin[x/2]] + Log[Cos[x/2] + S
in[x/2]])*Sin[x]}}

Maple raw input

dsolve(diff(diff(y(x),x),x)+y(x) = tan(x)^2, y(x))

Maple raw output

[y(x) = sin(x)*_C2+_C1*cos(x)-2+sin(x)*ln((1+sin(x))/cos(x))]