Throughout Harry Potter the general rule seems to be that spells have to be spoken the right way in order to be cast. However on numerous occasions wizards are seen casting magic without a word being said (in the final movie voldermort and harry throw spells around with grunting and moans) then at other moments magic words are said to shoot a spell.
What are the rules of spell casting can a spell simply be said in the head, does it not need to be spoken at all or is the film mis representing the rules of magic?