The Reagan administration sought today to improve dramatically U.S. relations with Brazil through a series of initiatives that includes a $1.23 billion loan to ease the serious financial difficulties of Latin America's largest nation.

The 90-day loan, which Treasury Secretary Donald T. Regan said would cushion Brazil pending the arrangement of long-term financing from the International Monetary Fund, was the most important of several steps taken today to strengthen U.S.-Brazilian ties during President Reagan's three-day visit here.

Other initiatives included a modest relaxation of sugar import restrictions and the formation of four binational working groups, one the first between the two countries on science and technology, and another that could lead to restoration of military ties ended by Brazil in 1977 over dissatisfaction with the Carter administration.

Brazil also was making moves designed to increase economic cooperation.

Brazilian officials pointed out that their country supported key U.S. trade initiatives proposed at the meeting of Western trade ministers in Geneva last week. And before the presidential party departs Friday, Brazil is expected to announce its agreement to a two-year phase-out of a series of export subsidies long opposed by the United States.

Brazilian leaders and journals of opinion responded positively to the U.S. initiatives and praised President Reagan for his efforts to improve relations between the two nations. However, in remarks that were unusually frank for such a ceremonial occasion, Brazilian President Joao Figueiredo emphasized that his appreciation for U.S. economic cooperation would not alter Brazil's determination to pursue an independent foreign policy oriented toward Africa and developing nations.

In a statement at a dinner honoring Reagan, the Brazilian president, whose country maintains close relations with Angola, called for the independence of Namibia.

Figueiredo also expressed "apprehension as regards the deteriorating political situation in Central America" and said that Brazil, Colombia and Mexico should play a larger role in the regional peace process.

"Together we must face the problems so strongly affecting Latin America," Figueiredo said. "But we must search for their economic and social roots as pluralistic and democratic solutions cannot prosper in a climate of general poverty and social instability, where each country feels threatened in its economic security."

Reagan, in a conciliatory toast to Figueiredo, with whom he went riding earlier in the day, made only an indirect reference to his oft-stated view that Central America is being subverted by communist revolutionaries encouraged by the Soviet Union, armed by Cuba and inspired by the Sandinista regime in Nicaragua.

The subject of Cuba did not arise in the private meetings of the two presidents, according to U.S. Secretary of State George P. Shultz.

Tonight, Reagan devoted only one paragraph of his long toast to the subversion issue, saying that legitimate governments were being undermined by insurgents who are "armed by the surrogate of a faraway power, a power that espouses a philosophy alien to the Americas, whose goal is the destabilization of our governments and economies."

The emphasis of Reagan's toast was on hemispheric economic cooperation. He said that both the United States and Brazil "are taking the painful steps necessary to overcome the economic crisis that threatens our people.

"Self-discipline is necessary," Reagan said. "So, too, is mutual accommodation. Borrowers must move to restrict their deficits but it is just as important that leaders not withhold new funds from countries which adopt effective stabilization plans. Lenders and borrowers must remember that each has an enormous stake in the other's success."

This was a reference to recent U.S. decisions to aid the deteriorating economy of Mexico as well as to the loan to Brazil that was announced today.

From the Brazilian point of view, the loan, which is to be repaid at the prevailing short term Treasury rate of about 8 percent, represents a badly needed infusion of funds to close external accounts jolted out of balance by slumping exports and the reluctance of foreign bankers to lend money to Latin America after the near fiscal collapse of Mexico.

The change in the sugar import quotas was a technical one, allowing importation of sugar cane by the United States for processing purposes including gasohol, of which oil-hungry Brazil is the world's largest producer and user.

Shultz announced the binational working groups would deal with economic problems, nuclear issues, science and technology and military cooperation.

In 1977 Brazil ended a 25-year arms assistance pact with the United States in retaliation for President Carter's complaints about human rights violations.

Since then Brazil has made strides toward internal democracy while the United States, under Reagan, has deemphasized human rights as a touchstone for relations with noncommunist nations.