Math/numerical formula every computer programmer should know

Posted by aaa on Stack Overflow See other posts from Stack Overflow or by aaa
Published on 2010-04-22T03:50:20Z Indexed on 2010/04/22 3:53 UTC
Read the original article Hit count: 305

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about subjective

Related posts about math