# Determining if a sum of trig functions is periodic

Given the discrete-time function $f[n] = 2\cos(\frac{\pi}{4}n) + \sin(\frac{\pi}{8}n) - 2\cos(\frac{\pi}{2}n + \frac{\pi}{6})$

How can I show that the function is periodic? I know that a discrete time function is periodic if $x[n] = x[n+N]$ where N and n are considered to be positive integers.

But even if I were to just plug [n+N] in I can't see how to determine equality from there.

I considered letting each trig function be the Re/Im part of their respective complex exponentials so that I could combine them and (potentially)more easily group the functions so I could show the equality for a given N, but I'm not sure if that's a valid way of doing it.

I'd also considered that the sum of periodic functions can be periodic, but not always, and I'm not completely clear on what conditions guarantee that a sum of periodic functions is also periodic.

Looking around at other similar questions and other sites, I can see that if they do not have a common multiple, then the sum is not periodic, but these do, which to me says that this may be a periodic sum, but also may not:

Is it always the case that if individual periodic functions have a common multiple, the sum is also periodic?

I can easily just let N be 16, based on the above, and see that it is the period of $f$, but I'm looking for more general information.

As in this case you're dealing with discrete periodic functions, the sum of periodic functions is also periodic. To show that you only have to consider that the function $f[n]=\sum_{i=1}^Mf_i[n]$ will have period $N=\text{lcm}(N_1,N_2,...,N_M)$, where $N_i$ is the period of $f_i$ since $f_i[n+N]=f_i[n+kN_i]=f_i[N]$, for some natural $k$. In your exemple, we have $N_1=8, N_2=16$ and $N_3=4$. So we got $N=\text{lcm}(8,16,4)=16$. In the general case, this is not always true, since the periods may not even be intergers. For exemple, consider the functions $f(x)=\sin x$ and $g(x)=\sin \pi x$. It is easy to see, that $f$ and $g$ are periodic, with period $2\pi$ and $2$, respectively. But the sum $f(x)+g(x)$ is not periodic. Assume, that it has period $T$. then, we would have $f(x+T)+g(x+T)=f(x+2\pi k)+g(x+2j)$, for some $k,j\in \mathbb{Z}$. But this would lead to $$2\pi k =2j \Leftrightarrow \pi=\frac{j}{k},$$ which is a contradiction, since $\pi$ is irrational. By the above argument, we can see that in the general case, the sum will be periodic iff the ratio of the periods is a rational number.