London — The prime ministers of Britain and South Africa are hopeful that the independence of Namibia (South-West Africa) will be negotiated by the end of next year.
This cautiously optimistic reading of a five-hour meeting between Margaret Thatcher and P. W. Botha took some time to emerge after the first visit to Britain by a South African prime minister in 23 years.
At first the result of their talks at Mrs. Thatcher's country home, Chequers, appeared to have been a cool standoff, with each leader spelling out mutually exclusive attitudes to apartheid.
Mrs. Thatcher told Mr. Botha that separate racial development was abhorrent to Britain. Botha responded by reminding her that apartheid was an internal matter.
But exchanges on racial questions took up only one-quarter of their conversation. The rest was centered on the future of Namibia - in particular, on ways of setting the territory on course for independence.
Their top-secret exchange on the future of mineral-rich Namibia and its 1 million people, officials said later, dealt with a timetable for independence and new South African ideas for speeding the process.
Diplomatic sources said two fresh ideas were central to the Thatcher-Botha talks:
* Possible ways to soften insistence by South Africa and the United States on the need for Cuba to remove its estimated 25,000 to 30,000 troops from Angola as a condition of independence.
* Supervising the pre-independence period in Namibia not by United Nations troops but by a mixed African force.
Both ideas are controversial, and sources suggest Thatcher would discuss them with President Reagan before this week's economic summit.
South African officials refused to discuss the Namibia formula, but diplomats from neighboring black African nations suggested Botha may be prepared to cut a few corners over Namibia if an independence formula can be found that will guarantee his country's security.
One concept Botha is said to be entertaining is a treaty with post-independence Namibia similar to the South Africa-Mozambique nonaggression pact.
The Thatcher-Botha talks drew heavy criticism from Britain's Labour Party opposition. And the biggest anti-apartheid demonstrations ever seen in central London forced Botha to fly by helicopter direct to Chequers.
While demonstrators chanted anti-apartheid slogans, the two prime ministers had lunch together, then talked on before Botha flew to Switzerland and Germany.
Later British officials said Thatcher refused a request by Botha that the African National Congress's office in London be shut down. She also complained to Botha about South African Embassy ''dirty tricks'' against the country's blacks in London.
But in terms of propaganda, Botha may have come out the winner. His in-flight interview with a British reporter en route to Switzerland received much attention when broadcast that evening. It is still being quoted.
Botha indicated he told Thatcher not to interfere in South Africa's internal policies and said she had not lambasted, but only ''asked for facts'' about, race policy.