# How to derive $\cos\frac{n\pi}{3}=\frac{1+3(-1)^{[\frac{n+1}{3}]}}{4}$

Consider the following formula to calculate a trigonometric function:

$$\cos\frac{n\pi}{3}=\frac{1+3(-1)^{[\frac{n+1}{3}]}}{4}$$ $[x]$ denotes the integer part of $x$. The formula is valid for $n=0,2,4,6,...$

I'm curious how this formula is derived? Is there any analytical method or is it a pure guessing?

First, observe that

$$\cos\frac{(n+6)\pi}{3}=\cos\left(\frac{n\pi}{3}+2\pi\right)=\cos\frac{n\pi}{3}$$

and

$$(-1)^{\lfloor\frac{(n+6)+1}{3}\rfloor}=(-1)^{\lfloor\frac{n+1}{3}\rfloor+2}=(-1)^{\lfloor\frac{n+1}{3}\rfloor}$$

Hence we only need to consider $n=0$, $n=2$, and $n=4$. These cases are trivial to check to be true; I will do it for $n=2$:

$$\cos\frac{2\pi}{3}=-\frac{1}{2}=\frac{1+3(-1)^{\lfloor\frac{2+1}{3}\rfloor}}{4}$$

Edit:

I misunderstood the question. To derive this formula, we just have to find an expression $E(n)$ such that $E(0)=1$, $E(2)=E(4)=-\frac{1}{2}$, and $E(n+6)=E(n)$. The key here is $(-1)^{\lfloor\frac{n+1}{3}\rfloor}$, which is $6$-periodic and alternates between $1$, $-1$, and $-1$. Going further, the formula

$$\frac{1+3(-1)^{\lfloor\frac{2n+1}{3}\rfloor}}{4}+((-1)^{\lfloor\frac{3n+1}{3}\rfloor}-1)\frac{(-1)^{\lfloor\frac{2n+2}{3}\rfloor}}{2}$$

is valid for $n=0,1,2,3,\dots$

• Thanks, very inspiring answer! – Martin Gales May 11 '13 at 14:11

HINT:

The formula can be written as $$\cos\frac{2m\pi}3=\frac{1+3(-1)^{\left[\frac{2m+1}3\right]}}4$$ for all integer $m\ge0$

Now, the value of $(-1)^{\left[\frac{2m+1}3\right]}$ can be $+1,-1$ based on whether $\left[\frac{2m+1}3\right]$ is even or is odd

Observe that the fractional part of $\frac{2m+1}3$ can be $\frac a3$ where $0\le a\le2$

$(1)$ If $\left[\frac{2m+1}3\right]$ is even, the right hand side will be $\frac{1+3}4=1$

and $\frac{2m+1}3=2r+\frac a3$ where $r$ is a non-negative integer

So, $2m+1=6r+a\implies a=2(m-3r)+1$ i.e. odd $\implies a=1$

$\implies m=3r\implies$ the Left hand side $=\cos \frac{2(3r)\pi}3=\cos2r\pi=1$

$(2)$ If $\left[\frac{2m+1}3\right]$ is odd, the right hand side will be $\frac{1-3}4=-\frac12$

and $\frac{2m+1}3=2r+1+\frac a3$ where $r$ is a non-negative integer

So, $2m+1=6r+3+a\implies a=2(m-3r-1)$ i.e. even $\implies a=0,2$

$a=0\implies m=3r+1\implies$ the Left hand side becomes $=\cos\frac{2(3r+1)\pi}3=\cos\frac{2\pi}3=\cos\left(\pi-\frac\pi3\right)=-\cos\frac\pi3=-\frac12$ as $\cos(\pi-y)=-\cos y$

$a=2\implies m=3r+2\implies$ the Left hand side becomes $\cos\frac{2(3r+2)\pi}3=\cos\frac{4\pi}3=\cos\left(\pi+\frac\pi3\right)=-\cos\frac\pi3=-\frac12$ as $\cos(\pi+y)=-\cos y$

Alternatively, $m$ can be of the form $3n,3n+1,3n+2$ where $n$ is any integer

Putting $m=3n,\cos\frac{2m\pi}3=\cos\frac{2(3n)\pi}3=\cos2n\pi=1$

and $\left[\frac{2m+1}3\right]=\left[\frac{2(3n)+1}3\right]=\left[2n+\frac13\right]=2n$ $\implies 1+3(-1)^{\left[\frac{2m+1}3\right]}=1+3(-1)^{2n}=1+3=4$ $\implies \frac{1+3(-1)^{\left[\frac{2m+1}3\right]}}4=1$

Can you take it from here?

• I learned quite a few new things from your answer. Thanks! – Martin Gales May 11 '13 at 14:13