Solution (source code)

= Solution

Differentiating the logarithm gives
$$
\frac d{dt}\log(\sec t+\tan t)=\frac{\sec t\tan t+\sec^2t}{\sec t+\tan t}=\sec t.
$$
The real logarithm is valid where its argument is positive; $\log|\sec t+\tan t|$ gives the same derivative on the other nonsingular intervals.

For the <first-order linear differential equation>, an <integrating factor> on the interval containing $t=0$ is
$$
\mu(t)=\exp\left(\int3\tan t\,dt\right)=\sec^3t.
$$
Multiplying the equation by it yields $(x\sec^3t)'=\sec t$. Integration and $x(0)=2$ therefore give
$$
\boxed{x(t)=\cos^3t\left[2+\log(\sec t+\tan t)\right],\qquad-\frac\pi2<t<\frac\pi2.}
$$
The interval ends at singularities of the differential equation's coefficient $\tan t$; a finite limiting value of the expression would not remove those coefficient singularities.