# Taylor series expansion for $\cos(2x)$ about $\frac{\pi}{8}$

So, knowing that $$f(x) = \sum_{n=0}^\infty \frac{f^n(a)(x-a)^n}{n!}$$

For my case I write $$\cos(2x) = \sum_{n=0}^\infty \frac{\frac{d^n(cos(\frac{\pi}{4}))}{d(\frac{\pi}{8})^n}(x-\frac{\pi}{8})^n}{n!}$$

I would now like to derive the sum formula for my specific case, for which I suppose I would have to derive the $$n^{th}$$ derivative.

I couldn't quite see a single clear pattern when deriving each derivative or each term of the sequence (although there seems to be one in derivatives, same doesn't hold for terms): $$f(\frac{\pi}{8}) = \frac{1}{\sqrt2}$$ $$f'(\frac{\pi}{8}) = -\sqrt2$$ $$f''(\frac{\pi}{8}) = -2\sqrt2$$ $$f'''(\frac{\pi}{8}) = 4\sqrt2$$

$$\cos(2x) = \frac{1}{\sqrt2} - \sqrt2(x-\frac{\pi}{8}) - \sqrt2(x-\frac{\pi}{8})^2 + \frac{2}{3}\sqrt2(x-\frac{\pi}{8})^3 + \frac{1}{3}\sqrt2(x-\frac{\pi}{8})^4 - \frac{2}{15}\sqrt2(x-\frac{\pi}{8})^5 ...$$

I also found that for $$f(x) = \cos(ax)$$

$$f^{(n)} (x)=(-a^2)^{(n-1)/2}(-a)\sin ax,$$ for $$n$$ odd

and $$f^{(n)} (x)=(-a^2)^{n/2}\cos ax,$$ for $$n$$ even from this answer:

But while it reduces to a simpler form for my case where $$a = \frac{\pi}{8}$$, I still can't get my head around uniting all this into a single formula forth both odd and even values of $$n$$.

Any help appreciated!

• I'm a little bit confused, why you don't just use $\sin(\pi/4) = 1/\sqrt{2} = \cos(\pi/4)$? You have $a=2$ and $x=\pi/8$. Commented Nov 16, 2018 at 11:19
• My previous comment missed a 2. I think I can see it now. I get $(-4)^{n/2}\frac{1}{\sqrt2}$ for both odd and even, or $(-1)^{n/2}2^n\frac{1}{\sqrt2}$. Do I add them next? Is this consistent with the result below by @josé-carlos-santos? Commented Nov 16, 2018 at 13:43
• I think it is easier to consider $f^{(2n)}$ and $f^{(2n+1)}$ in order to reproduce the answer below. Commented Nov 16, 2018 at 14:02
• I got it! And can even see where the minus between the sums below comes from. Thank you so much! Commented Nov 16, 2018 at 14:28

Notice that\begin{align}\cos(2x)&=\cos\left(2\left(x-\frac\pi8\right)+\frac\pi4\right)\\&=\cos\left(2\left(x-\frac\pi8\right)\right)\cos\left(\frac\pi4\right)-\sin\left(2\left(x-\frac\pi8\right)\right)\sin\left(\frac\pi4\right)\\&=\frac1{\sqrt2}\sum_{n=0}^\infty(-1)^n\frac{2^{2n}\left(x-\frac\pi8\right)^{2n}}{(2n)!}-\frac1{\sqrt2}\sum_{n=0}^\infty(-1)^n\frac{2^{2n+1}\left(x-\frac\pi8\right)^{2n+1}}{(2n+1)!}.\end{align}
• In the second line, it should be $\cos(\pi/4)$ instead of $\cos(\pi/8)$. Commented Nov 16, 2018 at 11:30
• That's brilliant, I never thought of the identities. I get easily confused by series, so I'm not sure what I can do next though. For the first series in the solution the next term is $(-1)^{n+1}\frac{2^{2(n+1)}\left(x-\frac\pi8\right)^{2(n+1)}}{(2(n+1))!}$, so I can't manipulate it if it would be contained in the second one, can I? Commented Nov 16, 2018 at 13:24
• Correct. Considering $cos(2x) = \frac{1}{\sqrt{2}} \sum_{k=1}^\infty a_k (x-\pi/8)^k$, the answer implies $a_k = (-1)^{k/2} \frac{2^k}{k!}$ if $k$ is even and $a_k = (-1)^{(k-1)/2} \frac{2^k}{k!}$ if $k$ is odd. Hence, the notation in the answer is rather nice. Commented Nov 16, 2018 at 13:58