Whitman organized the three stanzas of “O Captain! My Captain!” in a way that may be usefully compared to the structure of a sonata. A sonata is a classical musical form that moves through three sections that are usually referred to as exposition, development, and recapitulation. Essentially, this means that a sonata proceeds by stating a musical theme, developing that theme in new directions, then returning to the original theme. “O Captain! My Captain!” works in a similar way. The poem’s first stanza introduces the speaker’s lament for his dead captain, which happens against a celebratory backdrop as their ship sails into its home port. The second stanza takes the main elements of the first stanza in a new direction. Instead of directly mourning the captain’s death, the speaker emphasizes the celebratory atmosphere and calls on him to rise to the jubilant sound from the crowd. In the third stanza, however, the speaker returns to the original theme that dominated the first stanza, once again lamenting the untimely death of his captain—only this time in a sadder key.

Whitman’s use of this three-part “sonata” structure illustrates the speaker’s passage through the three key psychological stages of grief: shock, denial, and acceptance. In the first stanza, Whitman juxtaposes the crowd’s celebratory atmosphere with the speaker’s mournful attitude. The starkness of this contrast becomes especially pronounced when the speaker interrupts his description of jubilant crowds with his pained cry: “O heart! heart! heart!” (line 5). Evidently, his captain’s death has caused him quite a shock. Such a shock, in fact, that in the following stanza the speaker passes into a state of denial. He directly addresses his captain, acting as though he isn’t dead and begging him to get up (lines 9–12):

     O Captain! my Captain! rise up and hear the bells;
     Rise up—for you the flag is flung—for you the bugle trills,
     For you bouquets and ribbon’d wreaths—for you the shores a-crowding,
     For you they call, the swaying mass, their eager faces turning

Eventually, though, the speaker realizes that he has momentarily fallen into “some dream” (line 15), and that his captain is indeed deceased. Hence, in the poem’s final stanza, as he examines his captain for vital signs, the speaker moves out of denial (lines 17–18):

     My Captain does not answer, his lips are pale and still,
     My father does not feel my arm, he has no pulse nor will

No longer using the second-person pronoun “you,” the speaker now comprehends that his captain is irrevocably lost. As such, he at last enters the final phase of grief: acceptance.