Solution (source code)

= Solution

Start with the <Maclaurin series> $\cos x=1-x^2/2+x^4/24+O(x^6)$. Put $z=-x^2/2+x^4/24+O(x^6)$ into the <binomial series> $(1+z)^{-2}=1-2z+3z^2+O(z^3)$. Keeping terms through $x^4$ gives
$$
(\cos x)^{-2}=1-2\left(-\frac{x^2}{2}+\frac{x^4}{24}\right)+3\left(\frac{x^4}{4}\right)+O(x^6),
$$
so
$$
\boxed{\sec^2x=1+x^2+\frac23x^4+O(x^6)}.
$$
Since $d(\tan x)/dx=\sec^2x$ and $\tan0=0$, term-by-term <integration> supplies the <constant of integration> and gives
$$
\boxed{\tan x=x+\frac{x^3}{3}+\frac{2x^5}{15}+O(x^7)}.
$$
The expansions hold near zero; the nearest real poles at $\pm\pi/2$ limit their <radius of convergence> to $\pi/2$. The derivative relation also independently checks all three displayed coefficients of the <tangent function>.