This calculation is a three step process. First, the individual stats are each multiplied by their modifiers and taken to the 1.5 power, these terms are summed up and taken to the (2/3) power. The result, the Item Value, is a direct measure for the item's quality. It can be used to compare items across slots and without regard for quality.
ItemValue = [(StatValue[1]*StatMod[1])1.5 + (StatValue[2]*StatMod[2])1.5 + ...]1/1.5
Second, this sum is modified by the slot (or item type):
ItemSlotValue = ItemValue * SlotMod
The third and final modification takes into account item quality. The end result is a calculated value for item level.
Green: ilvl = ItemSlotValue * 2.0 + 4.00
Blue: ilvl = ItemSlotValue * 1.6 + 1.84
Epic: ilvl = ItemSlotValue * 1.3 + 1.30
This calculated item level usually matches Blizzards item level quite well.
The heart of the formula is to take each modified stat value to the 1.5th power, sum up these terms and draw the 1.5th root from the sum. This process makes single, high values of one stat more expensive than multiple, lower stats. Still it is a fairly simple mathematical model, but not so simple that it is just all the stats added together. It has been suggested that the actual power used may be higher than 1.5 (up to 1.7, see the discussions page).