Madoka Magica introduces us to possibly the most faithful representation of our time travel tragedy paradigm, with an emphasis on the Butterfly Effect and the predestination of the tragic event. The initial tragic event is Madoka's death; this occurs whether or not she becomes a magical girl and fights the queen-witch entity Walpurgisnacht. Homura is the tragic hero whose tragic flaw is her love and devotion to Madoka and Madoka's innocence (that Madoka not sacrifice her life to become a magical girl). Kyuubee and Walpurgisnacht act as gods who dictate the laws of the universe: make a wish, become a magical girl and fight evil, and then Walpurgisnacht is designed to destroy the world, her power becoming proportionally stronger with our heroes: power enough to invariably destroy the world. Homura repeatedly time travels back to become stronger and defeat Walpurgisnacht and to prevent Madoka from becoming a magical girl; every time this ends in tragedy—whether or not Madoka becomes a magical girl—and Madoka dies.
Madoka is the center of her universe. She is the reason for Homura's time travel, and so she is at the core of all the changes by which Homura causes to the world to deviate from its 'natural' order. Homura is willing to put the entire world at risk and fight Walpurgisnacht by herself in order to save Madoka. Walpurgisnacht is the offended god who responds to Homura's hubris and amplifies the effects of the tragic event. But everything falls completely out-of-wack at a disproportionate scale to Homura's relatively minor changes to Madoka's and her own life. Change a few decisions and friendships in someone's life: Madoka suddenly has God-like magical girl potential, and the world explodes twice as badly this time. It's not a logical one-to-one ratio, which is the real definition of the Butterfly Effect.
Also at the center of the universe, we see our parallel tragic events. Initially, there are two options: Madoka becomes a magical girl or she does not, both resulting in her death (and the world being destroyed). Then there's the alternative offered at the end: Madoka becomes a magical girl and sacrifices herself with the wish to become, effectively, a God and rewrite history to prevent all magical girls ever from becoming corrupted into witches. Madoka will become a non-personal, deific presence, and Homura loses her. It's a tragic ending again. Though it's the obvious "greater good" option, and she would save the world, Homura's efforts to prevent Madoka from becoming a magical girl and/or losing her to death are all in vain. Note that, non-traditionally, it is by Madoka's choice and actions that the tragedy is resolved and not because of our tragic hero, Homura (tragically powerless?).
So Madoka fulfills the tragic paradigm. There are two options, but both result in the ultimate loss of Madoka to the tragic hero Homura. However, despite our newly created timeline in which Madoka never existed, Madoka is still remembered by her baby brother and by Homura. We see a tonally "happy" ending, minimal notes of bittersweet, something depicted in the show as the 'right' ending and the ultimate resolution of the core conflicts. If the creators tell us it's a happy ending and break the laws of time in remembrance of Madoka, then it must be a happy ending, right? I'll give this three and a half "happily ever after"s out of 5.