# Derivation of Equation of Reducible and Irreducible Error [duplicate]

I am currently reading An Introduction to Statistical Learning by James, Witten, Hastie, and Tibshirani, and I am stuck on one of the leaps they take when defining reducible and irreducible error. They state that for a given set of input and output variable $X$ and $Y$, respectively, there is a function $f$ which we estimate, defined as $\hat f$. Using $\hat f$ we then obtain the our predictions of $Y$ which is called $\hat{Y}$ such that $\hat Y = \hat f(X)$. On page 19, equation 2.3, they give the following equation:

$$E(Y - \hat Y)^2 = E[f(X) + \epsilon - \hat f(X)]^2$$ $$= [f(X) - \hat f(X)]^2 + Var(\epsilon)$$

They then go on to say that $[f(X) - \hat f(X)]^2$ is the reducible error while $Var(\epsilon)$ is the irreducible error.

I am by no means a mathematician and have tried some derivations but cannot reach that conclusion on my own, particularly in deriving $Var(\epsilon)$. Thank you.

Because $E\left[\textrm{constant}\right]=\textrm{constant}$, (and $f$ and $\hat f$ are constants), $E\left[\epsilon\right]=0$, and $\textrm{Var}(\epsilon) = E\left[\left(\epsilon - E\left[\epsilon\right]\right)^2\right]$. You get the expected results. \begin{align} E(Y - \hat Y)^2 &= E\left[f(X) + \epsilon - \hat f(X)\right]^2\\ &= E\left[\left(f(X) - \hat f(X)\right)+\epsilon\right]^2\\ &=E\left[\left(f(X) - \hat f(X)\right)^2+2\epsilon\left(f(X) - \hat f(X)\right)+\epsilon^2\right]\\ &=E\left[\left(f(X) - \hat f(X)\right)^2\right]+E\left[2\epsilon\left(f(X) - \hat f(X)\right)\right]+E\left[\epsilon^2\right]\\ &=\left(f(X) - \hat f(X)\right)^2+0+E\left[\epsilon^2\right] \end{align}