# Taylor polynomial of $f(x) = 1/(1+\cos x)$

I'm trying to solve a problem from a previous exam. Unfortunately there is no solution for this problem.

So, the problem is:

Calculate the Taylor polynommial (degree $4$) in $x_0 = 0$ of the function: $$f(x) = \frac{1}{1+\cos(x)}$$

What I tried so far:

• calculate all $4$ derivatives
• $1+\cos(x) = 2\cos^2(\frac{x}{2})$ and work with this formula
• $\int\frac{1}{1+\cos(x)}dx = \tan(\frac{x}{2})$ and then use the Taylor series of $\tan(\frac{x}{2})$
• $\frac{1}{1 + \cos(x)} = \frac{1}{1 + \left(1 + \frac{x^2}{2!} + \cdots\right)}$

What do you think, is there a good way to calculate the Taylor polynomial of this function or is there just the hard way (derivatves)?

-

Let's do this in a couple of different ways. We want to expand $\dfrac{1}{1 + \cos x}$.

Method 1

If it's not obvious what the best method is, we might just choose one and go. A fourth degree Taylor Expansion isn't so bad - it's only a few derivatives. So you might just go, suffer through a few derivatives, and save yourself the trouble of deciding the best way.

Alternately, if you happen to know the series for $\tan x$, then that's a great way to proceed (referring to your idea of using the series expansion for $\tan (x/2)$

Method 2

If we are certain it has a Taylor expansion, and we are comfortable then we know it will look like $a_0 + a_1x + a_2x^2/2 + \ldots$ We know that $\cos x = 1 - x^2/2 + x^4/4! + \ldots$, so that $\dfrac{1}{1 + \cos x} = \dfrac{1}{2 - x^2/2 + x^4/4! + \dots}$

So we consider $\dfrac{1}{2 - x^2/2 + x^4/4! + \dots} = a_0 + a_1x + a_2x^2/2 + \ldots$, or equivalently $$(a_0 + a_1x + a_2x^2/2 + \ldots)(2 - x^2/2 + x^4/4! + \dots) = 1$$

By equating the coefficients of powers of $x$ on the left and on the right (which are all $0$ except for $x^0$, which has coefficient $1$), we get that $2a_0 = 1$, $a_1 = 0$, $a_0(-x^2/2) + (a_2x^2/2)(2) = 0$, etc. This isn't too bad, and is just a set of linear equations.

-
wow, +1! thanks for this solution! –  lee.O Aug 3 '12 at 16:58
this way of finding a taylorpolynom is really good to know, thanks a lot! –  lee.O Aug 3 '12 at 17:18
I'm glad you like it - –  mixedmath Aug 3 '12 at 17:23

There are some things that can make it easier, since you are expanding around $x_0 = 0$.

Let $f(x) = \frac{1}{1+\cos x} = \left(1+\cos x\right)^{-1}$. We can compute $df/dx$ as $\frac{df}{dx} = -\left(1+\cos x\right)^{-2}\frac{d (1+\cos x)}{dx} = -\left(1+\cos x\right)^{-2}\sin x$. Now, we have a product rule situation going to higher derivatives.

This makes our life a little easier, since $\sin x_0 = \sin 0 = 0$. In other words, we can simply "not care" about higher-order derivatives that have a $\sin$ term in them.

So, in short, the best way to compute the Taylor expansion quickly for a few terms on an exam, in my opinion, is to compute the derivatives, and note that since we need to compute $\frac{d^nf}{dx^n}\mid_{x = 0}$, to just skip the rigor of computing in detail any term that gets multiplied by $\sin x$.

-
In fact, since the function to be expanded is an even function, one only needs to worry about computing the coefficients of the even-order terms... –  Guess who it is. Aug 3 '12 at 17:41
@J.M. Indeed. I'm hoping the OP recognizes the pattern -- it certainly helps in doing such computations quickly within a time limit. –  Arkamis Aug 3 '12 at 17:53
Thanks for your answer, I had to try it with your approach :). But @J.M. , what do you mean by "only needs to worry about the even-order-terms"? –  lee.O Aug 3 '12 at 20:01
@lee.O He means that "odd" derivatives will always wash out. Consider $$f'(x) = -\left(1+\cos x\right)^{-2}\sin x,$$ but $$f''(x) = 2\left(1+\cos x\right)^{-3}\sin x - \left(1+\cos x\right)^{-2}\cos x.$$ Compute these for $x=0$, and the $\sin x$ term makes $f'(0) = 0$ in the first derivative. For the second derivative, however, the $\sin x$ term only wipes out part of the answer. –  Arkamis Aug 3 '12 at 20:59
now i got it, thanks for your explanation! :) –  lee.O Aug 3 '12 at 21:23

$$\cos x=\sum_{k=0}^\infty (-1)^k\frac{x^{2k}}{(2k)!}=1+\cos x= 2-\frac{x^2}{2}+\frac{x^4}{24}-...\Longrightarrow$$

$$\frac{1}{1+\cos x}=\frac{1}{2-\frac{x^2}{2}+\frac{x^4}{24}-...}=\frac{1}{2}\frac{1}{\left[1-\left(\frac{x}{2}\right)^2\right]\left(1-\frac{x^2}{24}+...\right)}=$$

$$=\frac{1}{2}\left(1+\frac{x^2}{4}+\frac{x^4}{8}+...\right)$$by taking the development of $$\frac{1}{1-x^2}$$

-
When I start with: $\frac{1}{2}\dfrac{1}{\left[ 1 - (x/2)^2\right](1-x^2/24 + \dots)} = \frac{1}{2}(1 + x^2/4 + x^4/8 + \dots) \cdot \dfrac{1}{(1 - x^2/24 + \dots)}$ That is - what happened to the $(1 - x^2/24 + \dots)$ of the denominator? –  mixedmath Aug 3 '12 at 16:56
There's still need to develop it, of course. I'd say that in a similar was as was done above, and multiply: above, it is "swallowed" in the ...part within the parentheses. It all depends, of course, what polynomial approximation is wanted. –  DonAntonio Aug 3 '12 at 22:05