The formula for the covariance for historical data is:
cov1,2 = {Σ[(Rstock A − Mean RA)(Rstock B − Mean RB)]} / (n − 1)
Mean RA = (10 + 6 + 8) / 3 = 8, Mean RB = (15 + 9 + 12) / 3 = 12
Here, cov1,2 = [(10 − 8)(15 − 12) + (6 − 8)(9 − 12) + (8 − 8)(12 − 12)] / 2 = 6