Suicide was the impulse driving John W. Hinckley Jr. when he shot President Reagan, a defense psychiatrist told a federal jury yesterday.

Dr. William T. Carpenter, basing his analysis on 45 hours of interviews with Hinckley after the attack, said Hinckley hoped through death to accomplish a union with actress Jodie Foster, and he saw the president and his other victims as "bit players" in his effort to reach that goal.

Capenter catalogued for the jury a series of violent themes and fantasies that he said began to dominate Hinckley's state of mind as his mental illness progressed.

He said in the months before the shooting, as Hinckley's obsession with Foster turned to resentment and a "murderous rage," he developed an "ill-formed plan" to carry out a massacre at Yale University by walking into a classroom where Foster was studing, shooting the professor and other students, perhaps wounding Foster and then killing himself.

In February 1981, struggling with "intense impulses" about Foster and about ending his own life, Hinckley came to Washington and went to the Capital building with "some notions" of trying to assassinate Sen. Edward M. Kennedy, Carpenter said, adding that those notions "passed quickly."

Hinckley began to picture himself storming the House gallery and shooting congressmen, like an assault carried out by Puerto Rican nationalists in 1954, and he pondered how many shots he could get off before he was stopped, Carpenter told the jury.

Hinckley copied an airplance hijacking note from a book he read twice about a criminal who feigns mental illness when he is caught.

He fancied that through a hijacking President Reagan could be forced to resign and that Foster would be brought to the White House for Hinckley, Carpenter testified.

During those months Hinckley was taking on "personality traits" from other identities, Carpenter said, including Lee Harvey Oswald and Charles Whitman, the sniper who killed 13 persons and wounded 31 others by shooting from an observation tower at the University of Texas in 1966.

Hinckley bought a rifle like the one used to kill Presient Kennedy and a handgun of the same model as the one used to murder John Lennon, Carpenter said. He bought more guns to "complete his arsenal" as the character Travis Bickle did in the movie "Taxi Driver," which Hinckley had seen at least 15 times.

During cross-examination yesterday by assistant U.S. attorney Roger M. Adelman, Carpenter acknowledged that Hinckley himself was the major source of information that led to his conclusions about Hinckley's mental illness. When Adelman asked if Hinckley would have a "motive to lie to him" because of the criminal charges that he faces, Carpenter said that any "misinformation" Hinckley gave him would be considered in his psychiatric evaluation.

"His neck's on the line. Haven't you thought about that?" Adelman asked Carpenter.

"Oh yes, I've thought about it," Carpenter said. But he told the chief prosecutor that when Hinckley tried to mislead him, those efforts were directed toward trying to persuade him that his mental illness was "less severe" than Carpenter believed it was.

The prosecution, which must prove to the jury that Hinckley was sane beyond a reasonable doubt, will call its own psychiatric witnesses later in the trail to support its argument that Hinckley carried out a planned and deliberate act when he shot Reagan.

Hinckley's lawyers contend that he was insane at the time of the shooting and during his testimony yesterday Carpenter said that in his opinion Hinckley met the legal standard for the jury to reach that conclusion.

Carpenter, the director of the Maryland Psychiatric Research Center, testified that Hinckley suffered from a mental illness and was so driven by his "inner state" that he could not obey the law.

Carpenter told the jury that while Hinckley had an "intellectual" understanding that his actions were illegal, his emotional understanding was so distorted that he could not appreciate the wrongfulness of his acts.

"His reasoning processes were dominated by the inner state and inner drives" that caused him to want to "terminate his own life" and form a union with Foster, Carpenter said.

Carpenter diagnosed Hinckley's mental illness as "process schizophrenia," which he described as a break with reality that begins to develop slowly in young adulthood and eventually progresses to a severe mental disorder "with potentially lifelong implications."

The disease was demonstrated in Hickley's depression and suicidal thoughts, his retreat from the real world into an "inner mind" and his inability to have ordinary emotional reactions, Carpenter said.

Carpenter told Adelman that he was paid $150 and later $100 an hour for his examination of Hinckley. He acknowledged that it was the first time that he had examined a person charged with a crime for the purposes of testifying in court about a defendant's criminal responsibility.

When questioned by Adelman, Carpenter denied that he had taken on the case at the request of defense lawyers with the intention of finding a mental illness in Hinckley so that he could support his insanity defense

During cross-examination, Carpenter also acknowledge that during an interview with Hinckley he had reviewed with him a standard manual for mental disorders that psychiatrists use to help formulate their diagnosis.

"Did you present Mr. Hinckley the opportunity to diagnose himself?" Adelman asked, noting that the book contains "recipe" lists of various symptons of mental illness. Carpenter replied that he had already made judgement about Hinckley's condition when he showed him the book and wanted to see if Hinckley would take the opportunity to add any symptoms.

Under questioning from defense lawyers, Carpenter told the jury that by early March 1981, after his parents had thrown him out of their home, desperate themes of homicide and suicide were "running rampant" in Hinckley's mind. Hinckley wanted to "bring this roller coaster to an end," Carpenter said.

Hinckley went to Hollywood in late March to make another attempt to reach fame as a rock music star, but when that failed he headed again for New Haven and Yale where he thought he would "end it all" through suicide or murder and suicide, Carpenter said.

He bought a bus ticket for Washington, thinking he didn't have the money to make it to New Haven and tried unsuccessfully to change his rouute when he angrily realized he could have made the trip directly, Carpenter said. Hinckley checked into the Park Central Hotel in Washington on March 29, one day before he shot Reagan and wounded three others.

When Hinckley decided to go to the Washington Hilton to try to assassinate Reagan, he "wasn't sure what the outcome of the trip would be" since he had stalked both Reagan and President Carter before but had taken no action, Carpenter said. Two factors led Hinckley to finally fire the shots, Carpenter testified.

First, Hinckley felt a sense of "highly personel" contact between himself and Reagan when Reagan turned and waved in Hinckley's direction as he was entering the hotel, where he was to give a speech, Carpenter said.

Hinckley had similar reactionsd when he had seen Foster's movies on television, Carpenter said, adding that Hinckley thought those broadcasts were intended to "excite" him to take action.

When Reagan emerged from the hotel, Carpenter said, Hinckley experienced time "moving very quickly," unlike other times when he had seen Reagan or Carter. That "rapid time frame" helped provoke him to shoot, Carpenter said.

"His primary purpose in all of this is to terminate his own experiences, his own existence," Carpenter told the jury.