Prove that cosine serie evaluates to zero by induction and double differentiation I had a linear algebra exam with this question which I had trouble solving. Here it is:

Let $n \in \mathbb{N}$ and $\lambda_1, \lambda_2, \ldots, \lambda_n \in \mathbb{R}_{+}^{*}$ such that $\lambda_1 \neq \lambda_2 \neq \ldots \neq \lambda_n$. Show by induction over $n$ that if
$$\sum_{i = 1}^{n} \mu_i \cos(\lambda_i x) = 0$$
then for all $x \in \mathbb{R}$ we have $\mu_1 = \mu_2 = \ldots = \mu_n = 0$.
Hint: you may need to differentiate the expression twice. Taking the second derivative does not change the linear dependence of the vectors involved.

First of all, I have no clue why it is hinted to differentiate the expression twice. I dit it, and I got
$$\sum_{i = 1}^{n} -\mu_i (\lambda_i)^2 \cos(\lambda_i x) = 0$$
which did not really help me understand why I would need to do this anyway. Then, I just constructed a silly sequence with
$$\lambda_1 = \frac{1}{2} \pi, \lambda_2 = \frac{1 + 2^{2 - 1}}{2} \pi, \lambda_3 = \frac{1 + 2^{3 - 1}}{2} \pi, \ldots, \lambda_n = \frac{1 + 2^{n - 1}}{2} \pi$$
so that if we choose $x = 1$, we obtain $\cos(\lambda_1) = \cos(\lambda_2) = \ldots = \cos(\lambda_n) = 0$. Then we could have positive values for $\mu_i$ and it does not matter since the cosine will always evaluate to zero in this case.
Note: I know my reasoning is faulty. I just want to know what is faulty.

The question does not explicitly mention the domain for $\cos(\lambda_i x)$ must be non-degenerate, like $\mathbb{R}$. In my reasoning, the interval is degenerate since I have chosen a singleton with $x \in \{1\}$.
 A: For fixed non-zero $\lambda_1,\dotsc,\lambda_n$ let $f_i(x) = \cos(\lambda_i x)$. The statement you should prove is: 

If $\lambda_1, \dotsc, \lambda_n$ are distinct, then $f_1\dotsc,f_n$ are linearly independent.

(This is only true, if $f_i$ does not vanish completely, that is, its domain must be sufficiently large, like an interval with positive length.)
Proof by induction over $n$: 
For $n=1$ it is trivial, as $f_1\ne 0$. (Here you need a sufficiently large domain.) 
Assume the statement is valid for $n-1$. Let $\mu_1,\dotsc,\mu_n$ be given with
$$ \sum_{i=1}^n\mu_i f_i = 0. $$
We want to prove $\mu_1=\dotsb=\mu_n=0$.
By differentiating the equation twice, we obtain
$$ \Bigl(\sum_{i=1}^n\mu_i f_i \Bigr)'' = \sum_{i=1}^n\mu_i f_i'' = \sum_{i=1}^n\mu_i (-\lambda_i^2 f_i) = 0. $$
Thus, we have
$$ 0 = \lambda_n^2 \Bigl(\sum_{i=1}^n\mu_i  f_i\Bigr) - \sum_{i=1}^n\mu_i \lambda_i^2 f_i = \sum_{i=1}^{n-1} \mu_i(\lambda_n^2 - \lambda_i^2) f_i. $$
Now, as $f_1,\dotsc,f_{n-1}$ are linearly independent by induction hypothesis, we have $\mu_i(\lambda_n^2 - \lambda_i^2) = 0$ for $1\le i\le n-1$. As the $\lambda_i$'s are distinct, it follows $(\lambda_n^2 - \lambda_i^2) \ne 0$ and $\mu_i = 0$ for $1\le i \le n-1$. It remains
$$ \mu_n f_n = 0. $$
Again, as $f_n\ne 0$ (sufficiently large domain), it follows $\mu_n = 0$.
