where f(q_i, D) is q_i's term frequency in the document , |D| is the length of the document in words, and is the average document length in the text collection from which documents are drawn.
There are several interpretations for IDF and slight variations on its formula.