This is a follow-up question to What should every programmer know and Is mathematics necessary.
So the question is, as a computer programmer, what is the most important/useful mathematical or numerical formula that you use? By Formula I mean anything that involves less obvious manipulations, whenever binomial coefficients or bit hacks.
I work with multidimensional arrays and various matrix representations.
So for me most commonly used formulas are:
A(i,j,k,..) = a[i + j*Dim0 + k*Dim0*Dim1 + ... to map indexes to one dimension ( which is basic address calculation which many people do not seem to know).
And triangular number T(i) = (i*i + i)/2 which is related to binomial coefficients, used to calculate address in triangular matrixes and many other things.
What is your workhorse formula that you think programmer should know?