  Let $(a_k)_{k\in\mathbb N}$ be a sequence of integers satisfying the Hadamard
gap condition $a_{k+1}/a_k>q>1$ for all $k\in\mathbb N$, and let $$ S_n(\omega)
= \sum_{k=1}^n\cos(2\pi a_k \omega),\qquad n\in\mathbb N,\;\omega\in [0,1]. $$
The lacunary trigonometric sum $S_n$ is known to exhibit several properties
typical for sums of independent random variables. In this paper we initiate the
investigation of large deviation principles (LDPs) for $S_n$. Under the large
gap condition $a_{k+1}/a_k\to\infty$, we prove that $(S_n/n)_{n\in\mathbb N}$
satisfies an LDP with speed $n$ and the same rate function $\tilde{I}$ as for
sums of independent random variables with the arcsine distribution, but show
that the LDP may fail to hold when we only assume the Hadamard gap condition.
However, we prove that in the special case $a_k=q^k$ for some $q\in
\{2,3,\ldots\}$, $(S_n/n)_{n\in\mathbb N}$ satisfies an LDP with speed $n$ and
a rate function $I_q$ different from $\tilde{I}$. We also show that $I_q$
converges pointwise to $\tilde I$ as $q\to\infty$ and construct a random
perturbation $(a_k)_{k\in\mathbb N}$ of the sequence $(2^k)_{k\in\mathbb N}$
for which $a_{k+1}/a_k\to 2$ as $k\to\infty$, but for which
$(S_n/n)_{n\in\mathbb N}$ satisfies an LDP with the rate function $\tilde{I}$
as in the independent case and not, as one might na{\"i}vely expect, with rate
function $I_2$. We relate this fact to the number of solutions of certain
Diophantine equations. Our results show that LDPs for lacunary trigonometric
sums are sensitive to the arithmetic properties of $(a_k)_{k\in\mathbb N}$.
This is particularly noteworthy since no such arithmetic effects are visible in
the central limit theorem by Salem and Zygmund or in the law of the iterated
logarithm by Erd\"os and G\'al. Our proofs use a combination of tools from
probability theory, harmonic analysis, and dynamical systems.
