Take another look at the sentence:
No punctuation is necessary between library and but. Madison tried to study in the library but discovered ... is a main clause. This main clause has Madison as its subject and tried and discovered as its verbs. Because there are only two verbs—two items in a series—a coordinating conjunction like but is enough to connect them.