Example 5.22. Expand the function $f(x)=\cos ^{2} x$ into a Taylor series.
Solution. By a well-known trigonometric formula, we have:

$$
\cos ^{2} x=\frac{1+\cos 2 x}{2}
$$

We expand the function $\cos 2 x$ into a Taylor series, replacing $x$ with $2 x$ in expansion (4):

$$
\cos 2 x=1-\frac{(2 x)^{2}}{2!}+\frac{(2 x)^{4}}{4!}-\ldots+(-1)^{n} \frac{(2 x)^{n}}{(2 n)!}+\ldots
$$

or

$$
\cos 2 x=1-\frac{2^{2}}{2!} x^{2}+\frac{2^{4}}{4!} x^{4}-\ldots+(-1)^{n} \frac{2^{2 n}}{(2 n)!} x^{2 n}+\ldots
$$

Expansion (4) is valid for any $x$, so the Taylor series for $\cos 2 x$ converges to the function that generated it over the entire real line.

To obtain the Taylor series expansion of the function $\frac{1}{2} \cos 2 x$, we multiply all terms of the series (*) by $\frac{1}{2}$:

$$
\frac{1}{2} \cos 2 x=\frac{1}{2}-\frac{2}{2!} x^{2}+\frac{2^{3}}{4!} x^{4}-\ldots+(-1)^{n} \frac{2^{2 n-1}}{(2 n)!} x^{2 n}+\ldots
$$

Then

$$
\frac{1}{2}+\frac{1}{2} \cos 2 x=1-\frac{2}{2!} x^{2}+\frac{2^{3}}{4!} x^{4}-\ldots+(-1)^{n} \frac{2^{2 n-1}}{(2 n)!} x^{2 n}+\ldots
$$

This is the Taylor series expansion of the function $f(x)=\cos ^{2} x$. It is clear that it is valid for any $x$.