From breakfast through dinner of the day after his first resounding defeats Jimmy Carter was optimistic, even joking. When he came into a Democratic congressional dinner last night, he dove right in:

"I am sure a lot of you are wondering what happened in New York and Connecticut yesterday. You're not the only ones," the president began. Moments before there had been only tepid applause from the 1,000 Democrats, but the president's self-effacing humor triggered vigorous laughter and applause.

"I've spent all day doing a very close analysis, using the most modern 1980 election techniques and finally have come to the conclusion we won a tremendous victory yesterday," Carter said as the audience continued to laugh. "Fritz Mondale and I are very proud when you are able to improve. In 1976, I ran in the New York primary and came in fourth. Yesterday I came in second."

It was Carter's first public surfacing since he'd been beaten by Ted Kennedy less than 24 hours earlier, an upset that had Kennedy making countless phone calls to Wisconsin from his home in McLean yesterday.

And taking in money, too.

"They were wheeling wheelbarrels into the door every hour," was how Jim Flug, a top Kennedy organizer, put it.

Kennedy never actually made it to the reception and dinner, although there was grand hope that he would and maybe cause some fireworks. But, alas, he stayed in McLean near his tennis court and telephone.

"Lots of calls," said Carl Wagner, Kennedy's director of operations, Carter, he added, is in "serous trouble, I think his problems are as serious as the inflation rate."

As for the president, those who'd spent the day with him instead insisted it was business as usual.

"He's in good shape," said persidential assistant Anne Wexler at a reception befrehand. "He was doing what he always does."

The president's day began with a regularly scheduled breakfast meeting with Hill leadership. "Sprightly," judged Rep. John Brademas (D-Ind.), who was there.

Nobody at the time brought up New York or Connecticut beacuse, as House Speaker Thomas P. "Tip" O'Neill explained, "We never mention the elections in the morning." They didn't have to; pretty soon Carter was making breakfast-table jokes about them.

Then it was on to another day at the White House. This included meetings between Carter and Agriculture Secretary Bob Bergland. "He was very upbeat, although he did ask me if I tought the surrogates' campaigning was effective and I said no, not as if he were out there. But I didn't urge him."

And from Robert Strauss, Carter's campaign director: "He couldn't have been in a better mood. He ribbed me and said, 'I would have won if it hadn't been for you, Strauss.'" A little later, Stauss said flatly: "We blew it."

That assessment was repeated throughout the cocktail hour and in and out of hotel suites where congressmen and rich Democrats party- hopped. Handicapping the 1980 political horse race was wonderful fun, particularly for the experienced spectator.

"I think it may be good for the Carter people," said Sen. George McGovern (D-S.D.) the 1972 presidential candidate who's on record for Kennedy. "It will shake everybody up."

Presidential adviser Sarah Weddington seemed to agree with that judgment. "Today was very much a sense that we've got to go back and start over," she said.

But Sen. Russell Long (D-La.) took the Kennedy upset more philosophi- cally. "That's how it goes," he said . "Some games you win, some games you lose."

Rep. Morris Udall (D-Ariz.), an early-on Kennedy backer, came late. Reporters gathered around, eager for him to pontificate about New York and Connecticut. "I think we're going to have a little more of a horse race than we thought," was what Udall offered.

In his introductory remarks, Tip O'Neill said the president had committed himself to the speech three weeks ago. But dinner organizers told a different story, one that had Carter accepting the invitation Tuesday afternoon after the first TV projections that Kennedy was winning in New York.

After the president's speech, which emphasized the time-honored Democratic Party ideals of "competence in government and compassion in government," everyone bolted for the doors. Though the unofficial consensus was that the speech was boring, the official reaction was predictable. Sen. Robert Byrd (D-W.Va.) commented. "He was very gracious and appropriate." Jim Wright (D-Tex.), House Majority Leader, said, "Very forceful, very strong."

From the opposition camp came Carl Wagner, a Kennedy adviser who wore an "I Love New York" button He said, "He was very unconvincing."

Leaving the ballroom, where Rep Lindy Boggs (D-La.), former senator Muriel Humphrey and cabinet members Newil Goldschmidt and Moon Landrieu were dancing to such Democratic evergreens as "Happy Days Are Here Again" and "Dixie", was Joe Thompson, a Democrat who owns miles and miles of real estate in Kentucky. The president, said Thompson, "said what he had to say. Now, whether he won an Emmy, that's a different story."

The reason for the $1,000-a-plate dinner was to raise $1 million for Democratic congressional campaigns this year. It also provided good political star-gazing territory for a group of psychologists collected at the Hilton for a convention.

"Psychologists will look at anybody," said Tony Spirito, a psychologist from Richmond who, in this case, was not looking for just anybody, but Ted Kennedy. "We just thought we'd hang around and see if we could see him," he said, explaining why he and a small group of casually dressed people were watching the doors expectantly.

But all they got was Treasury Secretary G. William Miller, who arrived late. Nobody asked him for an autograph.