Analyzing math equations This could be to a certain extent a philosophical question and I might know the answer already but I am interested in what others think.
My question is roughly the following. Let's say I am reading some new math material and let that be Statistics for my example but it could apply in any branch of math.
I come across population or sample mean and the definition is something like:
$$
\mu = \frac{1}{n}\sum_{i=1}^n x_i
$$
For some reason this is intuitive enough, the average is the sum of the values divided by their number.
Now you get to the equation for variance:
$$
S^2 = \frac{1}{n} \displaystyle\sum_{i} (x_i - \bar{x})^2
$$
Now according to my understanding, the variance is a measure of data spread from the mean.
So translates to subtraction in the equation. All good, then comes the squaring ^2.
Looking around online, many theories come about why there is a squaring operation in there. To get rid of negative values, to allow for analysis of a continuous function and so on and so forth.
I find my self in this situation very often, where I see an equation and I don't understand how it came about. It seems as if the inventor or author just had an intuition that he didn't document or maybe it's trivial and its up to the reader to deduce the knowledge.
What is it though? 
Why isn't such information captured?
Is it just about practicing?
Or we don't even care, we just study useful properties or if things make sense?
How do mathematicians or scientists arrive at such conclusions? hunch? trial and error?
 A: You are asking at least two related, but very different, questions: How do we arrive at these formulas? and, Why don't we tell people how we arrive at these formulas?  
When Ramanujan was asked how he came to his formulas, he said a god would give them to him. So I think that at least sometimes we really have no idea how we come to our formulas, and that would explain why we don't tell people how we arrive at these formulas; we don't, because we can't, since we don't know ourselves. 
If we are writing a formula we didn't find ourselves, but got from someone else, we may have the same reason for not telling people how the formulas were originally discovered; we simply don't know how the first person to discover them got there, and we're just copying them (after having verified them, of course) from the person who discovered them (or copying from someone who was copying from someone who was copying from someone and so on and so on). 
And even if we know how a formula was discovered, there are considerations of space. Textbooks are hundreds of pages long as it is – if they included the origins of all the results they use, you wouldn't be able to lift them. Papers in journals are expensive to print, and anything that makes them longer makes them more expensive, so some journals frown on too much expository work. And some authors figure their readers aren't interested in where the results come from, or maybe that their readers are bright enough to figure it out on their own. 
I'm probably leaving out a lot of stuff. 
