Though their beliefs and styles are at odds, the president and the mayor of New York City showed that polarization need not prevent substantive discussion.