It was time to put an end to the miscalculations of the captors in the embassy in Tehran and their leader in the holy of Qom.

So there was no slouching by the president as he stepped from his helicopter, tilted his chin uncharacteristically high and strode across the South Lawn of the White House in a most unnatural gait for this naturally slope-shouldered man. He looked exceedingly grim, never glancing at the reporters and cameras that his aids had led outside to observe him as he walked toward the Cabinet Room Tuesday afternoon to approve a statement threatening the use of military force -- as a last resort -- in Iran.

Part of the legacy of the Carter presidency has been polls at home that are low and an image abroad that is weak. Together they have conveyed a sense of vacillation and drift that, whether justified or not, is the way much of the world has come to see President Carter.

His top advisers do not like to talk of this, but they concede it is true; and twice in this crisis they have concluded that these factors had led the Ayatollah Rhollah Komeini and his followers to make major miscalculations about the resolve of the American people and the American president.

The first instance concerned the question of American unity. The second concerned Carter's willingness to use weapons of war.

In the Cabinet Room at 4 p.m. Tuesday, they were dealing with what they viewed as the second of the ayatollah's miscalculations. The president's top advisers, the secretaries of state and defense and his experts on national security, were waiting. They had drafted a statement, based on Carter's decision in a telephone call from Camp David, that now was the time to raise the threat of U.S. military force.

Carter took his seat at the table -- his is the chair with the back slightly higher than the rest -- and he silently read the statement.

He fixed on one sentence -- the action sentence, the one that, through a veil of dipolmatic nuance, made the threat. It came just after the assertion that the United States was seeking a peaceful solution through every available channel. "This is far preferable to the other remedies available to the United States under the charter of the United Nations," it said.

According to a source at the meeting, Carter told his advisers that he thought some people might think this meant that the United States could act militarily only with U.N. approval. The president said he wanted no doubt of his view that the United States is entitled to act unilaterally, without U.N. approval. He argued that the sentence should be separted into two, so that there could be no doubt of his intent.

Others present took issue with the president, saying the intent was clear and that the statement read better in its original wording. When the discussion was over, not surprisingly, the president prevailed.

The statement issued to reporters less than an hour later said: "This is far preferable to the other remedies available to the United States. Such remedies are explicity recognized in the charter of the United Nations."

And privately, reporters' attention was directed to Article 51 of the U.N. charter, which provides for a nation's actions in self-defense.

The president, who has been campaigning for reelection with a boast of having kept the nation at peace (he has already made a campaign movie stressing this), had just issued a threat of war.

"It was the most serious, sober -- the most grim meeting we have ever had," said one Carter adviser who attended. But we felt it had to be done."

Realization that now was the time to speak of military force had come swiftly -- right after a news agency ticker brought at 11:55 a.m., the first word of the ayatollah's speech declaring that the remaining hostages in the U.S. Embassy "were spies" and may stand trial.

The ayatollah ridiculed the possibility that the United States would resort to force in Iran.

So Carter spoke, for the first time in his presidency, of a real threat of U.S. military action. Just a week earlier, he had been moved to speak forcefully on a related matter -- also because his advisers had concluded that the Iranian leaders were, as one Carter official said, "profoundly misunderstanding the mood of American public opinion."

Administration officials had concluded that Iran's leaders had come to feel that American public opining would desert Carter and demand that the exiled Shah Mohammad Reza Pahlavi be returned to Iran. So Carter spoke out firmly last week in an address delivered to the AFL-CIO but meant mainly for those in charge in Iran.

"No act has so galvanized the American public toward unity in the last decade as has the holding of our people as hostages in Tehran," he said. "We stand today as one people.

So on two occasions Carter has spoken out to impress the Iranians of America's resolve. And if his words did not convince the ayatollah and his follwers, perhaps the words of others will. On Capitol Hill yesterday, senators of all military persuasions were speaking out firmly in support of Carter's stance. There were, of course, the hawks. But there was also Sen. George McGovern.

"I'm known as a dove, but I don't believe in letting terroists or bully boys trample on Americans anywhere," the South Dakota Democrat said. ". . . I have always been a full-scale hawk where legitmate American interests are threatened."