only the devil and you know why you want to do this FROM SCRATCH... but ok, here are my $0.02.

so, the formula we're working with is that R-squared in matrix form can be expressed as:

where is the vector of correlations between the dependent variable Y and the predictors X1 and X2 and is the correlation matrix for predictors X1 and X2.

so the first step is finding the inverse of:

for which we will use the super-duper handy Wolfram Calculator which says that is:

so all that's left to do is just work the convenient matrix multiplication of:

and after a lot of arduous and tedious matrix multiplications that i will let you thoroughly enjoy, you end up with the desired result.

just for kicks and giggles, i plugged all of this into my Maple and i get the exact same formula that you posted (but with switched signs for some reason, so i guess i can multiply it times -1 to get exactly what you got). but i can see that Maple inverted with the opposite signs that Wolfram did, so that's probably where it came from.

enjoy!