The U.S. merchandise trade deficit improved substantially in April, dropping to its lowest level in 40 months as American companies held onto most of the record export gains they had recorded the previous month, the government reported yesterday.</br></br>The high export figures, combined with a sharp decline in U.S. purchases of foreign products, lowered the trade deficit to $9.9 billion,</br></br>The unexpectedly good trade figures sparked a major rally on Wall Street, where stock prices jumped to an early lead of more than 38 points before retreating slightly. Even so, the Dow-Jones average of industrial stocks closed up 25 points at 2124.5, the highest close since before OctoberÛªs market collapse. [Story on Page Fl.J</br></br>The news also rallied bond markets, where prices surged in one of their biggest gains of the year, pushing long-term yields to two-month lows. The dollar also rose sharply against nearly every major currency.</br></br>The numbers are expected to buoy President Reagan when he makes the last summit appearance of his presidency at next weekÛªs meeting of leaders of industrialized nations. The good trade figures follow a series of positive government reports showing low unemployment, increased industrial production and relatively low inflation.