Covariance definition in terms of expected value Covariance is defined as:
$$COV(x,y)=\mathbb{E}[(X-\mathbb{E}[X])(Y-\mathbb{E}[Y])]$$
Is the following equation derived from the one above? If yes, how? By treating the expected value as an arithmetic mean? Expected value is indeed equal to arithmetic mean when the probabilities are equal.
$$COV(x,y)=\frac{\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{n-1}$$
The question is - why do we divide by $n-1$ instead of $n$? If it's an arithmetic mean, we are adding up $n$ terms and dividing by the number of terms $n$.

You question is answered in this Wikipedia section.
The first quantity is the [true] covariance and the second quantity is sample covariance, which is an estimate of the true covariance. You are correct in your intuitive interpretation of the sample covariance being an average. The $n-1$ makes the sample covariance unbiased, which means that if you think of the $x_i$ and $y_i$ as i.i.d. random variables drawn from the distributions of $X$ and $Y$ respectively, then the expectation of the sample covariance is the true covariance. This is an unfortunate quirk that arises due to the fact that the sample mean $\bar{x}$ is not the true mean $\mathbb{E}[X]$.
