I came across the following information on statistics and probability:
I am trying to understand the rationale behind the second line - i.e. the "variance" formula. Is there some reference which shows why the variance of a random variable can be written in the following way?
For example, I have often seen the variance of a random variable (e.g. var(y)) written as "the expectation of the random variable squared minus the square of the expectation of the rando variable".
But I have never seen the variance of a random variable written in the above way.
Can someone please provide some intuition as to how and why the variance of "y" can be written in the following way?
Thank you!

This is called the law of total variance. See https://en.wikipedia.org/wiki/Law_of_total_variance