What's the difference between なぜ、どうして and なんで when meaning 'why'?


I've been meaning to ask this for a while.

What is the difference between these 3 words. I was taught they all mean
"why", but obviously, being different words they convey different nuance and
would be used in different situations.

What would be the difference between these 3 sentences and in what situations
would they be used?

**なぜ** ここにいるのですか？  
**どうして** ここにいるのですか？  
**なんで** ここにいるのですか？




From dictionary@goo:

  * [なぜ](http://dictionary.goo.ne.jp/leaf/jn2/164059/m0u/%E3%81%AA%E3%81%9C/) is for asking 理由 (reason/motive) and 原因 (cause).

  * [どうして](http://dictionary.goo.ne.jp/srch/jn/%E3%81%A9%E3%81%86%E3%81%97%E3%81%A6/m0u/) covers なぜ usage, plus 方法 (method/process). Also, there is additional usage as a strong way to refuse.

  * [なんで](http://dictionary.goo.ne.jp/srch/jn/%E3%81%AA%E3%82%93%E3%81%A7/m0u/) covers なぜ and どうして usage, including the usage as a strong way to refuse.

So I guess どうして and なんで are interchangeable while なぜ has a smaller scope than
the two. As for the nuance differences between どうして and なんで, my theory is by
looking at the literal meaning of the word, どうして focuses on "how it is done"
while なんで focuses on "by what means".

