The interrelated themes of madness and revenge carry throughout the entire play, and they are primarily shown through Hamlet’s character. William Shakespeare encourages the audience to question whether there is a clear line between sanity and madness. Even more, he suggests that the desire for revenge may compel even sane people to act irrationally.
In act 1, scene 5, Hamlet swears to avenge his father’s death, telling the ghost that on swift wings, “I … /May sweep to my revenge.” He also tells Horatio and Marcellus that he will pretend to be mad, or “put an antic disposition on” (act 1, scene 2), as a method for investigating the involvement of both Claudius and Gertrude in King Hamlet’s death.
Hamlet's act is so convincing that most characters believe him mad. Even when he tells his mother that he is not actually insane but only “mad in craft,” she does not believe him (Act 3, Scene 4). After he kills Polonius, Gertrude tells Claudius that her son did it because he is insane, comparing his mental state to a storm at sea (Act 4, Scene 1).
Mad as the sea and wind when both contend
Which is the mightier.
It was not madness that made Hamlet stab into the arras, however. He believed that Claudius was the “rat” hiding there, and his underlying desire for revenge made him act rashly (act 3, scene 4). After he stabs the unseen person and hears them cry out, he asks his mother: “Is it the King?” Instead, he has killed Polonius, who is innocent of any involvement in Hamlet's father’s murder.