It costs more than $40,000 in public money for a mentally ill person to be homeless for a year in New York City, nearly as much as it costs for the same person to live in supportive housing, said a University of Pennsylvania study to be released today.

The long-awaited study used computer records from eight New York State and city agencies, including hospitals, jails, shelters and Medicaid offices, to review the histories of almost 5,000 homeless people in supportive housing. They were then compared with a matched control group of 5,000 other homeless people who were not placed in such housing.

Those left to fend for themselves consumed an average of $40,449 each year in public services during a two-year study period, the researchers found, the bulk of it in acute-care hospitals and homeless shelters.

But for each person in supportive housing under a joint city and state program known as New York/New York, costs in such public services were reduced by an average of $16,282 year round. The net cost of the supportive-housing program was $744 per placement, or $995 a year per unit constructed and run at an annual outlay of $17,277.