Let $p>3$ be a prime. Gauss first introduced the polynomial $S_p(x)=prod_{c}(x-zeta_p^c),$ where $0<c<p$ and $c$ varies over all quadratic residues modulo $p$ and $zeta_p=e^{2pi i/p}$. Later Dirichlet investigated this polynomial and used this to solve the problems involving the Pell equations. Recently, Z.-W Sun studied some trigonometric identities involving this polynomial. In this paper, we generalized their results. As applications of our result, we extend S. Chowlas result on the congruence concerning the fundamental unit of $mathbb{Q}(sqrt{p})$ and give an equivalent form of the extended Ankeny-Artin-Chowla conjecture.