Is Hamlet really mad or is he pretending?
The answer to this is a very mixed answer. The matter of the fact is that Hamlet does have a plan to "act mad" or crazy in front of everyone in order to hide his true intentions to avenge his father's death.
However, it can also be said that Hamlet is a little crazed by the notion that his uncle killed his father and his mother married his uncle, and also the fact that, despite what he has learned at Wittenberg university, the "warlike form" of his father (as Horatio calls the Ghost, I.i) has recently appeared to him and told him of how he died.
The realization of a ghost during the Elizabethan period was not a common aspect to life. Shakespeare wanted to show the distinction and confusion one goes through when they say they are going to act mad, then realize that they are a little mad to begin with.
So, to answer your question, he is a little of both: He is acting in order to get closer to Claudius, but he is crazed because of the circumstances surrounding the state of Denmark and what he needs to do. We can confirm this in V.ii when Hamlet excitedly tells Horatio of how he turned the tables on them and sent them to their deaths: he doesn't perceive the enormity of his murderous deed saying it was guided by a "divinity that shapes" the end results of our plans.
Our indiscretion sometimes serves us well,
When our deep plots do pall: and that should teach us
There's a divinity that shapes our ends,
Rough-hew them how we will,--
All of the evidence would seem to suggest that Hamlet is indeed pretending to be mad. But, as Polonius shrewdly acknowledges, there is method to his "madness." Hamlet conveys the impression of insanity the better to hide his true intentions regarding Claudius. If people think he's mad then they'll be more likely to underestimate him. Hamlet's constant vacillation in killing Claudius merely adds to the sense that this is not a particularly formidable character.
At the same time, we must remember that Hamlet is a complex soul. Although he may not be mad, there seems little doubt that he's psychologically damaged to some extent. After all, his uncle murdered his beloved father and is now married to his mother. Hamlet's whole world has been turned upside-down by Claudius's wicked actions. There's often a fine line between the trauma that Hamlet has suffered and the madness which he so successfully feigns. Indeed, one could say that it's only because Hamlet has been so psychologically damaged by what Claudius has done that he's able to make his "antic disposition" look so incredibly convincing.
He's pretending. He is quite emotionally upset, and so that gives his act an edge that might make it feel real to those around him. After all, he has learned his father was killed and that his mother married the killer!
However, Hamlet stays too much in control to really be mad. (Look at Ophelia as a contrast.)
there is some debate whether or not he has "lost some of his marbles" DIRECTLY after talking with the ghost the first time.
perhaps the better question is: is madness a fleeting disorder, or can it be? or is madness a permanent "imbalance". i'm not sure if he is completely one or the other. heck i'm not sure the two are mutually exclusive.
every time i think of madness in hamlet i am reminded of kesey's cuckoo's nest.